Pipeline

class sklearn.pipeline.Pipeline(
steps,
memory = None 

按顺序应用transforms列表和最终估计器。流水线的中间步骤必须是“transforms”,即必须实现fittransforms的方法(最后的估算器只需要实现fit)。管道中的变换器可以使用memory参数进行缓存。

管道的目的是组装几个可以一起交叉验证的步骤,同时设置不同的参数。为此,它可以使用名称和参数名以“__”分隔各个步骤来设置各个步骤。一个步骤的估算器可能完全根据参数名称替换为另一个估算器,或者通过设置为None来移除transformer

参数:

steps:列表

链接的(名称,变换)元组的列表(实现拟合/变换),链接的顺序是最后一个对象是一个估计器。

memory:None,str或带有joblib.Memory接口的对象(可选)

用于缓存管道的拟合变压器。默认情况下,不执行缓存。如果给出了一个字符串,它就是缓存目录的路径。在启动缓存之前,启动一个克隆transformer。因此,给管道的transformer实例不能直接检查。使用该属性named_stepssteps检查管道内的估计器。如果fit十分费时,缓存transformers是有利的。

属性:

named_steps:束对象,一个具有属性访问的字典

只读属性根据用户给定的名称访问任何步骤参数。键是步骤名称,值是步骤参数。

方法:

decision_function(X)

Apply transforms, and decision_function of the final estimator

fit(X[, y])

Fit the model

fit_predict(X[, y])

Applies fit_predict of last step in pipeline after transforms.

Fit the model and transform with the final estimator

get_params([deep])

Get parameters for this estimator.

Apply transforms to the data, and predict with the final estimator

Apply transforms, and predict_log_proba of the final estimator

Apply transforms, and predict_proba of the final estimator

score(X[, y, sample_weight])

Apply transforms, and score with the final estimator

set_params(**kwargs)

Set the parameters of this estimator.

例子:

Last updated