计算AUC和绘制ROC曲线
来源:互联网 发布:java在线笔试题 编辑:程序博客网 时间:2024/05/20 18:52
import csvimport numpy import matplotlib.pyplot as pltfrom sklearn.svm import SVCfrom sklearn.metrics import roc_auc_score,roc_curveimport pandas as pd
with open('F:/1.csv', 'r') as Data: read1 = csv.reader(Data) read1= numpy.array(list(read1), dtype='float64') CreditSocringData.close()X=read1[0:read1.shape[0],0:read1.shape[1]-1] Y=read1[0:read1.shape[0],read1.shape[1]-1] X_train,X_test,y_train,y_test=train_test_split(X,Y,test_size = 0.1, random_state=0)
clf= SVC(kernel='rbf',probability=True) clf.fit(X_train, y_train)y_true, y_predict = y_test, clf.predict(X_test)
y_pred_pro = clf.predict_proba(X_test) y_scores = pd.DataFrame(y_pred_pro,columns=clf.classes_.tolist())[1].values auc_value = roc_auc_score(y_ture,y_scores)fpr, tpr, thresholds = roc_curve(y_ture,y_scores,pos_label=1.0) plt.figure(figsize=(6,4)) plt.plot(fpr,tpr,color='blue',linewidth=2,label='AUC (area:%0.4f)'%auc_value) plt.plot([0, 1], [0, 1], color='black',linewidth=2, linestyle='--') 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') plt.legend(loc="lower right") plt.show()
阅读全文
0 0
- 计算AUC和绘制ROC曲线
- 人脸认证-ROC曲线绘制计算AUC和ACC
- ROC曲线绘制及AUC计算
- 广告计算中的AUC和ROC曲线
- ROC曲线和AUC面积计算 matlab
- 广告计算中的AUC和ROC曲线
- ROC曲线和AUC
- py2.7 : 《机器学习实战》 Adaboost 2.24号:ROC曲线的绘制和AUC计算函数
- ROC曲线与AUC计算
- ROC曲线与AUC计算
- ROC曲线及AUC计算
- 利用Python画ROC曲线和AUC值计算
- ROC曲线和EER/AUC的计算方式
- ROC曲线,AUC,
- ROC曲线与AUC
- ROC曲线与AUC
- ROC曲线与AUC
- ROC与AUC曲线
- Fast kill big data
- Linux服务器实现定时自动备份Mysql数据库
- 解决运行Java项目出现错误 error:java: 无效的源发行版: 1.8
- REE和TEE的schedule
- C++基于TCP/IP简单的客户端、服务器通信程序实例
- 计算AUC和绘制ROC曲线
- kafka的高可用和一致性探究
- Latex参考文献字体样式修改
- delete from和truncate table的区别
- C++ boost thread组件, 编译
- poj1157LITTLE SHOP OF FLOWERS
- Fliptile POJ
- 解决Android SDK Manager无法加载可更新包问题
- Ubuntu下搭建smaba