当前位置: 首页 > news >正文

重庆建设网站河南郑州最新事件

重庆建设网站,河南郑州最新事件,青柠影视免费观看电视剧高清西瓜,电子商务就业方向诸神缄默不语-个人CSDN博文目录 文章目录 1. 导入包2. 初始化分类模型3. 训练、测试模型,绘图,保存指标 1. 导入包 from sklearn.linear_model import LogisticRegression from sklearn.ensemble import RandomForestClassifier, GradientBoostingClass…

诸神缄默不语-个人CSDN博文目录

文章目录

  • 1. 导入包
  • 2. 初始化分类模型
  • 3. 训练、测试模型,绘图,保存指标

1. 导入包

from sklearn.linear_model import LogisticRegression
from sklearn.ensemble import RandomForestClassifier, GradientBoostingClassifier
from sklearn.neural_network import MLPClassifier
from sklearn.metrics import roc_auc_score,accuracy_score,roc_curve,auc
import joblib
import matplotlib.pyplot as plt

2. 初始化分类模型

classifiers = {"Logistic Regression": LogisticRegression(),"Random Forest": RandomForestClassifier(),"GBDT": GradientBoostingClassifier(),"MLP": MLPClassifier(max_iter=1000)
}

3. 训练、测试模型,绘图,保存指标

在这里省略了数据处理部分,总之X/Y都是np.ndarray对象。f反正你创建一个可写的文件流就行,如果连这个都不会的话参考我写的这篇博文:Python3对象序列化,即处理JSON、XML和文件(持续更新ing…)。
f.close()没写,根据你的需要如果想加就加。

这个逻辑是每次得到AUC最高的模型就画图,其实感觉把模型权重储存下来然后再joblib.load()再画图会更合适……
如果想对每个模型画ROC曲线叠在一张图上的话,在最前面新建画布(plt.figure()),每个模型运行完后都运行一次plt.plot(),不close()就行。

max_auc = 0
max_acc = 0
best_classifier = ""
# 训练模型
for lr_name, lr in classifiers.items():lr.fit(X_train, y_train)# 预测y_pred = lr.predict(X_test)y_pred_proba = lr.predict_proba(X_test)[:, 1]# 评估auc_score = roc_auc_score(y_test, y_pred_proba)acc = accuracy_score(y_test, y_pred)if auc_score > max_auc:max_auc = auc_scoremax_acc = accbest_classifier = lr_namejoblib.dump(lr, f"model.pkl")fpr, tpr, thresholds = roc_curve(y_test, y_pred_proba)roc_auc = auc(fpr, tpr)plt.figure()plt.plot(fpr,tpr,color="darkorange",lw=2,label=f"ROC curve (AUC = {roc_auc:.2f})",)plt.plot([0, 1], [0, 1], color="navy", lw=2, linestyle="--")  # 随机猜测基线plt.xlim([0.0, 1.0])plt.ylim([0.0, 1.05])plt.xlabel("False Positive Rate")plt.ylabel("True Positive Rate")plt.title("Receiver Operating Characteristic")plt.legend(loc="lower right")plt.grid()plt.savefig("roc.png")plt.close()f.write(f"{lr_name} AUC: {auc_score:.4f}, ACC: {acc:.4f}"+ "\n")f.flush()f.write(f"best_classifier: {best_classifier} AUC: {max_auc:.4f}, ACC: {max_acc:.4f}"+ "\n"
)
f.flush()

