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
Show all changes
22 commits
Select commit Hold shift + click to select a range
ce53c81
ENH Add verbose option and corresponding tests for Pipeline.
Mar 9, 2017
c7bbb94
ENH Add verbose option and corresponding tests for FeatureUnion.
Mar 10, 2017
d1353fb
ENH Add _pretty_print method to print from Pipeline properly.
Mar 10, 2017
a981bdc
Add a changelog entry about verbosity of Pipeline.
Mar 10, 2017
3bddca1
Fix bug in pipeline transformer list in-place assignment;
petrushev Sep 1, 2017
ba083b8
Extend `make_pipeline` to support the `verbose` kwarg as well
petrushev Sep 1, 2017
5857d5e
Fix `whats new` to reflect the Pipeline verbose change
petrushev Sep 1, 2017
72f4d0e
Remove `_BasePipeline` resulting from a bad rebase
petrushev Sep 1, 2017
1b7245e
Revert `FeatureUnion.transformer_list` to list instead of sequence
petrushev Sep 1, 2017
3938adc
Extend `FeatureUnion` to support the `verbose` kwarg as well
petrushev Sep 1, 2017
efb4aac
Minor tidy-up
petrushev Sep 3, 2017
2e5b6cc
Add `message_with_time` helper
petrushev Sep 5, 2017
f60eb7b
Merge branch 'master' into verbose-pipeline
jnothman Jan 9, 2018
45f346b
Rewrite verbose pipeline logic
jnothman Jan 9, 2018
3950fb0
Test logging utils
jnothman Jan 9, 2018
6807457
Param docstring
jnothman Jan 9, 2018
badf235
pytest<3.3 does return namedtuples
jnothman Jan 16, 2018
7de5ed8
Don't forcefully adjust timing on Windows as joblib does
jnothman Jan 16, 2018
5dce7c1
Need some __future__
jnothman Feb 11, 2018
b8c56d8
Rm unused import
jnothman Feb 13, 2018
57edbfa
Merge branch 'master' into verbose-pipeline
jnothman Apr 2, 2018
2caef80
Merge branch 'master' into verbose-pipeline
jnothman May 25, 2018
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
20 changes: 12 additions & 8 deletions doc/modules/compose.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,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 @@ -72,7 +72,8 @@ 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 @@ -92,7 +93,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 @@ -170,7 +172,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)
>>> # Clear the cache directory when you don't need it anymore
>>> rmtree(cachedir)

Expand All @@ -187,7 +189,8 @@ 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 @@ -209,7 +212,8 @@ 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 @@ -337,7 +341,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 @@ -352,7 +356,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
6 changes: 6 additions & 0 deletions doc/whats_new/v0.20.rst
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,12 @@ Model evaluation and meta-estimators
group-based CV strategies. :issue:`9085` by :user:`Laurent Direr <ldirer>`
and `Andreas Müller`_.

- Added optional parameter ``verbose`` in :class:`pipeline.Pipeline` and
:class:`pipeline.FeatureUnion` and corresponding ``make_`` helpers for
showing progress and timing of each step. :issue:`9668` by :user:`Baze
Petrushev <petrushev>`, :user:`Karan Desai <karandesai-96>` and `Joel
Nothman`_.

- The ``predict`` method of :class:`pipeline.Pipeline` now passes keyword
arguments on to the pipeline's last estimator, enabling the use of parameters
such as ``return_std`` in a pipeline with caution.
Expand Down
8 changes: 4 additions & 4 deletions sklearn/model_selection/_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
import scipy.sparse as sp

from ..base import is_classifier, clone
from ..utils import indexable, check_random_state, safe_indexing
from ..utils import (indexable, check_random_state, safe_indexing,
message_with_time)
from ..utils.deprecation import DeprecationDict
from ..utils.validation import _is_arraylike, _num_samples
from ..utils.metaestimators import _safe_split
from ..externals.joblib import Parallel, delayed, logger
from ..externals.joblib import Parallel, delayed
from ..externals.six.moves import zip
from ..metrics.scorer import check_scoring, _check_multimetric_scoring
from ..exceptions import FitFailedWarning
Expand Down Expand Up @@ -538,8 +539,7 @@ def _fit_and_score(estimator, X, y, scorer, train, test, verbose,
msg += ", score=%s" % test_scores
if verbose > 1:
total_time = score_time + fit_time
end_msg = "%s, total=%s" % (msg, logger.short_format_time(total_time))
print("[CV] %s %s" % ((64 - len(end_msg)) * '.', end_msg))
print(message_with_time('CV', msg, total_time))

ret = [train_scores, test_scores] if return_train_score else [test_scores]

Expand Down
Loading