KNNRegressor

regressors.KNNRegressor(self, k=5)

A class used to represent a K-Nearest Neighbors Regressor.

Parameters

Name Type Description Default
k int The number of nearest neighbors to consider for regression. 5

Methods

Name Description
fit Fit the model using X as input data and y as target values.
predict Predict the target for the provided data.

fit

regressors.KNNRegressor.fit(X, y)

Fit the model using X as input data and y as target values.

Parameters

Name Type Description Default
X ndarray The training data, which is a 2D array of shape (n_samples, 1) where each row is a sample and each column is a feature. required
y ndarray The target values, which is a 1D array of shape (n_samples, ). required

predict

regressors.KNNRegressor.predict(X_new)

Predict the target for the provided data.

Parameters

Name Type Description Default
X_new ndarray Input data, a 2D array of shape (n_samples, 1), with which to make predictions. required

Returns

Type Description
ndarray The target values, which is a 1D array of shape (n_samples, ).