管道探索器
项目描述
来自麻省理工学院Data to AI Lab的开源项目。
管道探索器
提供了一系列类和函数,可以探索和重现成千上万的MLBlocks管道和模板在数百个数据集上获得的性能。
- 免费软件:MIT许可证
- 文档:https://HDI-Project.github.io/piex
- 主页:https://github.com/HDI-Project/piex
概述
此存储库包含一系列类和函数,允许用户轻松探索麻省理工学院团队使用MLBlocks管道在大量数据集上运行的一系列实验的结果。
随着这个库的发布,我们还发布了一系列拟合的流水线,它们在交叉验证、测试数据和指标上的性能。这些实验的结果被存储在数据库中,后来上传到Amazon S3,用户可以通过Pipeline Explorer下载并分析这些数据。
我们将持续添加更多流水线、模板和数据集到我们的实验中,并将它们公开提供给社区。
这些可以用于以下目的
- 找到到目前为止给定数据集和任务类型(给定我们定义的搜索空间和我们的调优器)的最佳分数
- 使用流水线性能信息进行元学习
我们实验的当前总结如下
数据集数量 | |
---|---|
流水线 | 453 |
模板 | 2115907 |
测试 | 63 |
概念 | 2152 |
在深入软件使用之前,我们简要解释一些概念和术语。
原语
我们称机器学习过程中使用的最小计算块为原语,它可以是类或函数。
具有一些初始化参数,MLBlocks称为init_params
。
- 具有一些可调的超参数,具有类型和有效值列表或范围。
- 模板
- 原语可以组合成我们所说的模板,它具有以下特点:
具有一个原语列表。
具有一些初始化参数,与原语的初始化参数相对应。
- 具有一些可调的超参数,与原语的可调超参数相对应。
- 流水线
- 模板可以用来构建通过固定模板的一组有效超参数来构建的流水线。因此,流水线
具有一个原语列表,与模板的原语列表相对应。
具有一些初始化参数,与模板的初始化参数相对应。
- 具有一些超参数值,这些值在模板的有效可调超参数范围内。
- 流水线可以使用MLBlocks中的MLPipeline API进行拟合和评估。
- 数据集
使用了大约450个数据集,涵盖了6种不同的数据模式和17种任务类型。
每个数据集都使用留出法分为两部分,分别是训练和测试,分别用于寻找和拟合每个数据集的最佳流水线,以及后来评估每个流水线与每个数据集特定指标的拟合度。
这个数据集集合存储在Amazon S3桶中,格式为D3M格式,包括训练和测试分区,可以通过piex或网页浏览器下载,链接如下:https://d3m-data-dai.s3.amazonaws.com/index.html
什么是实验/测试?
在我们描述的过程中,我们将搜索过程称为实验或测试。实验/测试的定义如下:
给定一个数据集和一个任务
给定一个模板
- 然后使用贝叶斯调优算法(使用来自我们BTB库的调优器)进行搜索。调优算法测试多个从模板派生的流水线,并尝试在每个数据集上找到该模板的最佳超参数集。
- 在搜索过程中,会存储一系列信息到数据库中,并通过piex提供。它们是:
- 每个流水线在搜索过程中拟合到训练分区时获得的交叉验证分数。
- 在搜索过程中,某些时间点,已找到的最佳流水线被验证对测试数据,并存储在数据库中的得分。
- 调优过程中使用的超参数信息。
- 评估的流水线数量信息。
每个实验被赋予以下配置值之一或多个
- 超时:搜索过程允许运行的最大时间。
- 预算:搜索过程允许进行的调优迭代次数的最大值。
- 检查点:以秒为单位的时间点列表,在这些时间点,迄今为止的最佳流水线被针对测试数据进行评分。
- 流水线:用于构建流水线的模板名称。
- 调优器类型:要使用的调优器类型,
gp
或uniform
。
入门指南
安装
安装Pipeline Explorer最简单和推荐的方式是使用pip。
pip install piex
或者,您也可以克隆存储库并从源安装。
git clone git@github.com:HDI-Project/piex.git
cd piex
pip install -e .
使用方法
S3PipelineExplorer
S3PipelineExplorer类提供了从S3下载先前测试执行结果的方法,查看哪些流水线获得了最佳分数,并将它们作为字典加载,以便MLPipeline使用。
要开始使用它,需要提供用于下载数据的S3桶的名称。
在此示例中,我们将使用ml-pipelines-2018
桶,其中可以找到为Machine Learning Bazaar论文运行的实验结果。
from piex.explorer import S3PipelineExplorer
piex = S3PipelineExplorer('ml-pipelines-2018')
数据集
get_datasets
方法返回一个包含有关可用数据集、数据模式、任务类型和任务子类型信息的pandas.DataFrame
。
datasets = piex.get_datasets()
datasets.shape
(453, 4)
datasets.head()
数据集 | 数据模式 | 任务类型 | 任务子类型 | |
---|---|---|---|---|
314 | 124_120_mnist | 图像 | 分类 | 多类 |
315 | 124_138_cifar100 | 图像 | 分类 | 多类 |
316 | 124_153_svhn_cropped | 图像 | 分类 | 多类 |
317 | 124_174_cifar10 | 图像 | 分类 | 多类 |
318 | 124_178_coil100 | 图像 | 分类 | 多类 |
datasets = piex.get_datasets(data_modality='multi_table', task_type='regression')
datasets.head()
数据集 | 数据模式 | 任务类型 | 任务子类型 | |
---|---|---|---|---|
311 | uu2_gp_hyperparameter_estimation | 多表 | 回归 | 多元 |
312 | uu3_world_development_indicators | 多表 | 回归 | 单变量 |
实验
可以使用get_tests
方法获取已执行测试的列表。
此方法返回一个包含每在数据集上运行的每个实验的行的pandas.DataFrame
。该数据集包括有关数据集、实验使用的配置信息,例如模板、检查点或预算,以及有关执行的信息,例如时间戳、确切的软件版本、执行测试的主机以及是否存在错误。
就像get_datasets
一样,任何关键字参数都将用于过滤结果。
import pandas as pd
tests = piex.get_tests()
tests.head().T
0 | 1 | 2 | 3 | 4 | |
---|---|---|---|---|---|
预算 | NaN | NaN | NaN | NaN | NaN |
检查点 | [900, 1800, 3600, 7200] | [900, 1800, 3600, 7200] | [900, 1800, 3600, 7200] | [900, 1800, 3600, 7200] | [900, 1800, 3600, 7200] |
提交 | 4c7c29f | 4c7c29f | 4c7c29f | 4c7c29f | 4c7c29f |
数据集 | 196_autoMpg | 26_radon_seed | LL0_1027_esl | LL0_1028_swd | LL0_1030_era |
docker | False | False | False | False | False |
错误 | NaN | NaN | NaN | NaN | NaN |
主机名 | ec2-52-14-97-167.us-east-2.compute.amazonaws.com | ec2-18-223-109-53.us-east-2.compute.amazonaws.com | ec2-18-217-79-23.us-east-2.compute.amazonaws.com | ec2-18-217-239-54.us-east-2.compute.amazonaws.com | ec2-18-225-32-252.us-east-2.compute.amazonaws.com |
图像 | NaN | NaN | NaN | NaN | NaN |
插入时间戳 | 2018-10-24 20:05:01.872 | 2018-10-24 20:05:02.778 | 2018-10-24 20:05:02.879 | 2018-10-24 20:05:02.980 | 2018-10-24 20:05:03.081 |
流水线 | categorical_encoder/imputer/standard_scaler/xg... | categorical_encoder/imputer/standard_scaler/xg... | categorical_encoder/imputer/standard_scaler/xg... | categorical_encoder/imputer/standard_scaler/xg... | categorical_encoder/imputer/standard_scaler/xg... |
状态 | 完成 | 完成 | 完成 | 完成 | 完成 |
测试ID | 20181024200501872083 | 20181024200501872083 | 20181024200501872083 | 20181024200501872083 | 20181024200501872083 |
超时 | NaN | NaN | NaN | NaN | NaN |
跟踪 | NaN | NaN | NaN | NaN | NaN |
调优器类型 | NaN | NaN | NaN | NaN | NaN |
更新时间戳 | 2018-10-24 22:05:55.386 | 2018-10-24 22:05:57.508 | 2018-10-24 22:05:56.337 | 2018-10-24 22:05:56.112 | 2018-10-24 22:05:56.164 |
数据模式 | 单表 | 单表 | 单表 | 单表 | 单表 |
任务类型 | 回归 | 回归 | 回归 | 回归 | 回归 |
任务子类型 | 单变量 | 单变量 | 单变量 | 单变量 | 单变量 |
指标 | 均方误差 | 均方根误差 | 均方误差 | 均方误差 | 均方误差 |
数据集ID | 196_autoMpg_dataset_TRAIN | 26_radon_seed_dataset_TRAIN | LL0_1027_esl_dataset_TRAIN | LL0_1028_swd_dataset_TRAIN | LL0_1030_era_dataset_TRAIN |
问题ID | 196_autoMpg_problem_TRAIN | 26_radon_seed_problem_TRAIN | LL0_1027_esl_problem_TRAIN | LL0_1028_swd_problem_TRAIN | LL0_1030_era_problem_TRAIN |
目标 | 类别 | 对数 радон | 输出1 | Out1 | 输出1 |
大小 | 24 | 160 | 16 | 52 | 32 |
人类大小 | 24K | 160K | 16K | 52K | 32K |
测试特征 | 7 | 28 | 4 | 10 | 4 |
测试样本 | 100 | 183 | 100 | 199 | 199 |
训练特征 | 7 | 28 | 4 | 10 | 4 |
训练样本 | 298 | 736 | 388 | 801 | 801 |
pd.DataFrame(tests.groupby(['data_modality', 'task_type']).size(), columns=['count'])
计数 | ||
---|---|---|
数据模式 | 任务类型 | |
图形 | 社区检测 | 5 |
图匹配 | 18 | |
链接预测 | 2 | |
顶点提名 | 2 | |
图像 | 分类 | 57 |
回归 | 1 | |
多表 | 分类 | 1 |
回归 | 1 | |
单表 | 分类 | 1405 |
协同过滤 | 1 | |
回归 | 430 | |
时间序列预测 | 175 | |
文本 | 分类 | 17 |
时间序列 | 分类 | 37 |
tests = piex.get_tests(data_modality='graph', task_type='link_prediction')
tests[['dataset', 'pipeline', 'checkpoints', 'test_id']]
数据集 | 流水线 | 检查点 | 测试ID | |
---|---|---|---|---|
1716 | 59_umls | NaN | [900, 1800, 3600, 7200] | 20181031040541366347 |
2141 | 59_umls | 图/链接预测/随机森林分类器 | [900, 1800, 3600, 7200] | 20181031182305995728 |
实验结果
实验结果可以通过get_experiment_results
方法查看。
这些结果包括管道在调整过程中获得的交叉验证分数,以及使用训练数据拟合后并在测试数据上预测时获得的分数。
与get_datasets
一样,任何关键字参数都将用于过滤结果,包括test_id
。
results = piex.get_test_results(test_id='20181031182305995728')
results[['test_id', 'pipeline', 'score', 'cv_score', 'elapsed', 'iterations']]
测试ID | 流水线 | 分数 | 交叉验证分数 | 消耗时间 | 迭代次数 | |
---|---|---|---|---|---|---|
7464 | 20181031182305995728 | 图/链接预测/随机森林分类器 | 0.499853 | 0.843175 | 900.255511 | 435.0 |
7465 | 20181031182305995728 | 图/链接预测/随机森林分类器 | 0.499853 | 0.854603 | 1800.885417 | 805.0 |
7466 | 20181031182305995728 | 图/链接预测/随机森林分类器 | 0.499853 | 0.854603 | 3600.005072 | 1432.0 |
7467 | 20181031182305995728 | 图/链接预测/随机森林分类器 | 0.785568 | 0.860000 | 7200.225256 | 2366.0 |
最佳管道
可以通过get_best_pipeline
方法获取数据集的最佳管道信息。
此方法返回一个包含在调整期间获得最佳交叉验证分数的管道信息和构建它的模板的pandas.Series
对象。
注意:首次运行此调用时,会在后台下载一些数据,因此返回可能需要一段时间。
piex.get_best_pipeline('185_baseball')
id 17385666-31da-4b6e-ab7f-8ac7080a4d55
dataset 185_baseball_dataset_TRAIN
metric f1Macro
name categorical_encoder/imputer/standard_scaler/xg...
rank 0.307887
score 0.692113
template 5bd0ce5249e71569e8bf8003
test_id 20181024234726559170
pipeline categorical_encoder/imputer/standard_scaler/xg...
data_modality single_table
task_type classification
Name: 1149699, dtype: object
除了获取这些信息外,我们还可以使用load_best_pipeline
方法加载其JSON规范,以便在mlblocks.MLPipeline
对象中使用。
pipeline = piex.load_best_pipeline('185_baseball')
pipeline['primitives']
['mlprimitives.feature_extraction.CategoricalEncoder',
'sklearn.preprocessing.Imputer',
'sklearn.preprocessing.StandardScaler',
'mlprimitives.preprocessing.ClassEncoder',
'xgboost.XGBClassifier',
'mlprimitives.preprocessing.ClassDecoder']
最佳模板
与最佳管道一样,可以使用get_best_template
方法获取给定数据集的最佳模板。
这返回了构建最佳管道所使用的模板名称。
template_name = piex.get_best_template('185_baseball')
template_name
'categorical_encoder/imputer/standard_scaler/xgbclassifier'
这可以稍后用于探索模板,获取其默认超参数
defaults = piex.get_default_hyperparameters(template_name)
defaults
{'mlprimitives.feature_extraction.CategoricalEncoder#1': {'copy': True,
'features': 'auto',
'max_labels': 0},
'sklearn.preprocessing.Imputer#1': {'missing_values': 'NaN',
'axis': 0,
'copy': True,
'strategy': 'mean'},
'sklearn.preprocessing.StandardScaler#1': {'with_mean': True,
'with_std': True},
'mlprimitives.preprocessing.ClassEncoder#1': {},
'xgboost.XGBClassifier#1': {'n_jobs': -1,
'n_estimators': 100,
'max_depth': 3,
'learning_rate': 0.1,
'gamma': 0,
'min_child_weight': 1},
'mlprimitives.preprocessing.ClassDecoder#1': {}}
或获取相应的可调范围,以便与调谐器一起使用
tunable = piex.get_tunable_hyperparameters(template_name)
tunable
{'mlprimitives.feature_extraction.CategoricalEncoder#1': {'max_labels': {'type': 'int',
'default': 0,
'range': [0, 100]}},
'sklearn.preprocessing.Imputer#1': {'strategy': {'type': 'str',
'default': 'mean',
'values': ['mean', 'median', 'most_frequent']}},
'sklearn.preprocessing.StandardScaler#1': {'with_mean': {'type': 'bool',
'default': True},
'with_std': {'type': 'bool', 'default': True}},
'mlprimitives.preprocessing.ClassEncoder#1': {},
'xgboost.XGBClassifier#1': {'n_estimators': {'type': 'int',
'default': 100,
'range': [10, 1000]},
'max_depth': {'type': 'int', 'default': 3, 'range': [3, 10]},
'learning_rate': {'type': 'float', 'default': 0.1, 'range': [0, 1]},
'gamma': {'type': 'float', 'default': 0, 'range': [0, 1]},
'min_child_weight': {'type': 'int', 'default': 1, 'range': [1, 10]}},
'mlprimitives.preprocessing.ClassDecoder#1': {}}
评分模板和管道
S3PipelineExplorer类还允许对任何数据集上的模板和管道进行交叉验证。
评分管道
最简单的用例是在数据集上交叉验证管道。为此,我们必须将管道ID和数据集名称传递给score_pipeline
方法。
数据集可以是实验中使用的那个,也可以是不同的数据集。
piex.score_pipeline(pipeline['id'], '185_baseball')
(0.6921128080904511, 0.09950216269594728)
piex.score_pipeline(pipeline['id'], 'uu4_SPECT')
(0.8897656842904123, 0.037662864373452655)
可选地,可以更改交叉验证配置
piex.score_pipeline(pipeline['id'], 'uu4_SPECT', n_splits=3, random_state=43)
(0.8869488536155202, 0.019475563687443638)
评分模板
模板也可以通过传递其名称、数据集和可选的交叉验证规范在任意数据集上进行测试。你必须确保选择与你想要使用的任务/数据模态相关的模板。
如果没有传递超参数,将使用默认参数
piex.score_template(template_name, 'uu4_SPECT', n_splits=3, random_state=43)
(0.8555346666968675, 0.028343173498423108)
你可以获取默认超参数,并通过在字典中设置值来更新超参数
这样,任何人都可以使用他们自己的AutoML流程来调整我们为不同任务/数据模态类型提供的模板。如果您选择这样做,请告诉我们您获得的分数以及管道,我们将将其添加到我们的数据库中。
hyperparameters = piex.get_default_hyperparameters(template_name)
hyperparameters['xgboost.XGBClassifier#1']['learning_rate'] = 1
piex.score_template(template_name, 'uu4_SPECT', hyperparameters, n_splits=3, random_state=43)
(0.8754554700753094, 0.019151608028236813)
历史
0.2.0
- 固定依赖版本以确保可重复性
- 允许无AWS凭证使用S3PipelineExplorer
- 修复S3PipelineExplorer中的小错误
0.1.1
- 改进文档
- 修复了一些小错误并改进了探索器API
0.1.0
- 首次发布在PyPI
项目详情
下载文件
下载适合您平台的文件。如果您不确定要选择哪个,请了解更多关于安装包的信息。
源分布
构建分布
piex-0.2.0.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | c6ebb98ac1ea7d07dcb63b14f674158c66e670ce1fbad9b1fc6da3d6a903fbff |
|
MD5 | 9513ca888ab4e30624d813db1a8836dd |
|
BLAKE2b-256 | b3aca1ae4c66b0c91d51715e2d3bb402d92eea03e8fd4500021a7219fa36521c |
piex-0.2.0-py2.py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 1d3a45d9ce7479d6b30823783a205356eb3ce01414f73977124d93d810ec3a76 |
|
MD5 | 81fa32e115353bd8f2deb483a84ddd20 |
|
BLAKE2b-256 | 86a88d43acb88a5b5e247879e93776fe9f8c99bb31cabbedb42099a251cedb2b |