糖药病数据集分类

背景 (Background)

Data science should be an enjoyable process focused on delivering insights and real benefits. However, that enjoyment can sometimes get lost in tools and processes. Nowadays it is important for an applied data scientist to be comfortable using tools and software for data/code versioning, reproducible model development, experiment tracking, and model inspection — to name a few!

数据科学应该是一个令人愉悦的过程,专注于提供见解和实际收益。 但是,这种享受有时会在工具和过程中迷失。 如今,重要的是,对于应用数据科学家来说,使用工具和软件进行数据/代码版本控制,可重现的模型开发,实验跟踪和模型检查非常重要!

The purpose of this article is to briefly touch upon reproducible model development and experiment tracking through a worked example for tuning a Random Forest classifier using Optuna and mlflow.

本文的目的是通过一个使用Optuna和mlflow调整随机森林分类器的实例简要讨论可再现模型的开发和实验跟踪。

心脏病数据和预处理 (The heart disease data and preprocessing)

This example uses the heart disease data available in the UCI ML archive. In previous work I describe some processing done to create a semi-cleaned dataset: developing a model for heart disease prediction using pycaret. In the .csv file provided for this short worked example, I have additionally converted any categorical features with two values into a single binary feature where for feature_name_x the _x suffix indicates the level represented by a value of 1. The target to predict is heart disease (hd_yes) and we want to tune a Random Forest classifier to do so.

本示例使用UCI ML存档中可用的心脏病数据。 在之前的工作中,我描述了创建半清洁数据集的一些处理过程: 使用pycaret开发用于心脏病预测的模型 。 在为该简短示例提供的.csv文件中,我另外将具有两个值的所有分类特征转换为单个二进制特征,其中对于feature_name_x_x后缀表示值1表示的水平。要预测的目标是心脏病( hd_yes ),我们想调整随机森林分类器。

After loading the data and creating the feature matrix and target vector, I created a preprocessing pipeline. For numeric features missing values were imputed using the median and then scaled. For binary features missing values were imputed using the mode. For a three-level categorical feature chest pain, missing values were treated as a separate category and leave-one-out target encoding applied. Finally, these processing steps were wrapped up into a single processing pipeline.

加载数据并创建特征矩阵和目标矢量后,我创建了预处理管道。 对于数字特征,使用中位数估算缺失值,然后进行缩放。 对于二进制特征,使用该模式估算缺失值。 对于三级分类的特征性胸痛,缺失值被视为一个单独的类别,并应用了遗忘的目标编码 。 最后,这些处理步骤被包装到单个处理管道中。

使用Optuna和mlflow (Using Optuna and mlflow)

With our feature matrix, target vector and preprocessing pipeline ready to go, we can now tune a Random Forest classifier to predict heart disease. Note for the purpose of this demonstration I am going to forgo the use of a hold-out test set. To do the hyper-parameter optimization (model development) we will use Optuna and for experiment tracking one of its newer features: mlflow integration (see: mlflow callback in Optuna and mlflow tracking).

利用我们的特征矩阵,目标向量 并准备好进行预处理,我们现在可以调整“随机森林”分类器来预测心脏病。 请注意,出于演示目的,我将放弃使用保持测试集。 为了进行超参数优化(模型开发),我们将使用Optuna并进行实验跟踪,以实现其较新的功能之一 :mlflow集成(请参阅: Optuna中的mlflow回调和mlflow跟踪 )。

First, we begin by defining the objective function to optimize with Optuna (Figure 1), which has three main components:

首先,我们首先定义目标函数以使用Optuna进行优化( 图1 ),它具有三个主要组件:

  1. Defining the space of hyper-parameters and values to optimize: in our case we focus on six Random Forest hyper-parameters (n_estimators, max_depth, max_features, bootstrap, min_samples_split, min_samples_split)

    定义要优化的超参数和值的空间 :在本例中,我们集中于六个随机森林超参数(n_estimators,max_depth,max_features,bootstrap,min_samples_split,min_samples_split)

  2. The Machine Learning pipeline: we have a preprocessing pipeline plus a Random Forest classifier

    机器学习管道 :我们有一个预处理管道以及一个随机森林分类器

  3. The calculation of the metric to optimize: we use the 5-fold CV average ROC AUC

    优化指标的计算 :我们使用5倍CV平均ROC AUC

