text_plain_output_1.png
from sklearn.model_selection import GridSearchCV

from sklearn.neighbors import KNeighborsClassifier

params = {'n_neighbors': range(1, 30), 'metric': ['l1', 'l2']}

best_clf = GridSearchCV(estimator=KNeighborsClassifier(), param_grid=params)
best_clf.fit(X_train, y_train)
best_clf.score(X_test, y_test)

best_clf.best_params_