make_pipeline#

imblearn.pipeline.make_pipeline(*steps, memory=None, transform_input=None, verbose=False)[source]#

从给定的估计器构建一个管道。

这是Pipeline构造函数的简写形式;它不需要也不允许为估计器命名。相反,它们的名称将自动设置为它们类型的小写形式。

Parameters:
*stepslist of estimators

估计器的列表。

memoryNone, str or object with the joblib.Memory interface, default=None

用于缓存管道中已拟合的转换器。默认情况下,不执行缓存。如果给定一个字符串,则是缓存目录的路径。启用缓存会在拟合之前触发转换器的克隆。因此,无法直接检查提供给管道的转换器实例。使用属性named_stepssteps来检查管道中的估计器。当拟合过程耗时较长时,缓存转换器是有利的。

transform_inputlist of str, default=None

这使得可以将一些输入参数(除了X)通过管道的步骤进行转换,直到需要它们的步骤。需求是通过metadata routing定义的。例如,这可以用于通过管道传递验证集。

只有在启用了元数据路由的情况下才能设置此选项,您可以使用 sklearn.set_config(enable_metadata_routing=True) 来启用它。

在版本1.6中添加。

verbosebool, default=False

如果为True,则在完成每个步骤时,将打印出拟合所花费的时间。

Returns:
pPipeline

返回一个处理采样器的imbalanced-learn Pipeline实例。

另请参阅

imblearn.pipeline.Pipeline

用于创建带有最终估计器的转换管道的类。

示例

>>> from sklearn.naive_bayes import GaussianNB
>>> from sklearn.preprocessing import StandardScaler
>>> make_pipeline(StandardScaler(), GaussianNB(priors=None))
Pipeline(steps=[('standardscaler', StandardScaler()),
                ('gaussiannb', GaussianNB())])

使用 imblearn.pipeline.make_pipeline 的示例#

使用欠采样的多类分类

Multiclass classification with under-sampling

文本文档中的主题分类示例

Example of topic classification in text documents

自定义采样器以实现异常值拒绝估计器

Customized sampler to implement an outlier rejections estimator

在人脸识别任务中基准过采样方法

Benchmark over-sampling methods in a face recognition task

在不平衡数据集上拟合模型以及如何对抗偏差

Fitting model on imbalanced datasets and how to fight bias

比较采样器结合过采样和欠采样

Compare sampler combining over- and under-sampling

通过编译报告评估分类

Evaluate classification by compiling a report

不平衡学习特有的指标

Metrics specific to imbalanced learning

绘制验证曲线

Plotting Validation Curves

比较过采样采样器

Compare over-sampling samplers

管道嵌入采样器的使用

Usage of pipeline embedding samplers

比较欠采样采样器

Compare under-sampling samplers