IsotonicRegressionModel (Spark 3.5.5 JavaDoc) (original) (raw)
Object
- org.apache.spark.mllib.regression.IsotonicRegressionModel
All Implemented Interfaces:
java.io.Serializable, Saveable
public class IsotonicRegressionModel
extends Object
implements java.io.Serializable, Saveable
Regression model for isotonic regression.
param: boundaries Array of boundaries for which predictions are known. Boundaries must be sorted in increasing order. param: predictions Array of predictions associated to the boundaries at the same index. Results of isotonic regression and therefore monotone. param: isotonic indicates whether this is isotonic or antitonic.
See Also:
Serialized Form
Constructor Summary
Constructors
Constructor and Description IsotonicRegressionModel(double[] boundaries, double[] predictions, boolean isotonic) IsotonicRegressionModel(Iterable boundaries, Iterable predictions, Boolean isotonic) A Java-friendly constructor that takes two Iterable parameters and one Boolean parameter. Method Summary
All Methods Static Methods Instance Methods Concrete Methods
Modifier and Type Method and Description double[] boundaries() boolean isotonic() static IsotonicRegressionModel load(SparkContext sc, String path) double predict(double testData) Predict a single label. JavaDoubleRDD predict(JavaDoubleRDD testData) Predict labels for provided features. RDD predict(RDD testData) Predict labels for provided features. double[] predictions() void save(SparkContext sc, String path) Save this model to the given path. * ### Methods inherited from class Object `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
Constructor Detail
* #### IsotonicRegressionModel public IsotonicRegressionModel(double[] boundaries, double[] predictions, boolean isotonic) * #### IsotonicRegressionModel public IsotonicRegressionModel(Iterable<Object> boundaries, Iterable<Object> predictions, Boolean isotonic) A Java-friendly constructor that takes two Iterable parameters and one Boolean parameter. Parameters: `boundaries` \- (undocumented) `predictions` \- (undocumented) `isotonic` \- (undocumented)
Method Detail
* #### load public static [IsotonicRegressionModel](../../../../../org/apache/spark/mllib/regression/IsotonicRegressionModel.html "class in org.apache.spark.mllib.regression") load([SparkContext](../../../../../org/apache/spark/SparkContext.html "class in org.apache.spark") sc, String path) * #### boundaries public double[] boundaries() * #### predictions public double[] predictions() * #### isotonic public boolean isotonic() * #### predict public [RDD](../../../../../org/apache/spark/rdd/RDD.html "class in org.apache.spark.rdd")<Object> predict([RDD](../../../../../org/apache/spark/rdd/RDD.html "class in org.apache.spark.rdd")<Object> testData) Predict labels for provided features. Using a piecewise linear function. Parameters: `testData` \- Features to be labeled. Returns: Predicted labels. * #### predict public [JavaDoubleRDD](../../../../../org/apache/spark/api/java/JavaDoubleRDD.html "class in org.apache.spark.api.java") predict([JavaDoubleRDD](../../../../../org/apache/spark/api/java/JavaDoubleRDD.html "class in org.apache.spark.api.java") testData) Predict labels for provided features. Using a piecewise linear function. Parameters: `testData` \- Features to be labeled. Returns: Predicted labels. * #### predict public double predict(double testData) Predict a single label. Using a piecewise linear function. Parameters: `testData` \- Feature to be labeled. Returns: Predicted label. 1) If testData exactly matches a boundary then associated prediction is returned. In case there are multiple predictions with the same boundary then one of them is returned. Which one is undefined (same as java.util.Arrays.binarySearch). 2) If testData is lower or higher than all boundaries then first or last prediction is returned respectively. In case there are multiple predictions with the same boundary then the lowest or highest is returned respectively. 3) If testData falls between two values in boundary array then prediction is treated as piecewise linear function and interpolated value is returned. In case there are multiple values with the same boundary then the same rules as in 2) are used. * #### save public void save([SparkContext](../../../../../org/apache/spark/SparkContext.html "class in org.apache.spark") sc, String path) Description copied from interface: `[Saveable](../../../../../org/apache/spark/mllib/util/Saveable.html#save-org.apache.spark.SparkContext-java.lang.String-)` Save this model to the given path. This saves: - human-readable (JSON) model metadata to path/metadata/ - Parquet formatted data to path/data/ The model may be loaded using `Loader.load`. Specified by: `[save](../../../../../org/apache/spark/mllib/util/Saveable.html#save-org.apache.spark.SparkContext-java.lang.String-)` in interface `[Saveable](../../../../../org/apache/spark/mllib/util/Saveable.html "interface in org.apache.spark.mllib.util")` Parameters: `sc` \- Spark context used to save model data. `path` \- Path specifying the directory in which to save this model. If the directory already exists, this method throws an exception.