RandomForestRegressionModel#

class spark_rapids_ml.regression.RandomForestRegressionModel(n_cols: int, dtype: str, treelite_model: Union[str, List[str]], model_json: Union[List[str], List[List[str]]] = [])#

Model fitted by RandomForestRegressor.

Methods

clear(param)

Reset a Spark ML Param to its default value, setting matching cuML parameter, if exists.

copy([extra])

cpu()

Return the PySpark ML RandomForestRegressionModel

explainParam(param)

Explains a single param and returns its name, doc, and optional default value and user-supplied value in a string.

explainParams()

Returns the documentation of all params with their optionally default values and user-supplied values.

extractParamMap([extra])

Extracts the embedded default param values and user-supplied values, and then merges them with extra values from input into a flat param map, where the latter value is used if there exist conflicts, i.e., with ordering: default param values < user-supplied values < extra.

getBootstrap()

Gets the value of bootstrap or its default value.

getFeatureSubsetStrategy()

Gets the value of featureSubsetStrategy or its default value.

getFeaturesCol()

Gets the value of featuresCol or featuresCols

getFeaturesCols()

Gets the value of featuresCols or its default value.

getImpurity()

Gets the value of impurity or its default value.

getLabelCol()

Gets the value of labelCol or its default value.

getMaxBins()

Gets the value of maxBins or its default value.

getMaxDepth()

Gets the value of maxDepth or its default value.

getMinInstancesPerNode()

Gets the value of minInstancesPerNode or its default value.

getOrDefault(param)

Gets the value of a param in the user-supplied param map or its default value.

getParam(paramName)

Gets a param by its name.

getPredictionCol()

Gets the value of predictionCol or its default value.

getSeed()

Gets the value of seed or its default value.

hasDefault(param)

Checks whether a param has a default value.

hasParam(paramName)

Tests whether this instance contains a param with a given (string) name.

isDefined(param)

Checks whether a param is explicitly set by user or has a default value.

isSet(param)

Checks whether a param is explicitly set by user.

load(path)

Reads an ML instance from the input path, a shortcut of read().load(path).

predict(value)

Predict label for the given features.

predictLeaf(value)

Predict the indices of the leaves corresponding to the feature vector.

read()

save(path)

Save this ML instance to the given path, a shortcut of 'write().save(path)'.

set(param, value)

Sets a parameter in the embedded param map.

setFeaturesCol(value)

Sets the value of featuresCol or featureCols.

setFeaturesCols(value)

Sets the value of featuresCols.

setLabelCol(value)

Sets the value of labelCol.

setPredictionCol(value)

Sets the value of predictionCol.

transform(dataset[, params])

Transforms the input dataset with optional parameters.

write()

Attributes

bootstrap

cuml_params

Returns the dictionary of parameters intended for the underlying cuML class.

featureImportances

Estimate the importance of each feature.

featureSubsetStrategy

featuresCol

featuresCols

getNumTrees

Number of trees in ensemble.

impurity

labelCol

maxBins

maxDepth

minInstancesPerNode

numFeatures

Returns the number of features the model was trained on.

numTrees

num_workers

Number of cuML workers, where each cuML worker corresponds to one Spark task running on one GPU.

params

Returns all params ordered by name.

predictionCol

seed

supportedFeatureSubsetStrategies

supportedImpurities

toDebugString

Full description of model.

totalNumNodes

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

treeWeights

Return the weights for each tree.

trees

Trees in this ensemble.

Methods Documentation

clear(param: Param) None#

Reset a Spark ML Param to its default value, setting matching cuML parameter, if exists.

copy(extra: Optional[ParamMap] = None) P#
cpu() RandomForestRegressionModel#

Return the PySpark ML RandomForestRegressionModel

explainParam(param: Union[str, Param]) str#

Explains a single param and returns its name, doc, and optional default value and user-supplied value in a string.

explainParams() str#

Returns the documentation of all params with their optionally default values and user-supplied values.

extractParamMap(extra: Optional[ParamMap] = None) ParamMap#

Extracts the embedded default param values and user-supplied values, and then merges them with extra values from input into a flat param map, where the latter value is used if there exist conflicts, i.e., with ordering: default param values < user-supplied values < extra.

Parameters:
extradict, optional

extra param values

Returns:
dict

merged param map

getBootstrap() bool#

Gets the value of bootstrap or its default value.

New in version 3.0.0.

getFeatureSubsetStrategy() str#

Gets the value of featureSubsetStrategy or its default value.

New in version 1.4.0.

getFeaturesCol() Union[str, List[str]]#

Gets the value of featuresCol or featuresCols

getFeaturesCols() List[str]#

Gets the value of featuresCols or its default value.

getImpurity() str#

Gets the value of impurity or its default value.

New in version 1.4.0.

getLabelCol() str#

Gets the value of labelCol or its default value.

getMaxBins() int#

Gets the value of maxBins or its default value.

getMaxDepth() int#

Gets the value of maxDepth or its default value.

getMinInstancesPerNode() int#

