当前位置:网站首页>Draw multiple ROC curves on a graph
Draw multiple ROC curves on a graph
2022-06-29 06:51:00 【weixin_ forty-four million three hundred and twenty-three thous】
In order to show the experimental effect ,ROC Curves can also be more intuitive and beautiful . So I want to draw ROC curve . Here are two ways :1) Just draw one ROC curve ,2) Multiple ROC The curve is shown on a graph .
notes : I already have y-pred, So just use it directly , There is no need to calculate y_pred.
1 Draw a picture ROC curve
from sklearn.metrics import roc_curve, auc
import matplotlib.pyplot as plt
# Set up here lable It's really in there 1.
fpr, tpr, thersholds = roc_curve(y_label, y_pred, pos_label=1)
for i, value in enumerate(thersholds):
print("%f %f %f" % (fpr[i], tpr[i], value))
roc_auc = auc(fpr, tpr)
plt.figure(figsize=(10, 10), dpi=100)
plt.plot(fpr, tpr, 'k--', label='ROC (area = {0:.2f})'.format(roc_auc), lw=2)
plt.xlim([-0.05, 1.05]) # Set up x、y The upper and lower limits of the axis , So as not to coincide with the edge , Better observe the whole of the image
plt.ylim([-0.05, 1.05])
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive Rate') # Can use Chinese , But you need to import some libraries that are Fonts
plt.title('ROC Curve')
plt.legend(loc="lower right")
plt.show()

2 Will be multiple ROC The curve is shown on a graph
Define drawing function
def multi_models_roc(names, sampling_methods, colors, y_label, save=True, dpin=100):
"""
Combine multiple machine models roc Graph output to a graph
Args:
names: list, Names of multiple models
sampling_methods: list, Instantiated objects of multiple models
save: Choose whether to save the results ( The default is png Format )
Returns:
Return the image object plt
"""
plt.figure(figsize=(10, 10), dpi=dpin)
for (name, y_pred, colorname) in zip(names, sampling_methods, colors):
fpr, tpr, thresholds = roc_curve(y_label, y_pred, pos_label=1)
plt.plot(fpr, tpr, lw=5, label='{} (AUC={:.3f})'.format(name, auc(fpr, tpr)),color = colorname)
plt.plot([0, 1], [0, 1], '--', lw=5, color = 'grey')
plt.axis('square')
plt.xlim([0, 1])
plt.ylim([0, 1])
plt.xlabel('False Positive Rate',fontsize=20)
plt.ylabel('True Positive Rate',fontsize=20)
plt.title('ROC Curve',fontsize=25)
plt.legend(loc='lower right',fontsize=20)
if save:
plt.savefig('multi_models_roc.png')
return plt
call multi_models_roc
names = ['UTrans_Mem',
'Unet_Mem',
]
# sampling_methods Li Wei y_pred.
sampling_methods = [preds_UT_mem,
preds_U_mem,
]
#color:'crimson','orange','gold','mediumseagreen','steelblue', 'mediumpurple'
colors = ['crimson',
'orange',
]
#ROC curves
train_roc_graph = multi_models_roc(names, sampling_methods, colors, label[0], save = True)
train_roc_graph.savefig('ROC_Train_all.png')

The following links are more detailed .
边栏推荐
- [deep learning] - maze task learning I (to realize the random movement of agents)
- Draw smooth curves - methods needed - drawing smooth curves - methods needed
- What are the uses of wireless pressure collectors?
- JDBC连接数据库,socket发送客户端。
- Convert data frame with date column to timeseries
- The echares map is implemented separately by provinces, and the tooltip user-defined prompt box, scattered annotation and scattered illumination are explained in detail
- mongostat性能分析
- Antlr4 recognizes the format of escape string containing quotation marks
- It is the only one in China that Alibaba cloud container service has entered the Forrester leader quadrant
- 配置Flutter开发环境
猜你喜欢

百度小程序自动提交搜索

关于DDNS

Illustrate plug-in -- AI plug-in development -- creative plug-in -- astute graphics -- length and angle measurement function

QT writing map comprehensive application 58 compatible with multi browser kernel

作为一名合格的网工,你必须掌握的 DHCP Snooping 知识!

RPC和RMI

Fault: NetBt log for id4321

Chapter IV introduction to FPGA development platform

Some high-level usage of localstorage

Teach you how to develop your own NPM package (publish to the NPM official website)
随机推荐
2022.02.15 - 240. Lucky number in matrix
二叉树的迭代法前序遍历的两种方法
Games101 Lecture 10 geometry 1 Notes
package.json的所有配置项及其用法,你都熟悉么
Labor skills courses integrated into steam Education
WDCP访问不存在的路径全部跳转到首页不返回404的解决办法
力扣每日一题-第30天-1523.位1的个数
Venn diagram proportional and color shading with semi transparency
json tobean
VerilogA - dynamic comparator
[deep learning] - maze task learning I (to realize the random movement of agents)
Meta metauniverse female safety problems occur frequently. How to solve the relevant problems in the metauniverse?
Honeypot based on MySQL load data local INFILE
After “Go to Definition”, is there a command to return to where you came from?
How to combine two byte arrays [repeat] - how to combine two byte arrays [duplicate]
Introduction to Ceres Quartet
Yyds dry goods inventory meituan's two-sided experience, and finally there was a surprise?
Ribbon service invocation and load balancing
QT (x): innosetup for software packaging
Hyperledger Fabric 2. X custom smart contract