| |
- sega_learn.nearest_neighbors.base.KNeighborsBase(abc.ABC)
-
- KNeighborsRegressor
class KNeighborsRegressor(sega_learn.nearest_neighbors.base.KNeighborsBase) |
|
KNeighborsRegressor(n_neighbors=5, distance_metric='euclidean', one_hot_encode=False, fp_precision=<class 'numpy.float64'>, numba=False)
K-Nearest Neighbors classifier.
This class implements the k-nearest neighbors algorithm for regression. |
|
- Method resolution order:
- KNeighborsRegressor
- sega_learn.nearest_neighbors.base.KNeighborsBase
- abc.ABC
- builtins.object
Methods defined here:
- predict(self, X)
- Predict the class labels for the provided data.
Args:
X: array-like, shape (n_samples, n_features) - The input data for which to predict the class labels.
Returns:
predictions: array, shape (n_samples,) - The predicted class labels for the input data.
Data and other attributes defined here:
- __abstractmethods__ = frozenset()
Methods inherited from sega_learn.nearest_neighbors.base.KNeighborsBase:
- __init__(self, n_neighbors=5, distance_metric='euclidean', one_hot_encode=False, fp_precision=<class 'numpy.float64'>, numba=False)
- Initialize the KNeighborsBase class.
Args:
n_neighbors: int, default=5. The number of neighbors to use for the KNN algorithm.
distance_metric: str, default='euclidean'. The distance metric to use for calculating distances.
one_hot_encode: bool, default=False. Whether to apply one-hot encoding to the categorical columns.
fp_precision: data type, default=np.float64. The floating point precision to use for the calculations.
numba: bool, default=True. Whether to use numba for speeding up the calculations.
- fit(self, X, y)
- Fit the model using the training data.
Args:
X: array-like, shape (n_samples, n_features) - The training data.
y: array-like, shape (n_samples,) - The target values.
- get_distance_indices(self, X)
- Compute the distances and return the indices of the nearest points im the training data.
Args:
X: array-like, shape (n_samples, n_features) - The input data.
Returns:
indices: array, shape (n_samples, n_neighbors) - The indices of the nearest neighbors.
Data descriptors inherited from sega_learn.nearest_neighbors.base.KNeighborsBase:
- __dict__
- dictionary for instance variables
- __weakref__
- list of weak references to the object
| |