Question 1: Short answer
mediumAI-checkedNearest Neighbors & Kernel Methodsfrom sklearn.neighbors import KNeighborsClassifier
X = [[0.0], [1.0], [4.0]]
y = [0, 0, 1]
for w in ["uniform", "distance"]:
knn = KNeighborsClassifier(n_neighbors=3, weights=w).fit(X, y)
print(w, knn.predict([[3.5]])[0])
The loop prints the class predicted for : with "uniform" it prints , and with
"distance" it prints .
Fill in every blank (hints in the boxes). Enter moves to the next blank.