天天看點

Python3 使用SVM--Lasso等,訓練模型,畫出auc曲線

注意: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)


probas_ = Model.predict_proba(TestX)
#一些分類器直接predict_proba,傳回機率值
predictions = Model.predict(TestX)
#predict傳回預測值

fpr, tpr, thresholds = roc_curve(Testy,probas_[:,],pos_label=)


probas_ = Model.decision_function(TestX)
#傳回