sklearn之pipeline:sklearn.pipeline函数使用及其参数解释之详细攻略
sklearn之pipeline:sklearn.pipeline函數(shù)使用及其參數(shù)解釋之詳細(xì)攻略
?
?
目錄
sklearn.pipeline函數(shù)使用及其參數(shù)解釋
?
?
sklearn.pipeline函數(shù)使用及其參數(shù)解釋
| 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 | ? 具有最終估計(jì)器的轉(zhuǎn)換管道。 按順序應(yīng)用一組轉(zhuǎn)換和一個(gè)最終的估計(jì)器。 管道的中間步驟必須是“transforms”,也就是說,它們必須實(shí)現(xiàn)fit和transform方法。 最終的評估器只需要實(shí)現(xiàn)fit。 可以使用“memory”參數(shù)緩存管道中的轉(zhuǎn)換器。 管道的目的是將幾個(gè)可以交叉驗(yàn)證的步驟組裝在一起,同時(shí)設(shè)置不同的參數(shù)。 為此,它允許使用它們的名稱和由“__”分隔的參數(shù)名稱來設(shè)置各個(gè)步驟的參數(shù),如下例所示。 可以通過將參數(shù)的名稱設(shè)置為另一個(gè)估計(jì)器來完全替換步驟的估計(jì)器,或者通過將其設(shè)置為“passthrough”或“None”來刪除轉(zhuǎn)換器。 詳見: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 :列表。(名稱、轉(zhuǎn)換)元組(實(shí)現(xiàn)fit/轉(zhuǎn)換)的列表,按照它們被鏈接的順序,最后一個(gè)對象是評估器。 memory:str或物體與joblib。內(nèi)存接口,默認(rèn)=沒有。用于緩存安裝在管道中的變壓器。默認(rèn)情況下,不執(zhí)行緩存。如果給定一個(gè)字符串,它就是到緩存目錄的路徑。啟用緩存會(huì)在安裝前觸發(fā)變壓器的克隆。因此,給管線的變壓器實(shí)例不能直接檢查。使用屬性' ' named_steps ' ' '或' ' steps ' '檢查管道中的評估器。當(dāng)裝配耗時(shí)時(shí),緩存變壓器是有利的。 verbose :bool,默認(rèn)=False。如果為真,在完成每個(gè)步驟時(shí)所經(jīng)過的時(shí)間將被打印出來。 屬性 ---------- named_steps::類:“~ sklearn.utils.Bunch” 類字典的對象,具有以下屬性。只讀屬性,按用戶名訪問任何步驟參數(shù)。鍵是步驟名稱,值是步驟參數(shù)。 ? 另請參閱 -------- sklearn.pipeline。make_pipeline:簡化管道構(gòu)造的方便函數(shù)。 |
| ????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 | ? |
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
總結(jié)
以上是生活随笔為你收集整理的sklearn之pipeline:sklearn.pipeline函数使用及其参数解释之详细攻略的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 成功解决ModuleNotFoundEr
- 下一篇: sklearn之pipeline:pip