Skip to content

Commit a028416

Browse files
tuliocasagrandeqinhanmin2014
authored andcommitted
DOC Add details to StandardScaler calculation (#12446)
1 parent 036dfdd commit a028416

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

sklearn/preprocessing/data.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,14 @@ def minmax_scale(X, feature_range=(0, 1), axis=0, copy=True):
480480
class StandardScaler(BaseEstimator, TransformerMixin):
481481
"""Standardize features by removing the mean and scaling to unit variance
482482
483+
The standard score of a sample `x` is calculated as:
484+
485+
z = (x - u) / s
486+
487+
where `u` is the mean of the training samples or zero if `with_mean=False`,
488+
and `s` is the standard deviation of the training samples or one if
489+
`with_std=False`.
490+
483491
Centering and scaling happen independently on each feature by computing
484492
the relevant statistics on the samples in the training set. Mean and
485493
standard deviation are then stored to be used on later data using the
@@ -525,8 +533,8 @@ class StandardScaler(BaseEstimator, TransformerMixin):
525533
Attributes
526534
----------
527535
scale_ : ndarray or None, shape (n_features,)
528-
Per feature relative scaling of the data. Equal to ``None`` when
529-
``with_std=False``.
536+
Per feature relative scaling of the data. This is calculated using
537+
`np.sqrt(var_)`. Equal to ``None`` when ``with_std=False``.
530538
531539
.. versionadded:: 0.17
532540
*scale_*

0 commit comments

Comments
 (0)