automl框架:AutoGluon介绍
文章目录
- automl框架:AutoGluon介绍
- 原理
- 安装
- 案例
- 加载数据集
- 测试
- 通过leaderboard查看各个学习器
- 参考
automl框架:AutoGluon介绍
原理
- 大部分automl框架是基于超参数搜索技术,例如基于贝叶斯搜索的hyperopt技术等
- AutoGluon则依赖融合多个无需超参数搜索的模型,三个臭皮匠顶个诸葛亮
- stacking: 在同一份数据上训练出多个不同类型的模型,这些模型可以是KNN、tree、核方法等,这些模型的输出进入到一个线性模型里面得到最终的输出,就是对这些输出做加权求和,这里的权重是通过训练得出。
- K-则交叉Bagging:Bagging是训练同类别的多个模型,他们可能使用不同的初始权重或者数据块,最终将这些模型的输出做平均来降低模型的方差。
- K-则交叉Bagging,源自于K-则交叉验证。
- 相同点都是对数据集做K折
- K-则交叉验证:相同的初始参数,训练多次,对每次的误差求平均后作为这些初始参数的最终误差,为了最大化利用数据集,可以有效避免过拟合和欠拟合。
- (是为了验证初始参数)
- K-则交叉Bagging:每一则对应不同的初始参数,训练出多个模型,对结果求平均(3个臭皮匠顶个诸葛亮)
- 多层Stacking:将多个模型输出的数据,合并起来,再做一次Stacking。在上面再训练多个模型,最后用一个线性模型做输出。
- 为了避免后面层过多拟合数据,多层Stacking通常配合K-则交叉Bagging使用,也就是说这里的每个模型是K个模型的Bagging。它对下一层stacking的输出,是指每个bagging模型对应验证集上输出的合并
安装
conda create -y --force -n p38 python=3.8 pip
conda activate p38
pip install -U "mxnet<2.0.0"
pip install autogluon
案例
加载数据集
from autogluon.tabular import TabularDataset, TabularPredictor
train_data = TabularDataset('https://autogluon.s3.amazonaws.com/datasets/Inc/train.csv')
subsample_size = 500 # subsample subset of data for faster demo, try setting this to much larger values
train_data = train_data.sample(n=subsample_size, random_state=0)
label = 'class'
save_path = 'agModels-predictClass' # specifies folder to store trained models
predictor = TabularPredictor(label=label, path=save_path).fit(train_data)
fit函数执行的日志如下:
- 首先推导是什么问题,binary、multiclass还是regression
- 进行数据预处理(Data preprocessing and feature engineering)
- AsTypeFeatureGenerator
- FillNaFeatureGenerator
- IdentityFeatureGenerator、CategoryFeatureGenerator
- DropUniqueFeatureGenerator
- 通过eval_metric参数决定评估指标来衡量预测性能,默认是accuracy(准确性)
- 自动拆分训练集和验证集,holdout_frac=0.2
- 训练模型(从最快的模型开始尝试,作为stack1)
- KNeighborsUnif
- KNeighborsDist
- LightGBMXT
- LightGBM
- 最后一个是WeightedEnsemble(作为stack2)
- 保存模型
Beginning AutoGluon training ...
AutoGluon will save models to "agModels-predictClass/"
AutoGluon Version: 0.2.0
Train Data Rows: 500
Train Data Columns: 14
Preprocessing data ...
AutoGluon infers your prediction problem is: 'binary' (because only two unique label-values observed).2 unique label values: [' >50K', ' <=50K']If 'binary' is not the correct problem_type, please manually specify the problem_type argument in fit() (You may specify problem_type as one of: ['binary', 'multiclass', 'regression'])
Selected class <--> label mapping: class 1 = >50K, class 0 = <=50KNote: For your binary classification, AutoGluon arbitrarily selected which label-value represents positive ( >50K) vs negative ( <=50K) class.To explicitly set the positive_class, either rename classes to 1 and 0, or specify positive_class in Predictor init.
Using Feature Generators to preprocess the data ...
Fitting AutoMLPipelineFeatureGenerator...Available Memory: 84412.85 MBTrain Data (Original) Memory Usage: 0.29 MB (0.0% of available memory)Inferring data type of each feature based on column values. Set feature_metadata_in to manually specify special dtypes of the features.Stage 1 Generators:Fitting AsTypeFeatureGenerator...Stage 2 Generators:Fitting FillNaFeatureGenerator...Stage 3 Generators:Fitting IdentityFeatureGenerator...Fitting CategoryFeatureGenerator...Fitting CategoryMemoryMinimizeFeatureGenerator...Stage 4 Generators:Fitting DropUniqueFeatureGenerator...Types of features in original data (raw dtype, special dtypes):('int', []) : 6 | ['age', 'fnlwgt', 'education-num', 'capital-gain', 'capital-loss', ...]('object', []) : 8 | ['workclass', 'education', 'marital-status', 'occupation', 'relationship', ...]Types of features in processed data (raw dtype, special dtypes):('category', []) : 8 | ['workclass', 'education', 'marital-status', 'occupation', 'relationship', ...]('int', []) : 6 | ['age', 'fnlwgt', 'education-num', 'capital-gain', 'capital-loss', ...]0.2s = Fit runtime14 features in original data used to generate 14 features in processed data.Train Data (Processed) Memory Usage: 0.03 MB (0.0% of available memory)
Data preprocessing and feature engineering runtime = 0.27s ...
AutoGluon will gauge predictive performance using evaluation metric: 'accuracy'To change this, specify the eval_metric argument of fit()
Automatically generating train/validation split with holdout_frac=0.2, Train Rows: 400, Val Rows: 100
Fitting model: KNeighborsUnif ...0.73 = Validation accuracy score0.02s = Training runtime0.04s = Validation runtime
Fitting model: KNeighborsDist ...0.65 = Validation accuracy score0.01s = Training runtime0.05s = Validation runtime
Fitting model: LightGBMXT ...0.83 = Validation accuracy score198.28s = Training runtime0.04s = Validation runtime
Fitting model: LightGBM ...0.85 = Validation accuracy score342.98s = Training runtime0.08s = Validation runtime
Fitting model: RandomForestGini ...0.84 = Validation accuracy score1.83s = Training runtime0.16s = Validation runtime
Fitting model: RandomForestEntr ...0.83 = Validation accuracy score1.39s = Training runtime0.31s = Validation runtime
Fitting model: CatBoost ...0.84 = Validation accuracy score0.87s = Training runtime0.03s = Validation runtime
Fitting model: ExtraTreesGini ...0.82 = Validation accuracy score1.35s = Training runtime0.14s = Validation runtime
Fitting model: ExtraTreesEntr ...0.82 = Validation accuracy score1.49s = Training runtime0.23s = Validation runtime
Fitting model: NeuralNetFastAI ...Warning: Exception caused NeuralNetFastAI to fail during training... Skipping this model.CUDA error: out of memory
Fitting model: XGBoost ...0.85 = Validation accuracy score152.17s = Training runtime0.02s = Validation runtime
Fitting model: NeuralNetMXNet ...0.84 = Validation accuracy score9.57s = Training runtime0.59s = Validation runtime
Fitting model: LightGBMLarge ...0.83 = Validation accuracy score745.44s = Training runtime0.01s = Validation runtime
Fitting model: WeightedEnsemble_L2 ...0.85 = Validation accuracy score0.27s = Training runtime0.0s = Validation runtime
AutoGluon training complete, total runtime = 1460.95s ...
TabularPredictor saved. To load, use: predictor = TabularPredictor.load("agModels-predictClass/")
测试
test_data = TabularDataset('https://autogluon.s3.amazonaws.com/datasets/Inc/test.csv')
y_test = test_data[label] # values to predict
test_data_nolab = test_data.drop(columns=[label]) # delete label column to prove we're not cheatingpredictor = TabularPredictor.load(save_path) # unnecessary, just demonstrates how to load previously-trained predictor from file
y_pred = predictor.predict(test_data_nolab)
perf = predictor.evaluate_predictions(y_true=y_test, y_pred=y_pred, auxiliary_metrics=True)
输出结果为:
Evaluation: accuracy on test data: 0.8397993653393387
Evaluations on test data:
{"accuracy": 0.8397993653393387,"balanced_accuracy": 0.7437076677780596,"mcc": 0.5295565206264157,"f1": 0.6242496998799519,"precision": 0.7038440714672441,"recall": 0.5608283002588438
}
通过leaderboard查看各个学习器
predictor.leaderboard(test_data, silent=True)
参考
- https://auto.gluon.ai/dev/tutorials/tabular_prediction/tabular-quickstart.html
- 论文:https://arxiv.org/abs/2003.06505
- arXiv 同archive 读['a:rkaiv]
automl框架:AutoGluon介绍相关推荐
- [机器学习]AutoML---谷歌开源AdaNet:基于TensorFlow的AutoML框架
谷歌开源了基于 TensorFlow 的轻量级框架 AdaNet,该框架可以使用少量专家干预来自动学习高质量模型.据介绍,AdaNet 在谷歌近期的强化学习和基于进化的 AutoML 的基础上构建,快 ...
- 【实践】美团外卖图谱推荐比赛冠军经验分享:从多领域优化到AutoML框架
猜你喜欢 0.[免费下载]2021年12月热门报告盘点1.如何搭建一套个性化推荐系统?2.快手推荐系统精排模型实践.pdf3.全民K歌推荐系统算法.架构及后台实现4.微博推荐算法实践与机器学习平台演进 ...
- 推荐系统实践:从多领域优化到AutoML框架
猜你喜欢 0.[免费下载]2021年11月热门报告盘点1.预训练模型在华为信息流推荐中的应用与实践2.一站式数据开发平台在有赞的实践3.美团搜索排序架构及优化实践4.面向广告主的猜你喜欢推荐实践5.腾 ...
- 7次KDD CupKaggle冠军的经验分享:从多领域优化到AutoML框架
本文结合笔者在7次Kaggle/KDD Cup中的冠军经验,围绕多领域建模优化.AutoML技术框架以及面对新问题如何分析建模等三个方面进行了介绍.希望能够帮更多同学了解比赛中通用的高效建模方法与问题 ...
- Google 开源 AdaNet:快速灵活的轻量级 AutoML 框架
雷锋网 AI 科技评论编者按:近期,Google 开源了轻量级 AutoML 框架-- AdaNet,该框架基于 TensorFlow,只需要少量的专家干预便能自动学习高质量模型,在提供学习保证(le ...
- NET Core微服务之路:自己动手实现Rpc服务框架,基于DotEasy.Rpc服务框架的介绍和集成...
原文:NET Core微服务之路:自己动手实现Rpc服务框架,基于DotEasy.Rpc服务框架的介绍和集成 本篇内容属于非实用性(拿来即用)介绍,如对框架设计没兴趣的朋友,请略过. 快一个月没有写博 ...
- TF之AutoML框架:AutoML框架的简介、特点、使用方法详细攻略
TF之AutoML框架:AutoML框架的简介.特点.使用方法详细攻略 目录 AutoML框架的简介 AutoML框架的特点 AutoML框架的使用方法 AutoML VS AutoKeras 框架 ...
- Django - Django框架 简单介绍
Django框架 简单介绍 本文地址: http://blog.csdn.net/caroline_wendy/article/details/29172271 1. 介绍 Django是一个开放源码 ...
- python nose测试框架全面介绍十---用例的跳过
又来写nose了,这次主要介绍nose中的用例跳过应用,之前也有介绍,见python nose测试框架全面介绍四,但介绍的不详细.下面详细解析下 nose自带的SkipTest 先看看nose自带的S ...
最新文章
- mysql课程id数据类型_数据库学习之六:mysql数据类型
- 为什么 MySQL 不推荐默认值为 null ?
- 使用Azure DevOps Pipeline实现.Net Core程序的CI
- c语言 葬礼分号,其实从C语言用分号结尾开始,就是一个悲剧了……
- POI读取Excel文件时,row.getCell(0).getStringCellValue()报错:数字转换异常
- 生命不能承受之轻——沉重的眼泪
- Kotlin入门(33)运用扩展属性
- 洛谷——P1657 选书
- 对事件循环的一点理解
- android 在非UI线程更新UI仍然成功原因深入剖析
- WIN32汇编语言中位图的使用
- Aspose.Cells 使用FreezePanes()冻结行和列
- 什么是听觉?机器听觉?
- linux配置4g网络命令_[4G]Linux平台上实现4G通信
- 使用外网访问Flask项目
- python编写贪吃蛇大战_python实现贪吃蛇双人大战
- linux中为什么要分区,为什么要分区
- android自定义四边形,以编程方式在Android中创建平行四边形绘图
- 观点丨DALL-E 2、AI研究的未来以及OpenAI的商业前景
- 港台明星们的生日大曝光