注意:roc_curve() 这个函数
来源于:sklearn.metrics.roc_curve
roc_curve(y_true, y_score, pos_label=None, sample_weight=None, drop_intermediate=True)
注意它的参数:
Parameters:
y_true : array, shape = [n_samples]
True binary labels in range {0, 1} or {-1, 1}. If labels are not binary, pos_label should be explicitly given.
y_score : array, shape = [n_samples]
Target scores, can either be probability estimates of the positive class, confidence values, or non-thresholded measure of decisions (as returned by “decision_function” on some classifiers).
pos_label : int or str, default=None
Label considered as positive and others are considered negative.
...
注意第二个参数是:y_score,它可以是:对正例的概率估计值,置信度值,
决策值的非阈值测量(一些分类器中用decision_function来返回)
例如:
Model = classifier.fit(TrainX, Trainy)
1.
probas_ = Model.predict_proba(TestX)
#一些分类器直接predict_proba,返回概率值
predictions = Model.predict(TestX)
#predict返回预测值
fpr, tpr, thresholds = roc_curve(Testy,probas_[:,1],pos_label=1)
2.
probas_ = Model.decision_function(TestX)
#返回