DecisionTreeModel

class pyspark.mllib.tree.DecisionTreeModel(java_model: py4j.java_gateway.JavaObject)

A decision tree model for classification or regression.

Methods

call(name, *a)

Call method of java_model

depth()

Get depth of tree (e.g.

load(sc, path)

Load a model from the given path.

numNodes()

Get number of nodes in tree, including leaf nodes.

predict(x)

Predict the label of one or more examples.

save(sc, path)

Save this model to the given path.

toDebugString()

full model.

Methods Documentation

call(name: str, *a: Any) → Any

Call method of java_model

depth() → int

Get depth of tree (e.g. depth 0 means 1 leaf node, depth 1 means 1 internal node + 2 leaf nodes).

classmethod load(sc: pyspark.context.SparkContext, path: str) → JL

Load a model from the given path.

numNodes() → int

Get number of nodes in tree, including leaf nodes.

predict(x: Union[VectorLike, pyspark.rdd.RDD[VectorLike]]) → Union[float, pyspark.rdd.RDD[float]]

Predict the label of one or more examples.

Parameters
xpyspark.mllib.linalg.Vector or pyspark.RDD

Data point (feature vector), or an RDD of data points (feature vectors).

Notes

In Python, predict cannot currently be used within an RDD transformation or action. Call predict directly on the RDD instead.

save(sc: pyspark.context.SparkContext, path: str) → None

Save this model to the given path.

toDebugString() → str

full model.