Class IsotonicRegressionModel
Object
org.apache.spark.mllib.regression.IsotonicRegressionModel
- All Implemented Interfaces:
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:
-
Constructor Summary
ConstructorDescriptionIsotonicRegressionModel
(double[] boundaries, double[] predictions, boolean isotonic) IsotonicRegressionModel
(Iterable<Object> boundaries, Iterable<Object> predictions, Boolean isotonic) A Java-friendly constructor that takes two Iterable parameters and one Boolean parameter. -
Method Summary
Modifier and TypeMethodDescriptiondouble[]
boolean
isotonic()
static IsotonicRegressionModel
load
(SparkContext sc, String path) double
predict
(double testData) Predict a single label.predict
(JavaDoubleRDD testData) Predict labels for provided features.Predict labels for provided features.double[]
void
save
(SparkContext sc, String path) Save this model to the given path.
-
Constructor Details
-
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 Details
-
load
-
boundaries
public double[] boundaries() -
predictions
public double[] predictions() -
isotonic
public boolean isotonic() -
predict
Predict labels for provided features. Using a piecewise linear function.- Parameters:
testData
- Features to be labeled.- Returns:
- Predicted labels.
-
predict
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
Description copied from interface:Saveable
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
.
-