Gets the value of minInstancesPerNode or its default value.

getOrDefault(param: Union[str, Param[T]]) Union[Any, T]#

Gets the value of a param in the user-supplied param map or its default value. Raises an error if neither is set.

getParam(paramName: str) Param#

Gets a param by its name.

getPredictionCol() str#

Gets the value of predictionCol or its default value.

getSeed() int#

Gets the value of seed or its default value.

hasDefault(param: Union[str, Param[Any]]) bool#

Checks whether a param has a default value.

hasParam(paramName: str) bool#

Tests whether this instance contains a param with a given (string) name.

isDefined(param: Union[str, Param[Any]]) bool#

Checks whether a param is explicitly set by user or has a default value.

isSet(param: Union[str, Param[Any]]) bool#

Checks whether a param is explicitly set by user.

classmethod load(path: str) RL#

Reads an ML instance from the input path, a shortcut of read().load(path).

predict(value: Vector) float#

Predict label for the given features.

predictLeaf(value: Vector) float#

Predict the indices of the leaves corresponding to the feature vector.

classmethod read() MLReader#
save(path: str) None#

Save this ML instance to the given path, a shortcut of ‘write().save(path)’.

set(param: Param, value: Any) None#

Sets a parameter in the embedded param map.

setFeaturesCol(value: Union[str, List[str]]) P#

Sets the value of featuresCol or featureCols.

setFeaturesCols(value: List[str]) P#

Sets the value of featuresCols.

setLabelCol(value: str) P#

Sets the value of labelCol.

setPredictionCol(value: str) P#

Sets the value of predictionCol.

transform(dataset: DataFrame, params: Optional[ParamMap] = None) DataFrame#

Transforms the input dataset with optional parameters.

New in version 1.3.0.

Parameters:
datasetpyspark.sql.DataFrame

input dataset

paramsdict, optional

an optional param map that overrides embedded params.

Returns:
pyspark.sql.DataFrame

transformed dataset

write() MLWriter#

Attributes Documentation

bootstrap: Param[bool] = Param(parent='undefined', name='bootstrap', doc='Whether bootstrap samples are used when building trees.')#
cuml_params#

Returns the dictionary of parameters intended for the underlying cuML class.

featureImportances#

Estimate the importance of each feature.

featureSubsetStrategy: Param[str] = Param(parent='undefined', name='featureSubsetStrategy', doc="The number of features to consider for splits at each tree node. Supported options: 'auto' (choose automatically for task: If numTrees == 1, set to 'all'. If numTrees > 1 (forest), set to 'sqrt' for classification and to 'onethird' for regression), 'all' (use all features), 'onethird' (use 1/3 of the features), 'sqrt' (use sqrt(number of features)), 'log2' (use log2(number of features)), 'n' (when n is in the range (0, 1.0], use n * number of features. When n is in the range (1, number of features), use n features). default = 'auto'")#
featuresCol: Param[str] = Param(parent='undefined', name='featuresCol', doc='features column name.')#
featuresCols = Param(parent='undefined', name='featuresCols', doc='features column names for multi-column input.')#
getNumTrees#

Number of trees in ensemble.

impurity: Param[str] = Param(parent='undefined', name='impurity', doc='Criterion used for information gain calculation (case-insensitive). Supported options: variance')#
labelCol: Param[str] = Param(parent='undefined', name='labelCol', doc='label column name.')#
maxBins: Param[int] = Param(parent='undefined', name='maxBins', doc='Max number of bins for discretizing continuous features.  Must be >=2 and >= number of categories for any categorical feature.')#
maxDepth: Param[int] = Param(parent='undefined', name='maxDepth', doc='Maximum depth of the tree. (>= 0) E.g., depth 0 means 1 leaf node; depth 1 means 1 internal node + 2 leaf nodes. Must be in range [0, 30].')#
minInstancesPerNode: Param[int] = Param(parent='undefined', name='minInstancesPerNode', doc='Minimum number of instances each child must have after split. If a split causes the left or right child to have fewer than minInstancesPerNode, the split will be discarded as invalid. Should be >= 1.')#
numFeatures#

Returns the number of features the model was trained on. If unknown, returns -1

numTrees: Param[int] = Param(parent='undefined', name='numTrees', doc='Number of trees to train (>= 1).')#
num_workers#

Number of cuML workers, where each cuML worker corresponds to one Spark task running on one GPU.

params#

Returns all params ordered by name. The default implementation uses dir() to get all attributes of type Param.

predictionCol: Param[str] = Param(parent='undefined', name='predictionCol', doc='prediction column name.')#
seed: Param[int] = Param(parent='undefined', name='seed', doc='random seed.')#
supportedFeatureSubsetStrategies: List[str] = ['auto', 'all', 'onethird', 'sqrt', 'log2']#
supportedImpurities: List[str] = ['variance']#
toDebugString#

Full description of model.

totalNumNodes#

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

treeWeights#

Return the weights for each tree.

trees#

Trees in this ensemble. Warning: These have null parent Estimators.