# KNeighborsRegressor

### *class* cuml.dask.neighbors.KNeighborsRegressor(, client=None, streams_per_handle=0, verbose=False, \*\*kwargs)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/dask/neighbors/kneighbors_regressor.py#L21)

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_neighbors**
  : 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.

  **verbose**
  : Sets logging level. It must be one of `cuml.common.logger.level_*`.
    See [Verbosity Levels](../../cuml/index.html.md#verbosity-levels) for more info.

### Methods

| [`fit`](#cuml.dask.neighbors.KNeighborsRegressor.fit)(X, y)   | Fit a multi-node multi-GPU K-Nearest Neighbors Regressor index        |
|--------------------------------------------------------------|-----------------------------------------------------------------------|
| [`predict`](#cuml.dask.neighbors.KNeighborsRegressor.predict)(X)  | Predict outputs for a query from previously stored index and outputs. |
| [`score`](#cuml.dask.neighbors.KNeighborsRegressor.score)(X, y) | Provide score by comparing predictions and ground truth.              |
<!-- !! processed by numpydoc !! -->

#### fit(X, y)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/dask/neighbors/kneighbors_regressor.py#L50)

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

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

  **y**
  : Index output data.
    Acceptable formats: dask CuPy/NumPy/Numba Array
* **Returns:**
  **self**

<!-- !! processed by numpydoc !! -->

#### get_combined_model()[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/dask/common/base.py#L57)

Return single-GPU model for serialization

* **Returns:**
  **model**
  : yet been trained.

<!-- !! processed by numpydoc !! -->

#### get_neighbors(n_neighbors)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/dask/neighbors/nearest_neighbors.py#L113)

Returns the default n_neighbors, initialized from the constructor,
if n_neighbors is None.

* **Parameters:**
  **n_neighbors**
  : Number of neighbors
* **Returns:**
  n_neighbors: int
  : Default n_neighbors if parameter n_neighbors is none

<!-- !! processed by numpydoc !! -->

#### kneighbors(X=None, n_neighbors=None, return_distance=True, \_return_futures=False)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/dask/neighbors/nearest_neighbors.py#L242)

Query the distributed nearest neighbors index

* **Parameters:**
  **X**
  : Vectors to query. If not provided, neighbors of each indexed point
    are returned.

  **n_neighbors**
  : Number of neighbors to query for each row in X. If not provided,
    the n_neighbors on the model are used.

  **return_distance**
  : If false, only indices are returned
* **Returns:**
  **ret**
  : First dask-cuDF DataFrame contains distances, second contains the
    indices.

<!-- !! processed by numpydoc !! -->

#### predict(X)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/dask/neighbors/kneighbors_regressor.py#L112)

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

* **Parameters:**
  **X**
  : Query data.
    Acceptable formats: dask cuDF, dask CuPy/NumPy/Numba Array
* **Returns:**
  **predictions**

<!-- !! processed by numpydoc !! -->

#### score(X, y)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/dask/neighbors/kneighbors_regressor.py#L218)

Provide score by comparing predictions and ground truth.

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

  **y**
  : Outputs test data.
    Acceptable formats: dask CuPy/NumPy/Numba Array
* **Returns:**
  score

<!-- !! processed by numpydoc !! -->
