python - 评估指标的手动计算与 Sklearn 函数不匹配
问题描述
我想将精度和召回率的手动计算与 scikit-learn 函数进行比较。然而, recall_score()
scikit precision_score()
-learn 函数给了我不同的结果。不知道为什么!您能否给我一些建议,为什么我会得到不同的结果?谢谢!
我的混淆矩阵:
tp, fn, fp, tn = confusion_matrix(y_test, y_test_pred).ravel()
print('Outcome values : \n', tp, fn, fp, tn)
Outcome values :
3636933 34156 127 151
FDR=tp/(tp+fn) # TPR/Recall/Sensitivity
print('Recall: %.3f' % FDR)
Recall: 0.991
precision=tp/(tp + fp)
print('Precision: %.3f' % precision)
Precision: 1.000
precision = precision_score(y_test, y_test_pred)
print('Precision: %f' % precision)
recall = recall_score(y_test, y_test_pred)
print('Recall: %f' % recall)
Precision: 0.004401
Recall: 0.543165
解决方案
推荐阅读
- java - JDK 11;JAX-WS;未找到提供程序 com.sun.xml.internal.ws.spi.ProviderImpl
- java - 测试字符串是否与集合中的任何其他字符串不同
- android - 如何在 app/build.gradle 文件中获取当前选定的产品风格
- netsuite - NetSuite SS2.0 - 创建一个选中“addtimestamptourl”的文件
- java - 按升序对包含多个元素的数组进行排序
- c++ - log2 在位操作中的作用是什么?
- mysql - ubuntu子系统windows 10更改datadir后无法运行sql
- python-3.x - 从python中的.wav声音文件中获取numpy数组的方法
- c - 为自定义字符串格式化函数实现可变参数检查
- javascript - 使用 VS CODE 进行调试