Skip to content

Commit c0a0578

Browse files
committed
ENH rename Scaler to StandardScaler everywhere
1 parent 485854a commit c0a0578

File tree

14 files changed

+42
-44
lines changed

14 files changed

+42
-44
lines changed

doc/developers/utilities.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ efficiently process ``scipy.sparse`` data.
144144
- :func:`sparsefuncs.inplace_csr_column_scale`: can be used to multiply the
145145
columns of a CSR matrix by a constant scale (one scale per column).
146146
Used for scaling features to unit standard deviation in
147-
:class:`sklearn.preprocessing.Scaler`.
147+
:class:`sklearn.preprocessing.StandardScaler`.
148148

149149

150150
Graph Routines

doc/modules/classes.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -836,12 +836,13 @@ Pairwise metrics
836836
:toctree: generated/
837837
:template: class.rst
838838

839-
preprocessing.Scaler
840-
preprocessing.Normalizer
841839
preprocessing.Binarizer
840+
preprocessing.KernelCenterer
842841
preprocessing.LabelBinarizer
843842
preprocessing.LabelEncoder
844-
preprocessing.KernelCenterer
843+
preprocessing.MinMaxScaler
844+
preprocessing.Normalizer
845+
preprocessing.StandardScaler
845846

846847
.. autosummary::
847848
:toctree: generated/

doc/modules/manifold.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ Tips on practical use
427427

428428
* Make sure the same scale is used over all features. Because manifold
429429
learning methods are based on a nearest-neighbor search, the algorithm
430-
may perform poorly otherwise. See :ref:`Scaler <preprocessing_scaler>`
430+
may perform poorly otherwise. See :ref:`StandardScaler <preprocessing_scaler>`
431431
for convenient ways of scaling heterogeneous data.
432432

433433
* The reconstruction error computed by each routine can be used to choose

doc/modules/preprocessing.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ Scaled data has zero mean and unit variance::
6464
.. >>> print_options = np.set_printoptions(print_options)
6565
6666
The ``preprocessing`` module further provides a utility class
67-
:class:`Scaler` that implements the ``Transformer`` API to compute
67+
:class:`StandardScaler` that implements the ``Transformer`` API to compute
6868
the mean and standard deviation on a training set so as to be
6969
able to later reapply the same transformation on the testing set.
7070
This class is hence suitable for use in the early steps of a
7171
:class:`sklearn.pipeline.Pipeline`::
7272

73-
>>> scaler = preprocessing.Scaler().fit(X)
73+
>>> scaler = preprocessing.StandardScaler().fit(X)
7474
>>> scaler
75-
Scaler(copy=True, with_mean=True, with_std=True)
75+
StandardScaler(copy=True, with_mean=True, with_std=True)
7676

7777
>>> scaler.mean_ # doctest: +ELLIPSIS
7878
array([ 1. ..., 0. ..., 0.33...])
@@ -94,7 +94,7 @@ same way it did on the training set::
9494

9595
It is possible to disable either centering or scaling by either
9696
passing ``with_mean=False`` or ``with_std=False`` to the constructor
97-
of :class:`Scaler`.
97+
of :class:`StandardScaler`.
9898

9999

100100
.. topic:: References:
@@ -115,7 +115,7 @@ of :class:`Scaler`.
115115

116116
.. topic:: Sparse input
117117

118-
:func:`scale` and :class:`Scaler` accept ``scipy.sparse`` matrices
118+
:func:`scale` and :class:`StandardScaler` accept ``scipy.sparse`` matrices
119119
as input **only when with_mean=False is explicitly passed to the
120120
constructor**. Otherwise a ``ValueError`` will be raised as
121121
silently centering would break the sparsity and would often crash the
@@ -132,7 +132,7 @@ of :class:`Scaler`.
132132

133133
.. topic:: Scaling target variables in regression
134134

135-
:func:`scale` and :class:`Scaler` work out-of-the-box with 1d arrays.
135+
:func:`scale` and :class:`StandardScaler` work out-of-the-box with 1d arrays.
136136
This is very useful for scaling the target / response variables used
137137
for regression.
138138

@@ -243,7 +243,7 @@ It is possible to adjust the threshold of the binarizer::
243243
[ 1., 0., 0.],
244244
[ 0., 0., 0.]])
245245

246-
As for the :class:`Scaler` and :class:`Normalizer` classes, the
246+
As for the :class:`StandardScaler` and :class:`Normalizer` classes, the
247247
preprocessing module provides a companion function :func:`binarize`
248248
to be used when the transformer API is not necessary.
249249

doc/modules/sgd.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,10 @@ Tips on Practical Use
229229
attribute on the input vector X to [0,1] or [-1,+1], or standardize
230230
it to have mean 0 and variance 1. Note that the *same* scaling
231231
must be applied to the test vector to obtain meaningful
232-
results. This can be easily done using :class:`Scaler`::
232+
results. This can be easily done using :class:`StandardScaler`::
233233

234-
from sklearn.preprocessing import Scaler
235-
scaler = Scaler()
234+
from sklearn.preprocessing import StandardScaler
235+
scaler = StandardScaler()
236236
scaler.fit(X_train) # Don't cheat - fit only on training data
237237
X_train = scaler.transform(X_train)
238238
X_test = scaler.transform(X_test) # apply same transformation to test data

examples/cluster/plot_cluster_comparison.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from sklearn import cluster, datasets
3131
from sklearn.metrics import euclidean_distances
3232
from sklearn.neighbors import kneighbors_graph
33-
from sklearn.preprocessing import Scaler
33+
from sklearn.preprocessing import StandardScaler
3434

3535
np.random.seed(0)
3636

@@ -55,7 +55,7 @@
5555
no_structure]):
5656
X, y = dataset
5757
# normalize dataset for easier parameter selection
58-
X = Scaler().fit_transform(X)
58+
X = StandardScaler().fit_transform(X)
5959

6060
# estimate bandwidth for mean shift
6161
bandwidth = cluster.estimate_bandwidth(X, quantile=0.3)

examples/linear_model/plot_logistic_l1_l2_sparsity.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525

2626
from sklearn.linear_model import LogisticRegression
2727
from sklearn import datasets
28-
from sklearn.preprocessing import Scaler
28+
from sklearn.preprocessing import StandardScaler
2929

3030
digits = datasets.load_digits()
3131

3232
X, y = digits.data, digits.target
33-
X = Scaler().fit_transform(X)
33+
X = StandardScaler().fit_transform(X)
3434

3535
# classify small against large digits
3636
y = (y > 4).astype(np.int)

examples/linear_model/plot_sparse_recovery.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
from sklearn.linear_model import RandomizedLasso, lasso_stability_path, \
5151
LassoLarsCV
5252
from sklearn.feature_selection import f_regression
53-
from sklearn.preprocessing import Scaler
53+
from sklearn.preprocessing import StandardScaler
5454
from sklearn.metrics import auc, precision_recall_curve
5555
from sklearn.ensemble import ExtraTreesRegressor
5656
from sklearn.utils.extmath import pinvh
@@ -97,7 +97,7 @@ def mutual_incoherence(X_relevant, X_irelevant):
9797
# Keep [Wainwright2006] (26c) constant
9898
X[:n_relevant_features] /= np.abs(
9999
linalg.svdvals(X[:n_relevant_features])).max()
100-
X = Scaler().fit_transform(X.copy())
100+
X = StandardScaler().fit_transform(X.copy())
101101

102102
# The output variable
103103
y = np.dot(X, coef)

examples/svm/plot_rbf_parameters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import pylab as pl
2626

2727
from sklearn.svm import SVC
28-
from sklearn.preprocessing import Scaler
28+
from sklearn.preprocessing import StandardScaler
2929
from sklearn.datasets import load_iris
3030
from sklearn.cross_validation import StratifiedKFold
3131
from sklearn.grid_search import GridSearchCV
@@ -49,7 +49,7 @@
4949
# instead of fitting the transformation on the training set and
5050
# just applying it on the test set.
5151

52-
scaler = Scaler()
52+
scaler = StandardScaler()
5353

5454
X = scaler.fit_transform(X)
5555
X_2d = scaler.fit_transform(X_2d)

sklearn/cluster/_k_means.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def csr_row_norm_l2(X, squared=True):
243243
"""Get L2 norm of each row in CSR matrix X.
244244
245245
TODO: refactor me in the sklearn.utils.sparsefuncs module once the CSR
246-
sklearn.preprocessing.Scaler has been refactored as well.
246+
sklearn.preprocessing.StandardScaler has been refactored as well.
247247
"""
248248
cdef:
249249
unsigned int n_samples = X.shape[0]

0 commit comments

Comments
 (0)