[英]Having recall, F-score, precision 1 with KNN classifier
I'm running a python script that I've took from a website.我正在运行一个从网站上获取的 python 脚本。 It's a simple code that uses Iris dataset and performs a KNN classification on that dataset.
这是一个使用 Iris 数据集并对该数据集执行 KNN 分类的简单代码。 But when I run this script I keep getting all of measurement scores as 1.0 which is I believe a wrong result.
但是当我运行这个脚本时,我一直得到所有的测量分数为 1.0,我认为这是一个错误的结果。 Where did I make the mistake?
我在哪里犯了错误?
Classification part of the script:脚本的分类部分:
knn = KNeighborsClassifier(n_neighbors=5)
knn.fit(X_train, y_train)
y_pred = knn.predict(X_test)
print(confusion_matrix(y_test, y_pred))
print(classification_report(y_test, y_pred))
Try another dataset.尝试另一个数据集。 It will work.
它会起作用。 Maybe your algorithm works well that classify all the data correctly.
也许您的算法运行良好,可以正确分类所有数据。 I have run this kNN program and had such an issue but for another dataset, it shows the answer other than 1.
我已经运行了这个 kNN 程序并遇到了这样的问题,但是对于另一个数据集,它显示了 1 以外的答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.