from sklearn.metrics import roc_curve, auc
import matplotlib as mpl  
import matplotlib.pyplot as plt
def plot_roc(labels, predict_prob):
    false_positive_rate,true_positive_rate,thresholds=roc_curve(labels, predict_prob)
    roc_auc=auc(false_positive_rate, true_positive_rate)
    plt.title('ROC')
    plt.plot(false_positive_rate, true_positive_rate,'b',label='AUC = %0.4f'% roc_auc)
    plt.legend(loc='lower right')
    plt.plot([0,1],[0,1],'r--')
    plt.ylabel('TPR')
    plt.xlabel('FPR')
    plt.show()

 

相关文章:

  • 2022-01-01
  • 2022-01-07
  • 2021-07-05
  • 2021-12-25
  • 2022-12-23
  • 2021-06-17
猜你喜欢
  • 2022-01-10
  • 2022-12-23
  • 2023-03-09
相关资源
相似解决方案