text_plain_output_1.png
from sklearn.inspection import DecisionBoundaryDisplay

from sklearn.neighbors import KNeighborsClassifier

clf = KNeighborsClassifier()
clf.fit(X_train, y_train)
clf.score(X_test, y_test)

from sklearn.inspection import DecisionBoundaryDisplay
disp = DecisionBoundaryDisplay.from_estimator(clf, X_test, response_method='predict', alpha=0.7)
disp.ax_.scatter(X_test[:, 0], X_test[:, 1], c=y_test, edgecolor='yellow')