DecisionTreeModel

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

A decision tree model for classification or regression.

New in version 1.1.0.

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[source]

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

New in version 1.1.0.

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

Load a model from the given path.

New in version 1.3.0.

numNodes() → int[source]

Get number of nodes in tree, including leaf nodes.

New in version 1.1.0.

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

Predict the label of one or more examples.

New in version 1.1.0.

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.

New in version 1.3.0.

toDebugString() → str[source]

full model.

New in version 1.2.0.