[英]Using Classification_Report function in Sklearn
所以我理解這個函數的工作原理是它將一個表分成兩個,然后比較這些值以確定預測率
可以說我有一張桌子:
Column1 Column2 Column3 Column4 Column5
3 2 2 43 0
1 2 2 23 1
5 5 2 56 1
4 3 2 13 0
6 1 2 11 1
"Column 5" is label 0 or 1
我知道前3行是100%正確的,因為我手動為其分配標簽,但第4行和第5行使用隨機森林分類器進行標記。 我想看看預測率是多少
我想使用classification_report(y_true,y_pred,target_names = target_names),我的“y_true”,“y_pred”會是什么? 我假設target_names = 0,1
y_true是樣本的真實標簽,y_pred是我的模型的預測。 target_name允許您將自定義名稱分配給類標簽
classification_report重新生成模型的精度,召回率,f1分數和支持度。
sklearn https://scikit-learn.org/stable/modules/genic/sklearn.metrics.classification_report.html中顯示的示例
from sklearn.metrics import classification_report
y_true = [0, 1, 2, 2, 2]
y_pred = [0, 0, 2, 2, 1]
print(classification_report(y_true, y_pred, target_names=target_names))
例如,0級的精度為True Positive / True positive + False Positive,即1/2 = 0.5
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.