text_plain_output_1.png
from sklearn import neighbors, datasets

from sklearn.datasets import load_iris

import matplotlib.pyplot as plt

from sklearn.datasets import load_iris
data = load_iris()
n_samples, n_features = data.data.shape

x_index = 1
y_index = 2
formatter = plt.FuncFormatter(lambda i, *args: data.target_names[int(i)])
plt.colorbar(ticks=[0, 1, 2], format=formatter)
plt.clim(-0.5, 2.5)

from sklearn import neighbors, datasets
data = datasets.load_iris()
X, y = (data.data, data.target)
clf = neighbors.KNeighborsClassifier(n_neighbors=5, weights='uniform')
clf.fit(X, y)
X_test = [3, 4, 2, 5]
y_pred = clf.predict([X_test])
print(y_pred)
print(data.target_names[y_pred])
print(data.target_names)
print(clf.predict_proba([X_test]))