Class RandomForestModel

Object
org.apache.spark.mllib.tree.model.RandomForestModel
All Implemented Interfaces:
Serializable, Saveable, scala.Serializable

public class RandomForestModel extends Object implements Saveable
Represents a random forest model.

param: algo algorithm for the ensemble model, either Classification or Regression param: trees tree ensembles

See Also:
  • Constructor Details

    • RandomForestModel

      public RandomForestModel(scala.Enumeration.Value algo, DecisionTreeModel[] trees)
  • Method Details

    • load

      public static RandomForestModel load(SparkContext sc, String path)
      Parameters:
      sc - Spark context used for loading model files.
      path - Path specifying the directory to which the model was saved.
      Returns:
      Model instance
    • algo

      public scala.Enumeration.Value algo()
    • trees

      public DecisionTreeModel[] trees()
    • 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.
    • org$apache$spark$internal$Logging$$log_

      public static org.slf4j.Logger org$apache$spark$internal$Logging$$log_()
    • org$apache$spark$internal$Logging$$log__$eq

      public static void org$apache$spark$internal$Logging$$log__$eq(org.slf4j.Logger x$1)
    • predict

      public double predict(Vector features)
      Predict values for a single data point using the model trained.

      Parameters:
      features - array representing a single data point
      Returns:
      predicted category from the trained model
    • predict

      public RDD<Object> predict(RDD<Vector> features)
      Predict values for the given data set.

      Parameters:
      features - RDD representing data points to be predicted
      Returns:
      RDD[Double] where each entry contains the corresponding prediction
    • predict

      public JavaRDD<Double> predict(JavaRDD<Vector> features)
      Java-friendly version of org.apache.spark.mllib.tree.model.TreeEnsembleModel.predict.
      Parameters:
      features - (undocumented)
      Returns:
      (undocumented)
    • toString

      public String toString()
      Print a summary of the model.
      Overrides:
      toString in class Object
      Returns:
      (undocumented)
    • toDebugString

      public String toDebugString()
      Print the full model to a string.
      Returns:
      (undocumented)
    • numTrees

      public int numTrees()
      Get number of trees in ensemble.
      Returns:
      (undocumented)
    • totalNumNodes

      public int totalNumNodes()
      Get total number of nodes, summed over all trees in the ensemble.
      Returns:
      (undocumented)