用法:
cuml.metrics.precision_recall_curve(y_true, probs_pred) → Tuple[cuml.common.array.CumlArray, cuml.common.array.CumlArray, cuml.common.array.CumlArray]
針對不同的概率閾值計算precision-recall 對
注意
此實現僅限於二進製分類任務。精度是比率
tp / (tp + fp)
,其中tp
是真陽性數,fp
是假陽性數。精度直觀地是分類器不將負樣本標記為正樣本的能力。召回率是
tp / (tp + fn)
的比率,其中tp
是真陽性數,fn
是假陰性數。召回率直觀地是分類器找到所有正樣本的能力。最後的精度和召回值分別為 1. 和 0.,並且沒有相應的閾值。這可確保圖形從 y 軸開始。閱讀 scikit-learn 的 User Guide 了解更多信息。
- y_true:數組,形狀 = [n_samples]
真正的二進製標簽,{0, 1}。
- probas_pred:數組,形狀 = [n_samples]
估計的概率或決策函數。
- precision:數組,形狀 = [n_thresholds + 1]
精度值,使得元素 i 是 score >= thresholds[i] 且最後一個元素為 1 的預測的精度。
- recall:數組,形狀 = [n_thresholds + 1]
減少召回值,使得元素 i 是分數 >= 閾值 [i] 的預測的召回,最後一個元素為 0。
- thresholds:數組,形狀 = [n_thresholds <= len(np.unique(probas_pred))]
增加用於計算精度和召回率的決策函數的閾值。
參數:
返回:
例子:
import numpy as np from cuml.metrics import precision_recall_curve y_true = np.array([0, 0, 1, 1]) y_scores = np.array([0.1, 0.4, 0.35, 0.8]) precision, recall, thresholds = precision_recall_curve( y_true, y_scores) print(precision) print(recall) print(thresholds)
輸出:
array([0.66666667, 0.5 , 1. , 1. ]) array([1. , 0.5, 0.5, 0. ]) array([0.35, 0.4 , 0.8 ])
相關用法
- Python cuml.metrics.pairwise_distances.pairwise_distances用法及代碼示例
- Python cuml.metrics.pairwise_distances.sparse_pairwise_distances用法及代碼示例
- Python cuml.metrics.roc_auc_score用法及代碼示例
- Python cuml.metrics.log_loss用法及代碼示例
- Python cuml.multiclass.OneVsRestClassifier用法及代碼示例
- Python cuml.model_selection.train_test_split用法及代碼示例
- Python cuml.multiclass.OneVsOneClassifier用法及代碼示例
- Python cuml.multiclass.MulticlassClassifier用法及代碼示例
- Python cuml.neighbors.KNeighborsClassifier用法及代碼示例
- Python cuml.ensemble.RandomForestRegressor用法及代碼示例
- Python cuml.svm.SVC用法及代碼示例
- Python cuml.svm.SVR用法及代碼示例
- Python cuml.Lasso用法及代碼示例
- Python cuml.tsa.ARIMA.predict用法及代碼示例
- Python cuml.preprocessing.LabelBinarizer用法及代碼示例
- Python cuml.random_projection.GaussianRandomProjection用法及代碼示例
- Python cuml.MBSGDRegressor用法及代碼示例
- Python cuml.experimental.preprocessing.PolynomialFeatures用法及代碼示例
- Python cuml.PCA用法及代碼示例
- Python cuml.feature_extraction.text.HashingVectorizer用法及代碼示例
注:本文由純淨天空篩選整理自rapids.ai大神的英文原創作品 cuml.metrics.precision_recall_curve。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。