示例#1
0
    if labels_train[ii] == 1
]

#### initial visualization
plt.xlim(0.0, 1.0)
plt.ylim(0.0, 1.0)
plt.scatter(bumpy_fast, grade_fast, color="b", label="fast")
plt.scatter(grade_slow, bumpy_slow, color="r", label="slow")
plt.legend()
plt.xlabel("bumpiness")
plt.ylabel("grade")
plt.show()
################################################################################

### your code here!  name your classifier object clf if you want the
### visualization code (prettyPicture) to show you the decision boundary
from sklearn.neighbors import KDTree
kdt = KDTree(features_train, leaf_size=30, metric='euclidean')
t0 = time()
kdt.query(features_train, k=2, return_distance=False)
print("training time:", round(time() - t0, 3), "s")

t0 = time()
print(kdt.score(features_test))

try:
    #    prettyPicture(clf, features_test, labels_test)
    prettyPicture(kdt, features_test, labels_test)
except NameError:
    pass