class Pipeline(_BaseComposition):


    Pipeline of transforms with a final estimator.

    Sequentially apply a list of transforms and a final estimator.

    Intermediate steps of the pipeline must be 'transforms', that is, they must implement fit and transform methods.

    The final estimator only needs to implement fit.

    The transformers in the pipeline can be cached using ``memory`` argument.

The purpose of the pipeline is to assemble several steps that can be cross-validated together while setting different parameters.

    For this, it enables setting parameters of the various steps using their  names and the parameter name separated by a '__', as in the example below.

    A step's estimator may be replaced entirely by setting the parameter with its name to another estimator, or a transformer removed by setting  it to 'passthrough' or ``None``.

    Read more in the :ref:`User Guide pipeline`.

    .. versionadded:: 0.5










详见:ref: ' User Guide  '。/pipeline

. .versionadded:: 0.5



    steps : list. List of (name, transform) tuples (implementing fit/transform) that are chained, in the order in which they are chained, with the last object an estimator.

    memory : str or object with the joblib.Memory interface, default=None. Used to cache the fitted transformers of the pipeline. By default, no caching is performed. If a string is given, it is the path to the caching directory. Enabling caching triggers a clone of the transformers before fitting. Therefore, the transformer instance given to the pipeline cannot be inspected directly. Use the attribute ``named_steps`` or ``steps`` to inspect estimators within the pipeline. Caching the transformers is advantageous when fitting is time consuming.

    verbose : bool, default=False. If True, the time elapsed while fitting each step will be printed as it is completed.



    named_steps: :class:`~sklearn.utils.Bunch`

    Dictionary-like object, with the following attributes. Read-only attribute to access any step parameter by user given name. Keys are step names and values are steps parameters.


    See Also


    sklearn.pipeline.make_pipeline : Convenience function for simplified pipeline construction.



steps :列表。(名称、转换)元组(实现fit/转换)的列表,按照它们被链接的顺序,最后一个对象是评估器。

memory:str或物体与joblib。内存接口,默认=没有。用于缓存安装在管道中的变压器。默认情况下,不执行缓存。如果给定一个字符串,它就是到缓存目录的路径。启用缓存会在安装前触发变压器的克隆。因此,给管线的变压器实例不能直接检查。使用属性' ' named_steps ' ' '或' ' steps ' '检查管道中的评估器。当装配耗时时,缓存变压器是有利的。

verbose :bool,默认=False。如果为真,在完成每个步骤时所经过的时间将被打印出来。



named_steps::类:~ sklearn.utils.Bunch








     from sklearn.svm import SVC

     from sklearn.preprocessing import StandardScaler

     from sklearn.datasets import make_classification

     from sklearn.model_selection import train_test_split

     from sklearn.pipeline import Pipeline

     X, y = make_classification(random_state=0)

     X_train, X_test, y_train, y_test = train_test_split(X, y,

    ...                                                     random_state=0)

     pipe = Pipeline([('scaler', StandardScaler()), ('svc', SVC())])

     # The pipeline can be used as any other estimator

     # and avoids leaking the test set into the train set, y_train)

    Pipeline(steps=[('scaler', StandardScaler()), ('svc', SVC())])

     pipe.score(X_test, y_test)



















8 简首页