KNeighborsRegressor#

class cuml.dask.neighbors.KNeighborsRegressor(*, client=None, streams_per_handle=0, verbose=False, **kwargs)[source]#

Multi-node Multi-GPU K-Nearest Neighbors Regressor Model.

K-Nearest Neighbors Regressor is an instance-based learning technique, that keeps training samples around for prediction, rather than trying to learn a generalizable set of model parameters.

Parameters:
n_neighborsint (default=5)

Default number of neighbors to query

batch_size: int (optional, default 2000000)

Maximum number of query rows processed at once. This parameter can greatly affect the throughput of the algorithm. The optimal setting of this value will vary for different layouts and index to query ratios, but it will require batch_size * n_features * 4 bytes of additional memory on each worker hosting index partitions.

verboseint or boolean, default=False

Sets logging level. It must be one of cuml.common.logger.level_*. See Verbosity Levels for more info.

Methods

fit(X, y)

Fit a multi-node multi-GPU K-Nearest Neighbors Regressor index

predict(X[, convert_dtype])

Predict outputs for a query from previously stored index and outputs.

score(X, y)

Provide score by comparing predictions and ground truth.

fit(X, y)[source]#

Fit a multi-node multi-GPU K-Nearest Neighbors Regressor index

Parameters:
Xarray-like (device or host) shape = (n_samples, n_features)

Index data. Acceptable formats: dask CuPy/NumPy/Numba Array

yarray-like (device or host) shape = (n_samples, n_features)

Index output data. Acceptable formats: dask CuPy/NumPy/Numba Array

Returns:
selfKNeighborsRegressor model
predict(X, convert_dtype=True)[source]#

Predict outputs for a query from previously stored index and outputs. The process is done in a multi-node multi-GPU fashion.

Parameters:
Xarray-like (device or host) shape = (n_samples, n_features)

Query data. Acceptable formats: dask cuDF, dask CuPy/NumPy/Numba Array

convert_dtypebool, optional (default = True)

When set to True, the predict method will automatically convert the data to the right formats.

Returns:
predictionsDask futures or Dask CuPy Arrays
score(X, y)[source]#

Provide score by comparing predictions and ground truth.

Parameters:
Xarray-like (device or host) shape = (n_samples, n_features)

Query test data. Acceptable formats: dask CuPy/NumPy/Numba Array

yarray-like (device or host) shape = (n_samples, n_features)

Outputs test data. Acceptable formats: dask CuPy/NumPy/Numba Array

Returns:
score