对于KNN模型,每个输出都是K的不同值。
我有10个功能和一个二进制目标(1或0)
我不明白为什么混淆矩阵中的实际值每次都会更改,难道它们不应该保持不变吗?
外采样数据是看不见的csv,外采样精度只是总行与正确行之间的百分比。
我是一个初学者,我很确定自己做错了我不明白的事情。您可以评论此输出吗?
KNN
Accuracy Test score: 0.5564304461942258
Accuracy Train score: 1.0
AUC Score: 0.5176288721089244
F1 Score: 0.380952380952381
Confusion Matrix: [[160 82]
[ 87 52]]
Outsample data accuracy: 54.93291239147593
Accuracy Test score: 0.6115485564304461
Accuracy Train score: 0.7753950338600452
AUC Score: 0.5181491170699803
F1 Score: 0.24489795918367346
Confusion Matrix: [[209 33]
[115 24]]
Outsample data accuracy: 62.667719021310184
Accuracy Test score: 0.5695538057742782
Accuracy Train score: 0.7866817155756207
AUC Score: 0.5248974374219633
F1 Score: 0.3787878787878788
Confusion Matrix: [[167 75]
[ 89 50]]
Outsample data accuracy: 56.43251775848461
Accuracy Test score: 0.6272965879265092
Accuracy Train score: 0.7347629796839729
AUC Score: 0.53973185088293
F1 Score: 0.297029702970297
Confusion Matrix: [[209 33]
[109 30]]
Outsample data accuracy: 60.615627466456196
Accuracy Test score: 0.5459317585301837
Accuracy Train score: 0.7460496613995485
AUC Score: 0.487930316903502
F1 Score: 0.30522088353413657
Confusion Matrix: [[170 72]
[101 38]]
Outsample data accuracy: 57.93212312549329
Accuracy Test score: 0.5826771653543307
Accuracy Train score: 0.7076749435665914
AUC Score: 0.49542184434270764
F1 Score: 0.2318840579710145
Confusion Matrix: [[198 44]
[115 24]]
Outsample data accuracy: 62.27308602999211
Accuracy Test score: 0.5406824146981627
Accuracy Train score: 0.7234762979683973
AUC Score: 0.4730810393007907
F1 Score: 0.2616033755274262
Confusion Matrix: [[175 67]
[108 31]]
Outsample data accuracy: 58.40568271507498
Accuracy Test score: 0.5853018372703412
Accuracy Train score: 0.698645598194131
AUC Score: 0.4883019204471134
F1 Score: 0.18556701030927839
Confusion Matrix: [[205 37]
[121 18]]
Outsample data accuracy: 63.22020520915549
Accuracy Test score: 0.5669291338582677
Accuracy Train score: 0.7133182844243793
AUC Score: 0.4860871633271895
F1 Score: 0.23963133640552997
Confusion Matrix: [[190 52]
[113 26]]
Outsample data accuracy: 60.615627466456196
最佳答案
当您在KNN中更改k时,您正在使用不同数量的邻居来预测您的输出类别。这意味着,如果您使用更多邻居来预测其类别,则对给定“样本外”点的预测可能会更改。
混淆矩阵只是给您分解您的表现(模型被“混淆”的位置和方向)。如果您看到准确度百分比变化,则您的混淆矩阵可能也会更改。
confusion_matrix [0] [0] =您预测为1的事物的数量实际上是1
confusion_matrix [0] [1] =您预测为1的事物的数量实际上为0
confusion_matrix [1] [0] =您预测为0的事物的数量实际上是1
confusion_matrix [1] [1] =您预测为0的事物的数量实际上为0
参见:https://en.wikipedia.org/wiki/Confusion_matrix
关于python - 混淆矩阵实际值每K轮更改一次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59685347/