logo

... scikit learn: search



Notes

We're only running a very basic variant of gridsearch with this code;

from sklearn.datasets import load_boston
from sklearn.neighbors import KNeighborsRegressor
from sklearn.preprocessing import StandardScaler
from sklearn.pipeline import Pipeline
from sklearn.model_selection import GridSearchCV
import pandas as pd

mod = GridSearchCV(estimator=pipe,
                   param_grid={
                     'model__n_neighbors': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
                   },
                   cv=3)
mod.fit(X, y);

Note that we can inspect the results of the grid via this command;

pd.DataFrame(mod.cv_results_)

If you're interested in more depth, feel free to check our this series of videos on metrics. Only start watching that after watching this full series though. The most important point of this series is made in the next videos.

Feedback? See an issue? Something unclear? Feel free to mention it here.



If you want to be kept up to date, consider signing up for the newsletter.