class sklearn.pipeline.Pipeline(steps, memory=None, verbose=False)
带有最终评估量的转换流程。
循序的运用一些列转换和一个最终评估量。Pipeline的中间步骤必须是’transforms’,就是说,他们必须实现fit、transform方法。最终评估量只需要执行fit。流程中的转换方法可以用memory
参数暂存。
pipeline的目的是集成几个步骤,以便设定不同参数进行交叉验证。为了实现这个目标,设置不同步骤的参数和参数名用“_”分来。
一个步骤的评估量可通过设置参数成它的name来替换另一个评估量。或者一个转换步骤可以通过设置‘passthrough
’ or None
来取消掉。
Parameters | 数据类型 | 意义 |
---|---|---|
steps | list | 一些列需要成链的过程,最后是评估量 |
memory | None, str or object with the joblib.Memory interface, optional | 用于缓存流程中的待拟合转换过程 |
verbose | boolean, optional | True:每步完成后消耗的时间会被print |
Attributes | 意义 |
---|---|
named_steps | 查看步骤参数,keys是step name,values是step parameters |
Methods | 意义 |
---|---|
decision_function (self, X) | Apply transforms, and decision_function of the final estimator |
fit (self, X[, y]) | Fit the model |
fit_predict (self, X[, y]) | Applies fit_predict of last step in pipeline after transforms. |
fit_transform (self, X[, y]) | Fit the model and transform with the final estimator |
get_params (self[, deep]) | Get parameters for this estimator. |
predict (self, X, **predict_params) | Apply transforms to the data, and predict with the final estimator |
predict_log_proba (self, X) | Apply transforms, and predict_log_proba of the final estimator |
predict_proba (self, X) | Apply transforms, and predict_proba of the final estimator |
score (self, X[, y, sample_weight]) | Apply transforms, and score with the final estimator |
set_params (self, **kwargs) | Set the parameters of this estimator. |
这篇翻译的更好:《sklearn 中的 Pipeline 机制》