Class IsotonicRegressionModel

Object
org.apache.spark.mllib.regression.IsotonicRegressionModel
All Implemented Interfaces:
Serializable, Saveable

public class IsotonicRegressionModel extends Object implements 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 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

      public static IsotonicRegressionModel load(SparkContext sc, String path)
    • boundaries

      public double[] boundaries()
    • predictions

      public double[] predictions()
    • isotonic

      public boolean isotonic()
    • predict

      public RDD<Object> predict(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 predict(JavaDoubleRDD 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 sc, String path)
      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.

      Specified by:
      save in interface Saveable
      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.