Beispiel #1
0
for i in range(X.shape[0]):
    plt.scatter(X[i, 0],
                X[i, 1],
                marker=marker_shapes[y[i]],
                s=75,
                edgecolors='black',
                facecolors='none')
plt.scatter(test_datapoint[0],
            test_datapoint[1],
            marker='x',
            linewidth=6,
            s=200,
            facecolors='black')
plt.show()

_, indices = classifier.kneighbors([test_datapoint])
indices = indices.astype(np.int)[0]

plt.figure()
plt.title('K Nearest Neighbors')

for i in indices:
    plt.scatter(X[i, 0],
                X[i, 1],
                marker=marker_shapes[y[i]],
                linewidth=3,
                s=100,
                facecolors='black')
plt.scatter(test_datapoint[0],
            test_datapoint[1],
            marker='x',