译者:Coggle,镜像:7种 AutoML 辅助工具库
,著眼Python、数据挖掘、数据挖掘、有趣辅助工具!在日常生活组织工作中,时常会碰到 AutoML 辅助工具。责任编辑归纳了常用的AutoML库,供我们优先选择。
1、LightAutoML
工程项目镜像:https://github.com/sberbank-ai-lab/LightAutoML
所推荐成分股:⭐⭐⭐
LightAutoML是如前所述Python自然环境下的方式化手动机器学习库,那时全力支持的各项任务有:
二进行分类
多进行分类
重回各项任务
LightAutoML那时只全力支持单配置文件历史记录的方式,即每带队由样品的特点和条码共同组成。
import pandas as pd
from sklearn.metrics import f1_score
from lightautoml.automl.presets.tabular_presets import TabularAutoML
from lightautoml.tasks import Task
df_train = pd.read_csv(../input/titanic/train.csv)
df_test = pd.read_csv(../input/titanic/test.csv)
automl = TabularAutoML(
task = Task(
name = binary,
metric = lambda y_true, y_pred: f1_score(y_true, (y_pred > 0.5)*1))
)
oof_pred = automl.fit_predict(
df_train,
roles = {target: Survived, drop: [PassengerId]}
)
test_pred = automl.predict(df_test)
pd.DataFrame({
PassengerId:df_test.PassengerId,
Survived: (test_pred.data[:, 0] > 0.5)*1
}).to_csv(submit.csv, index = False)
2、H2O AutoML
工程项目镜像:https://docs.h2o.ai/h2o/latest-stable/h2o-docs/automl.html
所推荐成分股:⭐⭐⭐⭐
H2O AutoML是如前所述Python自然环境和R自然环境下的方式化手动机器学习库,全力支持分布式部署,对模型调参、模型优先选择和特点筛选全力支持比较完备,但使用起来比较复杂。
import h2o
from h2o.automl import H2OAutoML
h2o.init()
train_hf = h2o.H2OFrame(train_df.copy())
test_hf = h2o.H2OFrame(test_df.copy())
train_hf[target_column] = train_hf[target_column].asfactor()
aml = H2OAutoML(
seed=2021,
max_runtime_secs=100,
nfolds = 3,
exclude_algos = [“DeepLearning”]
)
aml.train(
x=list(feature_columns),
y=target_column,
training_frame=train_hf
)
preds = aml.predict(h2o.H2OFrame(test_df[feature_columns].copy()))
preds_df = h2o.as_list(preds)
preds_df
submission[[Class_1, Class_2, Class_3, Class_4]] = preds_df[[Class_1, Class_2, Class_3, Class_4]]
submission.to_csv(h2o_automl_300s.csv, index=False)
submission.head()
3、MLJAR AutoML
工程项目镜像:https://github.com/mljar/mljar-supervised
所推荐成分股:⭐⭐⭐⭐
MLJAR AutoML是如前所述Python自然环境下的方式化手动机器学习库,所全力支持的机器学习模型非常多,且对模型可视化全力支持的非常好。
from supervised.automl import AutoML # mljar-supervised
automl = AutoML(
mode=“Compete”,
eval_metric=“f1”,
total_time_limit=300,
features_selection=False # switch off feature selection
)
automl.fit(
train[feature_cols],
train[target_column]
)
preds = automl.predict(test[feature_cols])
submission[Survived] = preds
submission.to_csv(mljar_automl_300s_f1_metric.csv, index=False)
submission.head()
4、PyCaret
工程项目镜像:https://pycaret.org/
所推荐成分股:⭐⭐⭐⭐⭐
PyCaret是如前所述Python自然环境下的方式化手动机器学习库,全力支持的各项任务包括:
进行分类
重回
聚类
异常检测
NLP
关联规则
PyCaret全力支持的模型比较多,工程项目也比较活跃,但对模型的可视化做的不够。
from pycaret.classification import *
from category_encoders.cat_boost import CatBoostEncoder
cat_train_df = train_df.copy()
cat_test_df = test_df.copy()
ce = CatBoostEncoder()
cols_to_encode = [name, sex, ticket, cabin, embarked]
cat_train_df[pure_cat_cols] = ce.fit_transform(cat_train_df[pure_cat_cols], cat_train_df[target_column])
cat_test_df[pure_cat_cols] = ce.transform(cat_test_df[pure_cat_cols])
setup(
data = cat_train_df[feature_cols.to_list() + [target_column]],
target = target_column,
fold = 3,
silent = True,
)
best_models = compare_models(
sort=F1,
n_select=3,
budget_time=300,
) # we will use it later
best = automl(optimize = F1)
5、EvalML: AutoML
工程项目镜像:https://evalml.alteryx.com/en/latest/
所推荐成分股:⭐⭐⭐
EvalML是一款比较模块比较完备的手动机器学习框架,全力支持进行分类、重回和时间序列各项任务。但提出的时间稍晚,所以使用的人很少。
from evalml.automl import AutoMLSearch
X = train_df.drop(columns=[target_column, passengerid])
y = train_df[target_column]
X_train,X_test,y_train,y_test = train_test_split(X, y, test_size=0.2)
automl = AutoMLSearch(
X_train=X_train,
y_train=y_train,
problem_type=binary,
random_seed=2021,
max_time=300,
)
automl.search()
pipeline = automl.best_pipeline
pipeline.fit(X, y)
6、TPOT: Genetic Approach
工程项目镜像:http://epistasislab.github.io/tpot/
所推荐成分股:⭐⭐⭐
TPOT是一款非常轻量级的手动机器学习框架,利用遗传算法可以快读完成特点的构造。但TPOT所全力支持的功能较少,所以场景有限。
from tpot import TPOTClassifier
from sklearn.model_selection import train_test_split
tpot = TPOTClassifier(generations=5, population_size=50, verbosity=2, random_state=42)
tpot.fit(X_train, y_train)
print(tpot.score(X_test, y_test))
tpot.export(tpot_digits_pipeline.py)
7、FLAML
工程项目镜像:https://github.com/microsoft/FLAML
所推荐成分股:⭐⭐⭐⭐
FLAML是由微软提出的手动机器学习库,全力支持进行分类和重回各项任务。FLAML对特点的构造和搜索全力支持的比较好,非常轻量。
from flaml import AutoML
from sklearn.datasets import load_boston
automl = AutoML()
# Specify automl goal and constraint
automl_settings = {
“time_budget”: 300, # in seconds
“metric”: accuracy,
“task”: classification,
}
automl.fit(
X_train=train_df[feature_cols],
y_train=train_df[target_column],
**automl_settings
)
print(automl.predict_proba(train_df[feature_cols]))
文章所推荐
Python 的 f-strings,远比你想象的强大!
这可能是最强 Python 可视化库,没有之一
油管知名博主 Bouchard 撰写了2021年入门机器学习完整指南!
移除 GIL,可显著提升 Python 多线程性能么?
丢掉 Pycharm,这款轻量级神器值得拥有!
超详细!Python 制作一个优雅的词云其实特简单!
作为 Python 开发者,这21个 Linux 命令值得去学习!
动手实战!《长津湖》为什么这么火爆?我用 Python 来分析!
太强了,用 Python+Excel 制作天气预报表!
用 Python 制作一个可视化大屏,其实特简单!
妙不可言!Mito:一款超级棒的 JupyterLab 扩展程序!
微软出品!FLAML:一款可以手动化机器学习过程的神器!
整理不易,有所收获,点个赞和爱心❤️,更