Giter Site home page Giter Site logo

#使用python程序绘制二分类任务的ROC曲线,以及求AUC的值 from sklearn.metrics import roc_curve,auc import matplotlib.pyplot as plt

y_label = ([1, 1, 1, 2, 2, 2]) # 非二进制需要pos_label y_pre = ([0.3, 0.5, 0.9, 0.8, 0.4, 0.6]) #与y_label一一对应 fpr, tpr, thersholds = roc_curve(y_label, y_pre, pos_label=2) #thersholds可以将不同阈值进行降序排列

for i, value in enumerate(thersholds): print("%f %f %f" % (fpr[i], tpr[i], value)) roc_auc = auc(fpr,tpr)

plt.plot(fpr, tpr, 'b^--', label='ROC (area = {0:.2f})'.format(roc_auc), lw=1)
plt.xlim([0.0,1.0]) plt.ylim([0.0, 1.0]) plt.xlabel('False Positive Rate') plt.ylabel('True Positive Rate') # 可以使用中文,但需要导入一些库即字体 plt.title('ROC Curve') plt.legend(loc=0) plt.show()

Rao Shiyuan's Projects

web_demo icon web_demo

this is a front-end website of the project by vue

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.