我想在 python 中使用 svm 分类器找出错误率,我采用的方法是:
1-svm.predict(test_samples).mean()
但是,这种方法行不通。 sklearn 的评分函数也给出了平均准确度......但是,我不能使用它,因为我想完成交叉验证,然后找到错误率。请在 sklearn 中建议一个合适的函数来找出错误率。
最佳答案
假设您在向量 y_test
中有真实标签:
from sklearn.metrics import zero_one_score
y_pred = svm.predict(test_samples)
accuracy = zero_one_score(y_test, y_pred)
error_rate = 1 - accuracy
关于python - 使用 sklearn 找出错误率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10318884/