Class DecisionTreeModel

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

public class DecisionTreeModel extends Object implements scala.Serializable, Saveable
Decision tree model for classification or regression. This model stores the decision tree structure and parameters. param: topNode root node param: algo algorithm type -- classification or regression
See Also:
  • Constructor Details

    • DecisionTreeModel

      public DecisionTreeModel(Node topNode, scala.Enumeration.Value algo)
  • Method Details

    • load

      public static DecisionTreeModel 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
    • 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)
    • topNode

      public Node topNode()
    • algo

      public scala.Enumeration.Value algo()
    • 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:
      Double prediction from the trained model
    • predict

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

      Parameters:
      features - RDD representing data points to be predicted
      Returns:
      RDD of predictions for each of the given data points
    • predict

      public JavaRDD<Double> predict(JavaRDD<Vector> features)
      Predict values for the given data set using the model trained.

      Parameters:
      features - JavaRDD representing data points to be predicted
      Returns:
      JavaRDD of predictions for each of the given data points
    • numNodes

      public int numNodes()
      Get number of nodes in tree, including leaf nodes.
      Returns:
      (undocumented)
    • depth

      public int depth()
      Get depth of tree. E.g.: Depth 0 means 1 leaf node. Depth 1 means 1 internal node and 2 leaf nodes.
      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)
    • 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.