Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions doc/modules/pipeline.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ is an estimator object::
>>> pipe # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS
Pipeline(memory=None,
steps=[('reduce_dim', PCA(copy=True,...)),
('clf', SVC(C=1.0,...))])
('clf', SVC(C=1.0,...))], verbose=False)

The utility function :func:`make_pipeline` is a shorthand
for constructing pipelines;
Expand All @@ -57,7 +57,7 @@ filling in the names automatically::
steps=[('binarizer', Binarizer(copy=True, threshold=0.0)),
('multinomialnb', MultinomialNB(alpha=1.0,
class_prior=None,
fit_prior=True))])
fit_prior=True))], verbose=False)

The estimators of a pipeline are stored as a list in the ``steps`` attribute::

Expand All @@ -77,7 +77,8 @@ Parameters of the estimators in the pipeline can be accessed using the
>>> pipe.set_params(clf__C=10) # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS
Pipeline(memory=None,
steps=[('reduce_dim', PCA(copy=True, iterated_power='auto',...)),
('clf', SVC(C=10, cache_size=200, class_weight=None,...))])
('clf', SVC(C=10, cache_size=200, class_weight=None,...))],
verbose=False)

Attributes of named_steps map to keys, enabling tab completion in interactive environments::

Expand Down Expand Up @@ -153,7 +154,7 @@ object::
>>> pipe # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS
Pipeline(...,
steps=[('reduce_dim', PCA(copy=True,...)),
('clf', SVC(C=1.0,...))])
('clf', SVC(C=1.0,...))], verbose=False)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is an irrelevant detail, maybe use ellipsis? (...)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I'm ambiguous on this...)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well then i'll wait for others' suggestion meanwhile. I'm not sure which should be preferred either.

@kdexd kdexd Mar 13, 2017

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we set an analogy, transformer_weights are shown here in same documentation. They're not having any value in this particular example.

>>> estimators = [('linear_pca', PCA()), ('kernel_pca', KernelPCA())]
>>> combined = FeatureUnion(estimators)
>>> combined # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS
FeatureUnion(n_jobs=1,
             transformer_list=[('linear_pca', PCA(copy=True,...)),
                               ('kernel_pca', KernelPCA(alpha=1.0,...))],
             transformer_weights=None, verbose=False)

We can use this as a tie breaker 😆

>>> # Clear the cache directory when you don't need it anymore
>>> rmtree(cachedir)

Expand All @@ -170,7 +171,7 @@ object::
>>> pipe.fit(digits.data, digits.target)
... # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS
Pipeline(memory=None,
steps=[('reduce_dim', PCA(...)), ('clf', SVC(...))])
steps=[('reduce_dim', PCA(...)), ('clf', SVC(...))], verbose=False)
>>> # The pca instance can be inspected directly
>>> print(pca1.components_) # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS
[[ -1.77484909e-19 ... 4.07058917e-18]]
Expand All @@ -192,7 +193,7 @@ object::
>>> cached_pipe.fit(digits.data, digits.target)
... # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS
Pipeline(memory=...,
steps=[('reduce_dim', PCA(...)), ('clf', SVC(...))])
steps=[('reduce_dim', PCA(...)), ('clf', SVC(...))], verbose=False)
>>> print(cached_pipe.named_steps['reduce_dim'].components_)
... # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS
[[ -1.77484909e-19 ... 4.07058917e-18]]
Expand Down Expand Up @@ -246,7 +247,7 @@ and ``value`` is an estimator object::
FeatureUnion(n_jobs=1,
transformer_list=[('linear_pca', PCA(copy=True,...)),
('kernel_pca', KernelPCA(alpha=1.0,...))],
transformer_weights=None)
transformer_weights=None, verbose=False)


Like pipelines, feature unions have a shorthand constructor called
Expand All @@ -261,7 +262,7 @@ and ignored by setting to ``None``::
FeatureUnion(n_jobs=1,
transformer_list=[('linear_pca', PCA(copy=True,...)),
('kernel_pca', None)],
transformer_weights=None)
transformer_weights=None, verbose=False)

.. topic:: Examples:

Expand Down
8 changes: 7 additions & 1 deletion doc/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ New features
Enhancements
............

- Added optional parameter ``verbose`` in :class:`pipeline.Pipeline` and
:class:`pipeline.FeatureUnion` for showing progress and timing of each
step. :issue:`8568` by :user:`Karan Desai <karandesai-96>`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add your name and link to the bottom of the page :)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done ✅


- Update Sphinx-Gallery from 0.1.4 to 0.1.7 for resolving links in
documentation build with Sphinx>1.5 :issue:`8010`, :issue:`7986`
:user:`Oscar Najera <Titan-C>`
Expand Down Expand Up @@ -5059,4 +5063,6 @@ David Huard, Dave Morrill, Ed Schofield, Travis Oliphant, Pearu Peterson.
.. _Anish Shah: https://github.com/AnishShah

.. _Neeraj Gangwar: http://neerajgangwar.in
.. _Arthur Mensch: https://amensch.fr
.. _Arthur Mensch: https://amensch.fr

.. _Karan Desai: https://www.github.com/karandesai-96
Loading