org.apache.spark.mllib.tree.model
Class DecisionTreeModel

Object
  extended by org.apache.spark.mllib.tree.model.DecisionTreeModel
All Implemented Interfaces:
java.io.Serializable, Saveable

public class DecisionTreeModel
extends Object
implements scala.Serializable, Saveable

:: Experimental :: 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:
Serialized Form

Constructor Summary
DecisionTreeModel(Node topNode, scala.Enumeration.Value algo)
           
 
Method Summary
 scala.Enumeration.Value algo()
           
 int depth()
          Get depth of tree.
static DecisionTreeModel load(SparkContext sc, String path)
           
 int numNodes()
          Get number of nodes in tree, including leaf nodes.
 JavaRDD<Object> predict(JavaRDD<Vector> features)
          Predict values for the given data set using the model trained.
 RDD<Object> predict(RDD<Vector> features)
          Predict values for the given data set using the model trained.
 double predict(Vector features)
          Predict values for a single data point using the model trained.
 void save(SparkContext sc, String path)
          Save this model to the given path.
 String toDebugString()
          Print the full model to a string.
 Node topNode()
           
 String toString()
          Print a summary of the model.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DecisionTreeModel

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

load

public static DecisionTreeModel load(SparkContext sc,
                                     String path)

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<Object> 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.