8000 DOC More details about the attributes in MinMaxScaler (#13029) · scikit-learn/scikit-learn@31cef3b · GitHub
[go: up one dir, main page]

Skip to content

Commit 31cef3b

Browse files
qinhanmin2014jnothman
authored andcommitted
DOC More details about the attributes in MinMaxScaler (#13029)
1 parent 5fc5c6e commit 31cef3b

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

sklearn/preprocessing/data.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,11 @@ class MinMaxScaler(BaseEstimator, TransformerMixin):
210210
211211
where min, max = feature_range.
212212
213+
The transformation is calculated as::
214+
215+
X_scaled = scale * X + min - X.min(axis=0) * scale
216+
where scale = (max - min) / (X.max(axis=0) - X.min(axis=0))
217+
213218
This transformation is often used as an alternative to zero mean,
214219
unit variance scaling.
215220
@@ -227,10 +232,12 @@ class MinMaxScaler(BaseEstimator, TransformerMixin):
227232
Attributes
228233
----------
229234
min_ : ndarray, shape (n_features,)
230-
Per feature adjustment for minimum.
235+
Per feature adjustment for minimum. Equivalent to
236+
``min - X.min(axis=0) * self.scale_``
231237
232238
scale_ : ndarray, shape (n_features,)
233-
Per feature relative scaling of the data.
239+
Per feature relative scaling of the data. Equivalent to
240+
``(max - min) / (X.max(axis=0) - X.min(axis=0))``
234241
235242
.. versionadded:: 0.17
236243
*scale_* attribute.
@@ -409,12 +416,17 @@ def minmax_scale(X, feature_range=(0, 1), axis=0, copy=True):
409416
that it is in the given range on the training set, i.e. between
410417
zero and one.
411418
412-
The transformation is given by::
419+
The transformation is given by (when ``axis=0``)::
413420
414421
X_std = (X - X.min(axis=0)) / (X.max(axis=0) - X.min(axis=0))
415422
X_scaled = X_std * (max - min) + min
416423
417424
where min, max = feature_range.
425+
426+
The transformation is calculated as (when ``axis=0``)::
427+
428+
X_scaled = scale * X + min - X.min(axis=0) * scale
429+
where scale = (max - min) / (X.max(axis=0) - X.min(axis=0))
418430
419431
This transformation is often used as an alternative to zero mean,
420432
unit variance scaling.

0 commit comments

Comments
 (0)
0