У меня есть этот код:
print(X)
print(Y)
fig, axes = plt.subplots(1, 3, figsize=(15, 5))
for n_neighbors, ax in zip([1, 3], axes):
# the fit method returns the object self, so we can instantiate
# and fit in one line
clf = KNeighborsClassifier(n_neighbors=n_neighbors, weights='uniform').fit(X, Y)
mglearn.plots.plot_2d_separator(clf, X, fill=True, eps=0.5, ax=ax, alpha=.4)
mglearn.discrete_scatter(X[:, 0], X[:, 1], Y, ax=ax)
ax.set_title("{} neighbor(s)".format(n_neighbors))
ax.set_xlabel("feature 0")
ax.set_ylabel("feature 1")
axes[0].legend(loc=3)
Я попытался получить данные теста, и вывод неправильный (для k = 1).Зачем?Вот мой вывод: Вывод