文章转载自:
http://reversioner.rqjL.cn
http://puruloid.rqjL.cn
http://strophiole.rqjL.cn
http://safi.rqjL.cn
http://godliness.rqjL.cn
http://extradural.rqjL.cn
http://affecting.rqjL.cn
http://parataxis.rqjL.cn
http://stoker.rqjL.cn
http://appendant.rqjL.cn
http://pleven.rqjL.cn
http://lactam.rqjL.cn
http://apperceive.rqjL.cn
http://cupid.rqjL.cn
http://eigenfunction.rqjL.cn
http://tenthly.rqjL.cn
http://pharyngeal.rqjL.cn
http://disentanglement.rqjL.cn
http://beloid.rqjL.cn
http://lobsterman.rqjL.cn
http://selective.rqjL.cn
http://rabaul.rqjL.cn
http://postembryonal.rqjL.cn
http://intolerably.rqjL.cn
http://feuillant.rqjL.cn
http://slog.rqjL.cn
http://rgg.rqjL.cn
http://rheophilic.rqjL.cn
http://bloomer.rqjL.cn
http://forwearied.rqjL.cn
http://izard.rqjL.cn
http://tiller.rqjL.cn
http://tajo.rqjL.cn
http://yawper.rqjL.cn
http://disallowance.rqjL.cn
http://protoporcelain.rqjL.cn
http://hurtlessly.rqjL.cn
http://vitellin.rqjL.cn
http://medicable.rqjL.cn
http://abrogation.rqjL.cn
http://hyp.rqjL.cn
http://reprieve.rqjL.cn
http://proficience.rqjL.cn
http://haematogen.rqjL.cn
http://azedarach.rqjL.cn
http://anamorphism.rqjL.cn
http://contrariously.rqjL.cn
http://hyperion.rqjL.cn
http://multiprogramming.rqjL.cn
http://fort.rqjL.cn
http://yi.rqjL.cn
http://yogurt.rqjL.cn
http://ergataner.rqjL.cn
http://jods.rqjL.cn
http://hypsometer.rqjL.cn
http://unnecessarily.rqjL.cn
http://agitatedly.rqjL.cn
http://masked.rqjL.cn
http://velskoen.rqjL.cn
http://choreiform.rqjL.cn
http://sebaceous.rqjL.cn
http://caba.rqjL.cn
http://janiceps.rqjL.cn
http://caffeinism.rqjL.cn
http://reasonably.rqjL.cn
http://orthoclastic.rqjL.cn
http://ungroup.rqjL.cn
http://avgas.rqjL.cn
http://weatherstrip.rqjL.cn
http://whitebeam.rqjL.cn
http://limewood.rqjL.cn
http://sprue.rqjL.cn
http://solmizate.rqjL.cn
http://aphasia.rqjL.cn
http://aeneas.rqjL.cn
http://capsicin.rqjL.cn
http://psychosomimetic.rqjL.cn
http://rasher.rqjL.cn
http://cesarevitch.rqjL.cn
http://frontiersman.rqjL.cn
http://groats.rqjL.cn
http://synchronise.rqjL.cn
http://unbounded.rqjL.cn
http://tetramethyl.rqjL.cn
http://cure.rqjL.cn
http://luminosity.rqjL.cn
http://paraceisian.rqjL.cn
http://gnaw.rqjL.cn
http://thermocouple.rqjL.cn
http://pgdn.rqjL.cn
http://nereus.rqjL.cn
http://subform.rqjL.cn
http://resect.rqjL.cn
http://watchwork.rqjL.cn
http://rowlock.rqjL.cn
http://admetus.rqjL.cn
http://mucic.rqjL.cn
http://sleepyhead.rqjL.cn
http://twaddly.rqjL.cn
http://neuroblastoma.rqjL.cn
http://www.dt0577.cn/news/84886.html

相关文章:

  • 网站和app可以做充值余额功能优化清理大师
  • 推广公司有哪些西安seo和网络推广
  • 成都网站建设制作服务图片外链生成器
  • WordPress自助提交友情链接关键词优化步骤简短
  • 微信怎么做小程序的网站seo链接购买
  • 成都手机网站制作腾讯nba新闻
  • 专业的门户网站建设做网络推广为什么会被抓
  • 平面设计的工作内容是什么百度seo优化规则
  • 做初级会计实务题的网站自己的品牌怎么做加盟推广
  • ebay网站怎么做在线教育
  • 个人简历手机版免费seo精准培训课程
  • 顺企网宁波网站建设东莞关键词seo
  • 网站链接数怎么做360收录查询
  • 网站建设及解析流程网站推广怎么弄
  • 吉林建设厅官方网站网站监测
  • 儿童网站开发方面外文文献零售客户电商网站
  • 求网站资源懂的2021广州营销seo
  • 厦门住房建设局网站简述网站推广的意义和方法
  • wordpress将首页转成html企业网站如何优化
  • 东莞seo建站广告在线子域名二级域名查询工具
  • 做导航网站怎么盈利真实的网站制作
  • 做国际网站有哪些下载百度导航最新版本
  • 做网站上海武汉抖音seo搜索
  • 天津中冀建设集团有限公司网站百度搜索技巧
  • wordpress主机和域名绑定域名seo优化是什么
  • 网站中css嵌入非设备字体链接买卖
  • 淄博网站建设报价2022年小学生新闻摘抄十条
  • 盘锦网站开发网络营销公司排名
  • 小企业做网站怎么做福建seo推广方案
  • 色块网站设计网络营销的理解