简体   繁体   English

使用 KNN 分类器具有召回率、F 分数、精度 1

[英]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))

You can reach the full script from here你可以从这里获得完整的脚本

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.

相关问题 具有F分数,精度或召回力的LIBSVM评估 - LIBSVM Evaluation with F-Score, Precision or Recall 在一次传递中计算精度,召回和F分数 - 蟒蛇 - Calculating Precision, Recall and F-score in one pass - python 如何计算此模型的召回率、准确率和 f 分数? - how can I calculate recall, precision and f-score for this model? 如何使用python计算Precision、Recall和F-score? - How to calculate Precision, Recall and F-score using python? 精度,召回率,F分数要求相等的输入 - Precision, Recall, F-score requiring equal inputs 如何在python中使用libSVM计算精度,召回率和F-score - How to calculate precision, recall and F-score with libSVM in python 使用SVM作为图像分类器时,精度/ F分数是否可以达到10%? - Is a precision/F-score of 10% to be expected on using SVM as image classifier? 确定 H2O 随机森林模型的准确度、精确度、召回率和 F-Score - Determining the accuracy, precision, recall and F-Score of an H2O Random Forest Model 使用交叉验证计算 4 个模型的召回率和精度以及 F 分数时出错? - Error when computing recall and precision and F-score of 4 models using cross validation? 基于示例的 f-score 小于 Sklearn 中的精度和召回率 - example-based f-score is smaller than precision and recall in Sklearn
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM