<jupyter_start><jupyter_text>Applying k-means on iris<jupyter_code>from sklearn import datasets
iris = datasets.load_iris()
x = iris.data
y = iris.target

k_means_iris = KMeans(n_clusters = 3)
k_means_iris.fit(x)
#k_means_iris.score(k_means_iris.labels_,y)
#l = k_means_iris.labels_.reshape(-1,1)
plt.scatter(x[:,0],x[:,1],c = k_means_iris.labels_)
from sklearn.metrics import accuracy_score

#accuracy_score(y,k_means_iris.labels_)
yy = []
pred = k_means_iris.labels_
for i in range(len(pred)):
    if pred[i] == 1:
        yy.append(0)
    elif pred[i] == 2:
        yy.append(1)
    elif pred[i] == 0:
        yy.append(2)

yy = np.array(yy)

accuracy_score(y,yy)<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup