【发布时间】:2020-01-24 20:40:56
【问题描述】:
问题是为什么我得到 0.00 的准确度
iris = pd.read_csv('iris.csv')
feature_cols = ['sepal_length', 'sepal_width', 'petal_length', 'petal_width']
X_train, X_test, y_train, y_test = train_test_split(iris.loc[:, iris.columns != 'species'],
iris['species'], test_size=0.30 , random_state=0)
k_means = KMeans(n_clusters=3)
k_means.fit(X_train)
score = metrics.accuracy_score(y_test,k_means.predict(X_test))
print('Accuracy:{0:f}'.format(score))
print(k_means.predict(X_test))
print(k_means.labels_[:])
print(y_test[:])
问题是我得到了 0.0 的准确度
Accuracy:0.000000
[0 0 1 2 1 2 1 0 0 0 2 0 0 0 0 1 0 0 1 1 0 0 1 1 0 1 1 0 0 1 2 0 1 0 2 0 1
0 0 0 2 1 2 1 1]
[0 2 2 0 2 0 2 0 0 0 0 0 0 2 2 0 1 0 0 0 0 0 2 1 1 2 0 1 1 2 1 0 0 1 0 2 0
1 2 2 2 2 1 1 2 2 1 2 1 0 2 1 1 2 1 1 1 0 2 2 1 1 1 0 0 1 1 0 1 2 0 2 0 1
0 1 2 1 1 2 1 2 0 0 0 2 2 0 2 1 0 2 0 1 0 0 0 0 1 1 1 2 0 2 1]
114 virginica
62 versicolor
33 setosa
.
.
.
【问题讨论】:
-
你没有发布问题
-
为什么我的准确率是 0.0
标签: python scikit-learn k-means