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

Skip to content

Commit 53e2a0c

Browse files
author
Thomas Unterthiner
committed
ENH Refactor scaler code
1 parent 842d80a commit 53e2a0c

File tree

4 files changed

+298
-245
lines changed

4 files changed

+298
-245
lines changed

doc/modules/preprocessing.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,14 @@ This class is hence suitable for use in the early steps of a
7272
:class:`sklearn.pipeline.Pipeline`::
7373

7474
>>> scaler = preprocessing.StandardScaler().fit(X)
75-
>>> scaler
76-
StandardScaler(copy=True, with_mean=True, with_std=True)
75+
>>> scaler # doctest: +NORMALIZE_WHITESPACE
76+
StandardScaler(axis=0, copy=True, with_centering=True, with_mean=None,
77+
with_scaling=True, with_std=None)
7778

78-
>>> scaler.mean_ # doctest: +ELLIPSIS
79+
>>> scaler.center_ # doctest: +ELLIPSIS
7980
array([ 1. ..., 0. ..., 0.33...])
8081

81-
>>> scaler.std_ # doctest: +ELLIPSIS
82+
>>> scaler.scale_ # doctest: +ELLIPSIS
8283
array([ 0.81..., 0.81..., 1.24...])
8384

8485
>>> scaler.transform(X) # doctest: +ELLIPSIS
@@ -94,7 +95,7 @@ same way it did on the training set::
9495
array([[-2.44..., 1.22..., -0.26...]])
9596

9697
It is possible to disable either centering or scaling by either
97-
passing ``with_mean=False`` or ``with_std=False`` to the constructor
98+
passing ``with_centering=False`` or ``with_scaling=False`` to the constructor
9899
of :class:`StandardScaler`.
99100

100101

@@ -132,11 +133,11 @@ applied to be consistent with the transformation performed on the train data::
132133
It is possible to introspect the scaler attributes to find about the exact
133134
nature of the transformation learned on the training data::
134135

135-
>>> min_max_scaler.scale_ # doctest: +ELLIPSIS
136-
array([ 0.5 , 0.5 , 0.33...])
136+
>>> min_max_scaler.scale_ # doctest: +NORMALIZE_WHITESPACE
137+
array([ 2., 2., 3.])
137138

138-
>>> min_max_scaler.min_ # doctest: +ELLIPSIS
139-
array([ 0. , 0.5 , 0.33...])
139+
>>> min_max_scaler.center_ # doctest: +ELLIPSIS
140+
array([ 0., -1., -1.])
140141

141142
If :class:`MinMaxScaler` is given an explicit ``feature_range=(min, max)`` the
142143
full formula is::
@@ -526,6 +527,5 @@ similarly.
526527

527528
Note that if features have very different scaling or statistical
528529
properties, :class:`cluster.FeatureAgglomeration` maye not be able to
529-
capture the links between related features. Using a
530+
capture the links between related features. Using a
530531
:class:`preprocessing.StandardScaler` can be useful in these settings.
531-

sklearn/pipeline.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,11 @@ def make_pipeline(*steps):
237237
--------
238238
>>> from sklearn.naive_bayes import GaussianNB
239239
>>> from sklearn.preprocessing import StandardScaler
240+
>>> from sklearn.pipeline import make_pipeline
240241
>>> make_pipeline(StandardScaler(), GaussianNB()) # doctest: +NORMALIZE_WHITESPACE
241-
Pipeline(steps=[('standardscaler',
242-
StandardScaler(copy=True, with_mean=True, with_std=True)),
243-
('gaussiannb', GaussianNB())])
242+
Pipeline(steps=[('standardscaler', StandardScaler(axis=0, copy=True,
243+
with_centering=True, with_mean=None, with_scaling=True,
244+
with_std=None)), ('gaussiannb', GaussianNB())])
244245
245246
Returns
246247
-------

0 commit comments

Comments
 (0)