roc_auc_score - Only one class present in y_true

前端 未结 5 1490
忘了有多久
忘了有多久 2020-12-16 14:28

I am doing a k-fold XV on an existing dataframe, and I need to get the AUC score. The problem is - sometimes the test data only contains 0s, and not 1s!

I tried usin

5条回答
  •  青春惊慌失措
    2020-12-16 15:00

    Simply modify the code with 0 to 1 make it work

    import numpy as np
    from sklearn.metrics import roc_auc_score
    y_true = np.array([0, 1, 0, 0])
    y_scores = np.array([1, 0, 0, 0])
    roc_auc_score(y_true, y_scores)
    

    I believe the error message has suggested that only one class in y_true (all zero), you need to give 2 classes in y_true.

提交回复
热议问题