NeighborsRegressor

Module for generic NeighborsRegressor.

class NeighborsRegressor[source]

Bases: Approximation

A generic superclass for wrappers of *NeighborsRegressor from sklearn.

This class provides a common interface for neighbor-based regression methods.

Parameters:

kwargs – Arguments passed to the internal instance of *NeighborsRegressor.

Example:
>>> import numpy as np
>>> from ezyrb import KNeighborsRegressor
>>> x = np.random.uniform(-1, 1, size=(20, 2))
>>> y = np.sin(x[:, 0]) + np.cos(x[:, 1])
>>> knn = KNeighborsRegressor(n_neighbors=5)
>>> knn.fit(x, y)
>>> y_pred = knn.predict(x[:5])
_abc_impl = <_abc._abc_data object>
fit(points, values)[source]

Construct the interpolator given points and values.

Parameters:
  • points (array_like) – the coordinates of the points.

  • values (array_like) – the values in the points.

predict(new_point)[source]

Evaluate interpolator at given new_points.

Parameters:

new_points (array_like) – the coordinates of the given points.

Returns:

the interpolated values.

Return type:

numpy.ndarray