Figure 1. The Optuna objective function图1. Optuna目标函数

Next, we define a callback to mlflow, one of the new (and experimental!) features in Optuna 2.0 in order to track our classifier hyper-parameter tuning (Figure 2).

接下来,我们定义对mlflow的回调,这是Optuna 2.0中的新功能(也是实验性功能!)之一,以便跟踪分类器的超参数调整( 图2 )。

Figure 2. Setting the mlflow callback to track an Optuna study图2.设置mlflow回调以跟踪Optuna研究

Then we instantiate the Optuna study object to maximize our chosen metric (ROC AUC) (Figure 3). We also apply Hyperband pruning, which helps find optimums in shorter times by stopping unpromising trials early. Note that this is typically of more benefit for more intensive and difficult optimization such as in deep learning.

然后,我们实例化Optuna研究对象以最大化我们选择的指标(ROC AUC)( 图3 )。 我们还应用了Hyperband修剪 ,可通过尽早停止毫无希望的试验来帮助您在更短的时间内找到最佳选择。 请注意,这通常对于深度学习等更深入,更困难的优化更有利。

Figure 3. Creating an Optuna study图3 。 创建一个Optuna研究

Finally, we run the hyper-parameter tuning using 200 trials (Figure 4). It may take a couple of minutes to run.

最后,我们使用200次试验运行超参数调整( 图4 )。 运行可能需要几分钟。

Figure 4. Running the hyper-parameter optimization using Optuna图4.使用Optuna运行超参数优化

The mlflow logged experiment including assessed hyper-parameter configurations for the Random Forest classifier (Optuna study/trials), are stored in a folder called mlruns. To view these results using the mlflow user interface, do the following:

mlflow记录的实验(包括为随机森林分类器评估的超参数配置(Optuna研究/试验))存储在名为mlruns的文件夹中。 要使用mlflow用户界面查看这些结果,请执行以下操作:

  1. Open a shell (for example a Windows PowerShell) in the directory containing the mlruns folder在包含mlruns文件夹的目录中打开外壳程序(例如Windows PowerShell)
  2. Activate the virtual environment used for this notebook, i.e., conda activate optuna_env

    激活用于此笔记本的虚拟环境,即conda activate optuna_env

  3. Run mlflow ui

    运行mlflow ui

  4. Navigate to the localhost address provided, something like: http://kubernetes.docker.internal:5000/

    导航到提供的localhost地址,例如: http://kubernetes.docker.internal:5000/

You should see Figure 5, and you can sift through the experiment trials. I deselected the user, source and version columns, as well as the tags section to simplify the view. I also sorted the results by ROC AUC. The top hyper-parameter configurations provided a ROC AUC of 0.917, where max_depth was in the range 14 to 16, max_features was 4, min_samples_leaf was 0.1, min_samples_split was 0.2, and n_estimators was 340 (note these results may differ slightly for you if you re-run the notebook).

您应该看到图5 ,然后可以筛选实验。 我取消选择了用户,源和版本列以及标签部分,以简化视图。 我还按ROC AUC对结果进行了排序。 顶级超参数配置的ROC AUC为0.917,其中max_depth在14到16之间,max_features是4,min_samples_leaf是0.1,min_samples_split是0.2,n_estimators是340(请注意,如果您使用重新运行笔记本)。

Figure 5. mlflow summary for Optuna HPO of our heart disease random Forest classifier图5.我们的心脏病随机森林分类器的Optuna HPO的mlflow摘要

Optuna also has great visualizations for summarizing experiments. Here we look at hyper-parameter importance and the optimization history (Figure 6). We can see that the min_samples_leaf is the most important hyper-parameter to tune in this example. The hyper-parameter importance is calculated using a functional ANOVA approach. For more information see Hutter, Hoos and Leyton-Brown 2014.

