RandomForestModel

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

Represents a random forest model.

New in version 1.2.0.

Methods

call(name, *a)

Call method of java_model

load(sc, path)

Load a model from the given path.

numTrees()

Get number of trees in ensemble.

predict(x)

Predict values for a single data point or an RDD of points using the model trained.

save(sc, path)

Save this model to the given path.

toDebugString()

Full model

totalNumNodes()

Get total number of nodes, summed over all trees in the ensemble.

Methods Documentation

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

Call method of java_model

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

Load a model from the given path.

New in version 1.3.0.

numTrees() → int

Get number of trees in ensemble.

New in version 1.3.0.

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

Predict values for a single data point or an RDD of points using the model trained.

New in version 1.3.0.

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

Full model

New in version 1.3.0.

totalNumNodes() → int

Get total number of nodes, summed over all trees in the ensemble.

New in version 1.3.0.