scikit learn logo scikit learn: models

1 2 3 4 5 6 7 8 9 10
Notes

Note that both models are called with the same API.

from sklearn.neighbors import KNeighborsRegressor
from sklearn.linear_model import LinearRegression

from sklearn.datasets import load_boston
X, y = load_boston(return_X_y=True)

mod = LinearRegression()
mod.fit(X, y)
mod.predict(X)

mod = KNeighborsRegressor()
mod.fit(X, y)
mod.predict(X)