RandomForestRegressor#
- class cuml.dask.ensemble.RandomForestRegressor(
- *,
- workers=None,
- client=None,
- verbose=False,
- n_estimators=100,
- random_state=None,
- ignore_empty_partitions=None,
- **kwargs,
Multi-GPU Random Forest regressor model which fits multiple decision tree regressors in an ensemble. This uses Dask to partition data over multiple GPUs (possibly on different nodes).
During fitting, all workers that hold training rows collectively build the same forest from the complete distributed dataset.
- Parameters:
- n_estimatorsint (default = 100)
total number of trees in the forest
- split_criterionint or string (default =
2('mse')) The criterion used to split nodes.
0or'gini'for gini impurity1or'entropy'for information gain (entropy)2or'mse'for mean squared error4or'poisson'for poisson half deviance5or'gamma'for gamma half deviance6or'inverse_gaussian'for inverse gaussian deviance
0,'gini',1,'entropy'not valid for regression- bootstrapboolean (default = True)
Control bootstrapping.
If
True, each tree in the forest is built on a bootstrapped sample with replacement.If
False, the whole dataset is used to build each tree.
Weighted bootstrapping through
sample_weightis not yet supported for distributed random forests.- max_samplesfloat (default = 1.0)
Ratio of dataset rows used while fitting each tree.
- max_depthint or None (default = None)
Maximum tree depth. Use
Nonefor unlimited depth (trees grow until all leaves are pure). Must be a positive integer orNone.Changed in version 26.08: The default of
max_depthchanged from16toNone.- max_leavesint (default = -1)
Maximum leaf nodes per tree. Soft constraint. Unlimited, If
-1.- max_featuresfloat (default = ‘auto’)
Ratio of number of features (columns) to consider per node split.
If type
intthenmax_featuresis the absolute count of features to be used.If type
floatthenmax_featuresis a fraction.If
'auto'thenmax_features=n_features = 1.0.If
'sqrt'thenmax_features=1/sqrt(n_features).If
'log2'thenmax_features=log2(n_features)/n_features.If
None, thenmax_features = 1.0.
- n_binsint (default = 128)
Maximum number of bins used by the split algorithm per feature.
- min_samples_leafint or float (default = 1)
The minimum number of samples (rows) in each leaf node.
If type
int, thenmin_samples_leafrepresents the minimum number.If
float, thenmin_samples_leafrepresents a fraction andceil(min_samples_leaf * n_rows)is the minimum number of samples for each leaf node.
- min_samples_splitint or float (default = 2)
The minimum number of samples required to split an internal node.
If type
int, thenmin_samples_splitrepresents the minimum number.If type
float, thenmin_samples_splitrepresents a fraction andceil(min_samples_split * n_rows)is the minimum number of samples for each split.
- n_streamsint
Deprecated. Distributed training currently builds trees serially to preserve collective order.
- workersoptional, list of strings
Dask addresses of workers to use for computation. If None, all available Dask workers will be used.
- random_stateint (default = None)
Seed for the random number generator. Unseeded by default.
- ignore_empty_partitions: optional, boolean
Deprecated. This parameter no longer has any effect and will be removed in release 26.12.
- Attributes:
- oob_prediction_
Methods
fit(X, y[, broadcast_data, sample_weight])Fit the input data with a Random Forest regression model
get_params([deep])Returns the value of all parameters required to configure this estimator as a dictionary.
predict(X[, layout, default_chunk_size, ...])Predicts the regressor outputs for X.
set_params(**params)Sets the value of parameters required to configure this estimator, it functions similar to the sklearn set_params.
- fit(
- X,
- y,
- broadcast_data=None,
- sample_weight=None,
Fit the input data with a Random Forest regression model
Only workers holding one or more training rows participate in fitting.
When persisting data, you can use
cuml.dask.common.utils.persist_across_workersto simplify this:X_dask_cudf = dask_cudf.from_cudf(X_cudf, npartitions=n_workers) y_dask_cudf = dask_cudf.from_cudf(y_cudf, npartitions=n_workers) X_dask_cudf, y_dask_cudf = persist_across_workers(dask_client, [X_dask_cudf, y_dask_cudf])
This is equivalent to calling
persistwith the data and workers):X_dask_cudf, y_dask_cudf = dask_client.persist([X_dask_cudf, y_dask_cudf], workers={ X_dask_cudf:workers, y_dask_cudf:workers })
- Parameters:
- XDask cuDF DataFrame or CuPy backed Dask Array (n_rows, n_features)
Distributed dense matrix (floats or doubles) of shape (n_samples, n_features).
- yDask cuDF DataFrame or CuPy backed Dask Array (n_rows, 1)
Labels of training examples. y must be partitioned the same way as X
- sample_weightarray-like, optional
Sample weights are not yet supported by distributed random forests.
- broadcast_databool, optional
Deprecated. This parameter no longer has effect and will be removed in release 26.12.
- get_combined_model()[source]#
Return single-GPU model for serialization
- Returns:
- modelTrained single-GPU model or None if the model has not
yet been trained.
- get_params(deep=True)[source]#
Returns the value of all parameters required to configure this estimator as a dictionary.
- Parameters:
- deepboolean (default = True)
- predict(
- X,
- layout='depth_first',
- default_chunk_size=None,
- align_bytes=None,
- delayed=True,
- broadcast_data=None,
Predicts the regressor outputs for X.
- Parameters:
- XDask cuDF dataframe or CuPy backed Dask Array (n_rows, n_features)
Distributed dense matrix (floats or doubles) of shape (n_samples, n_features).
- layoutstring (default = ‘depth_first’)
Specifies the in-memory layout of nodes in nvForest models. Options: ‘depth_first’, ‘layered’, ‘breadth_first’.
- default_chunk_sizeint, optional (default = None)
Determines how batches are further subdivided for parallel processing. The optimal value depends on hardware, model, and batch size. If None, will be automatically determined.
- align_bytesint, optional (default = None)
If specified, trees will be padded such that their in-memory size is a multiple of this value. This can improve performance by guaranteeing that memory reads from trees begin on a cache line boundary. Typical values are 0 or 128.
- delayedbool (default = True)
Whether to do a lazy prediction (and return Delayed objects) or an eagerly executed one.
- broadcast_databool, optional
Deprecated. This parameter no longer has effect and will be removed in release 26.12.
- Returns:
- yDask cuDF dataframe or CuPy backed Dask Array (n_rows, 1)