sklearn之pipeline:sklearn.pipeline函数使用及其参数解释之详细攻略
sklearn之pipeline:sklearn.pipeline函數使用及其參數解釋之詳細攻略
?
?
目錄
sklearn.pipeline函數使用及其參數解釋
?
?
sklearn.pipeline函數使用及其參數解釋
| 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 | ? 具有最終估計器的轉換管道。 按順序應用一組轉換和一個最終的估計器。 管道的中間步驟必須是“transforms”,也就是說,它們必須實現fit和transform方法。 最終的評估器只需要實現fit。 可以使用“memory”參數緩存管道中的轉換器。 管道的目的是將幾個可以交叉驗證的步驟組裝在一起,同時設置不同的參數。 為此,它允許使用它們的名稱和由“__”分隔的參數名稱來設置各個步驟的參數,如下例所示。 可以通過將參數的名稱設置為另一個估計器來完全替換步驟的估計器,或者通過將其設置為“passthrough”或“None”來刪除轉換器。 詳見:ref: ' User Guide ?'。</pipeline> . .versionadded:: 0.5 |
| ????Parameters ????---------- ????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. ????Attributes ????---------- ????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” 類字典的對象,具有以下屬性。只讀屬性,按用戶名訪問任何步驟參數。鍵是步驟名稱,值是步驟參數。 ? 另請參閱 -------- sklearn.pipeline。make_pipeline:簡化管道構造的方便函數。 |
| ????Examples ????-------- ????>>> 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 ????>>> pipe.fit(X_train, y_train) ????Pipeline(steps=[('scaler', StandardScaler()), ('svc', SVC())]) ????>>> pipe.score(X_test, y_test) ????0.88 | ? |
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
總結
以上是生活随笔為你收集整理的sklearn之pipeline:sklearn.pipeline函数使用及其参数解释之详细攻略的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 成功解决ModuleNotFoundEr
- 下一篇: sklearn之pipeline:pip