跳转到主要内容

基于scikit-learn的AutoML工具

项目描述

Build Status

       ______         ______                 ______
__________  /____________  /___  ________ ______  /______________
__  ___/_  //_/__  __ \_  /_  / / /_  __ `__ \_  __ \  _ \_  ___/
_(__  )_  ,<  __  /_/ /  / / /_/ /_  / / / / /  /_/ /  __/  /
/____/ /_/|_| _  .___//_/  \__,_/ /_/ /_/ /_//_.___/\___//_/
              /_/

skplumber是一个机器学习(ML)包,提供两个核心功能:

  • 一个自动机器学习(AutoML)系统,用于在分类或回归问题上自动采样、训练、评分和调整机器学习管道。这可以通过skplumber.skplumber.SKPlumber类获得。
  • 一个轻量级ML框架,可以将ML原语组合成任意形状的管道(skplumber.pipeline.Pipeline),并使用各种评估技术(例如train/test拆分、k折交叉验证和下采样)对这些管道进行训练和拟合。此外,所有原始超参数都预先注有类型和范围信息,以便更容易地交互。此外,还提供了skplumber.tuners.ga.ga_tune的现有超参数调整技术。

基础管道和原始构建块在很大程度上借鉴了数据驱动模型发现(D3M)核心包中存在的相同结构。

项目的API文档位于这里

安装

pip install skplumber

用法

SKPlumber自动机器学习系统

该包的最高级API是skplumber.skplumber.SKPlumber类。您实例化该类,然后使用它的fit方法在给定的输入数据Xy(分别对应于pandas.DataFramepandas.Series)上执行对最佳机器学习(ML)管道的搜索。以下是一个使用经典的鸢尾花数据集的示例

from skplumber import SKPlumber
import pandas as pd
from sklearn.datasets import load_iris

dataset = load_iris()
X = pd.DataFrame(data=dataset["data"], columns=dataset["feature_names"])
y = pd.Series(dataset["target"])

# Ask plumber to find the best machine learning pipeline it
# can for the problem in 60 seconds.
plumber = SKPlumber(problem="classification", budget=60)
plumber.fit(X, y)

# To use the best found machine learning pipeline on unseen data:
predictions = plumber.predict(unseen_X)

管道

skplumber.pipeline.Pipeline类是该包的一个较低级别的API,可用于构建、拟合和预测任意形状的机器学习管道。例如,我们可以创建一个基本的一级堆叠管道,其中预测器的输出被馈送到另一个预测器中,以学习方式进行集成

from skplumber import Pipeline
from skplumber.primitives import transformers, classifiers
import pandas as pd
from sklearn.datasets import load_iris

dataset = load_iris()
X = pd.DataFrame(data=dataset["data"], columns=dataset["feature_names"])
y = pd.Series(dataset["target"])

# A random imputation of missing values step and one hot encoding of
# non-numeric features step are automatically added.
pipeline = Pipeline()
# Preprocess the inputs
pipeline.add_step(transformers["StandardScalerPrimitive"])
# Save the pipeline step index of the preprocessor's outputs
stack_input = pipeline.curr_step_i
# Add three classifiers to the pipeline that all take the
# preprocessor's outputs as inputs
stack_outputs = []
for clf_name in [
    "LinearDiscriminantAnalysisPrimitive",
    "DecisionTreeClassifierPrimitive",
    "KNeighborsClassifierPrimitive"
]:
    pipeline.add_step(classifiers[clf_name], [stack_input])
    stack_outputs.append(pipeline.curr_step_i)
# Add a final classifier that takes the outputs of all the previous
# three classifiers as inputs
pipeline.add_step(classifiers["RandomForestClassifierPrimitive"], stack_outputs)

# Train the pipeline
pipeline.fit(X, y)

# Have fitted pipeline make predictions
pipeline.predict(X)

包意见

  • 管道的最后一步必须是产生管道最终输出的步骤。
  • 所有缺失值都被插补。
  • 所有类型为objectcategory的列都被独热编码。

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分布

skplumber-0.6.5.dev0.tar.gz (24.2 kB 查看哈希值)

上传时间 源代码

构建分布

skplumber-0.6.5.dev0-py3-none-any.whl (31.2 kB 查看哈希值)

上传时间 Python 3

支持者

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面