Optuna还具有用于汇总实验的出色可视化效果。 在这里,我们看一下超参数的重要性和优化历史( 图6 )。 我们可以看到,在此示例中,min_samples_leaf是最重要的超参数。 使用功能方差分析方法计算超参数重要性。 有关更多信息,请参阅Hutter,Hoos和Leyton-Brown 2014 。

Figure 6. Hyper-parameter importance (left) and the optimization history for ROC AUC (right)图6.超参数重要性(左)和ROC AUC的优化历史(右)

摘要 (Summary)

Optuna has come a long way since its inception and version 2.0 released in July this year has some fantastic additions, one of which we touched upon in this short article: the mlflow callback. Perhaps as expected the tuning worked great and the summaries available via the in-built visualizations in Optuna and using the mlflow UI made this a lot of fun.

Optuna自问世以来已经走了很长一段路,并且在今年7月发布的2.0版中添加了一些很棒的功能,我们在这篇短文中谈到了其中之一:mlflow回调。 也许正如预期的那样,调整效果很好,并且通过Optuna的内置可视化工具以及使用mlflow UI的摘要提供了很多乐趣。

The jupyter notebook, virtual environment and data used for this article are available at my GitHub. As always comments, thoughts, feedback and discussion are very welcome.

我的GitHub上提供了本文使用的jupyter笔记本,虚拟环境和数据。 与往常一样,我们非常欢迎评论,想法,反馈和讨论。

翻译自: https://medium.com/@jasonpben/heart-disease-classifier-tuning-using-optuna-and-mlflow-fc1366eefdec

糖药病数据集分类


http://www.taodudu.cc/news/show-995276.html

相关文章:

  • mongdb 群集_群集文档的文本摘要
  • gdal进行遥感影像读写_如何使用遥感影像进行矿物勘探
  • 推荐算法的先验算法的连接_数据挖掘专注于先验算法
  • 时间序列模式识别_空气质量传感器数据的时间序列模式识别
  • 数据科学学习心得_学习数据科学
  • 数据科学生命周期_数据科学项目生命周期第1部分
  • 条件概率分布_条件概率
  • 成为一名真正的数据科学家有多困难
  • 数据驱动开发_开发数据驱动的股票市场投资方法
  • 算法偏见是什么_算法可能会使任何人(包括您)有偏见
  • 线性回归非线性回归_了解线性回归
  • 数据图表可视化_数据可视化如何选择正确的图表第1部分
  • 使用python和javascript进行数据可视化
  • github gists 101使代码共享漂亮
  • 大熊猫卸妆后_您不应错过的6大熊猫行动
  • jdk重启后步行_向后介绍步行以一种新颖的方式来预测未来
  • scrapy模拟模拟点击_模拟大流行
  • plsql中导入csvs_在命令行中使用sql分析csvs
  • 交替最小二乘矩阵分解_使用交替最小二乘矩阵分解与pyspark建立推荐系统
  • 火种 ctf_分析我的火种数据
  • 分析citibike数据eda
  • 带有postgres和jupyter笔记本的Titanic数据集
  • 机器学习模型 非线性模型_机器学习模型说明
  • 算命数据_未来的数据科学家或算命精神向导
  • 熊猫数据集_熊猫迈向数据科学的第三部分
  • 充分利用UC berkeleys数据科学专业
  • 铁拳nat映射_铁拳如何重塑我的数据可视化设计流程
  • 有效沟通的技能有哪些_如何有效地展示您的数据科学或软件工程技能
  • vue取数据第一个数据_我作为数据科学家的第一个月
  • rcp rapido_为什么气流非常适合Rapido

