2828The :class: `Pipeline ` is build using a list of ``(key, value) `` pairs, where
2929the ``key `` a string containing the name you want to give this step and ``value ``
3030is an estimator object::
31+
3132 >>> from sklearn.pipeline import Pipeline
3233 >>> from sklearn.svm import SVC
3334 >>> from sklearn.decomposition import PCA
@@ -40,21 +41,25 @@ is an estimator object::
4041 shrinking=True, tol=0.001, verbose=False))])
4142
4243The estimators of the pipeline are stored as a list in the ``steps `` attribute::
44+
4345 >>> clf.steps[0]
4446 ('reduce_dim', PCA(copy=True, n_components=None, whiten=False))
4547
4648and as a ``dict `` in ``named_steps ``::
49+
4750 >>> clf.named_steps['reduce_dim']
4851 PCA(copy=True, n_components=None, whiten=False)
4952
5053Parameters of the estimators in the pipeline can be accessed using the
5154``<estimator>__<parameter> `` syntax::
55+
5256 >>> clf.set_params(svm__C=10) # NORMALIZE_WHITESPACE
5357 Pipeline(steps=[('reduce_dim', PCA(copy=True, n_components=None, whiten=False)), ('svm', SVC(C=10, cache_size=200, class_weight=None, coef0=0.0, degree=3, gamma=0.0,
5458 kernel='rbf', probability=False, shrinking=True, tol=0.001,
5559 verbose=False))])
5660
5761This is particularly important for doing grid searches::
62+
5863 >>> from sklearn.grid_search import GridSearchCV
5964 >>> params = dict(reduce_dim__n_components=[2, 5, 10],
6065 ... svm__C=[0.1, 10, 100])
0 commit comments