糖药病数据集分类_使用optuna和mlflow进行心脏病分类器调整相关推荐

  1. lda进行图片分类_基于SIFT+Kmeans+LDA的图片分类器的实现

    题记:2012年4月1日回到家,南大计算机研究僧复试以后,等待着的就是独坐家中无聊的潇洒.不知哪日,无意中和未来的同学潘潘聊到了图像处理,聊到了她的论文<基于LDA的行人检测>,出于有一年 ...

  2. 机器学习——人工神经网络之BP算法编程(python二分类数据集:马疝病数据集)

    目录 一.理论知识回顾 1.神经网络模型 2.明确任务以及参数 1)待估参数: 2)超参数: 3)任务 3.神经网络数学模型定义 1)激活函数 ​ 2)各层权重.阈值定义 3)各层输入输出定义 4.优 ...

  3. orange实现逻辑回归_分别用逻辑回归和决策树实现鸢尾花数据集分类

    学习了决策树和逻辑回归的理论知识,决定亲自上手尝试一下.最终导出决策树的决策过程的图片和pdf.逻辑回归部分参考的是用逻辑回归实现鸢尾花数据集分类,感谢原作者xiaoyangerr 注意:要导出为pd ...

  4. 朴素贝叶斯(西瓜数据集分类,社区恶意留言分类,垃圾邮件分类,新浪新闻分类),AODE分类器 代码实现

    朴素贝叶斯(西瓜数据集分类,社区恶意留言分类,垃圾邮件分类,新浪新闻分类),AODE分类器 代码实现 以下代码为本人学习后,修改或补充后的代码实现,数据集和原代码请参考:https://github. ...

  5. mnist数据集彩色图像_使用MNIST数据集构建多类图像分类模型。

    mnist数据集彩色图像 Below are the steps to build a model that can classify handwritten digits with an accur ...

  6. 糖尿病预测模型-Pima印第安人数据集-论文_企业科研

    糖尿病概述 糖尿病有一型和二型,是由于胰腺分泌胰岛素紊乱或人体无法有效利用其产生的胰岛素而发生的一种慢性疾病,是21世纪人类面临的健康问题之一.糖尿病伴有弥漫性并发症,其包括心血管病变.肾脏疾病.高血 ...

  7. 基于Adaboost实现鸢尾花数据集分类

    写在之前 提交内容分为两大部分: 一为Adaboost算法实现,代码在文件夹<算法实现>中,<提升方法笔记>为个人学习笔记. 二为基于Adaboost模型实现鸢尾花数据集分类, ...

  8. 数据增强 数据集扩充_数据扩充的抽象总结

    数据增强 数据集扩充 班级分配不均衡的创新解决方案 (A Creative Solution to Imbalanced Class Distribution) Imbalanced class di ...

  9. 菜品三级分类_分类器的惊人替代品

    菜品三级分类 Many tasks in Machine Learning are setup as classification tasks. The name would imply you ha ...

最新文章

  1. [教程]Python函数的参数
  2. “大型票务系统”和“实物电商系统”的数据库选型
  3. shared_ptr 用法
  4. 我在学python-你们以为我在学C++?其实我在学Python!人生苦短!
  5. maven 学习笔记2
  6. 漫游Kafka设计篇之性能优化
  7. 为什么苹果有2500亿美刀不用,偏偏要借钱?
  8. YARP+AgileConfig 5分钟实现一个支持配置热更新的代理网关
  9. qmc0转换mp3工具_GoldenRecords for Mac(唱片录音转换软件)
  10. python 案例串接_Python基础系例--字典串操作
  11. 多线程 并发编程(一)
  12. python程序设计采用格式框架结构_Python笔记:基于Django框架的项目架构程序设计...
  13. 生产用计算机房噪音应小于,机房建设规范标准要求
  14. SSRF学习(5)gopher协议上传文件
  15. [AcWing] 1017. 怪盗基德的滑翔翼(C++实现)最长上升子序列模型
  16. 2021-03-28
  17. Emlog资源网下载主题模板源码
  18. Java 字符串转码工具类
  19. DDR中的ODT功能详解及波形对比
  20. Element ui el-popover实现content显示img格式

热门文章

  1. Linux网络编程---I/O复用模型之poll
  2. 阿里P8亲自讲解!java实例变量和类变量
  3. python 图像处理(从安装Pillow开始)
  4. Arduino 控制超声波测距模块
  5. Wind River颁布车用信息文娱行使Linux平台
  6. centos7自带数据库MariaDB重启和修改密码
  7. 基于easyui开发Web版Activiti流程定制器详解(二)——文件列表
  8. 3D场景中选取场景中的物体。
  9. C#DNS域名解析工具(DnsLookup)
  10. 2.6 multimap