MCPcopy Create free account
hub / github.com/scikit-learn/scikit-learn / MinMaxScaler

Class MinMaxScaler

sklearn/preprocessing/_data.py:305–621  ·  view source on GitHub ↗

Transform features by scaling each feature to a given range. This estimator scales and translates each feature individually such that it is in the given range on the training set, e.g. between zero and one. The transformation is given by:: X_std = (X - X.min(axis=0)) / (X.

Source from the content-addressed store, hash-verified

303
304
305class MinMaxScaler(OneToOneFeatureMixin, TransformerMixin, BaseEstimator):
306 """Transform features by scaling each feature to a given range.
307
308 This estimator scales and translates each feature individually such
309 that it is in the given range on the training set, e.g. between
310 zero and one.
311
312 The transformation is given by::
313
314 X_std = (X - X.min(axis=0)) / (X.max(axis=0) - X.min(axis=0))
315 X_scaled = X_std * (max - min) + min
316
317 where min, max = feature_range.
318
319 This transformation is often used as an alternative to zero mean,
320 unit variance scaling.
321
322 `MinMaxScaler` doesn't reduce the effect of outliers, but it linearly
323 scales them down into a fixed range, where the largest occurring data point
324 corresponds to the maximum value and the smallest one corresponds to the
325 minimum value. For an example visualization, refer to :ref:`Compare
326 MinMaxScaler with other scalers <plot_all_scaling_minmax_scaler_section>`.
327
328 Read more in the :ref:`User Guide <preprocessing_scaler>`.
329
330 Parameters
331 ----------
332 feature_range : tuple (min, max), default=(0, 1)
333 Desired range of transformed data.
334
335 copy : bool, default=True
336 Set to False to perform inplace row normalization and avoid a
337 copy (if the input is already a numpy array).
338
339 clip : bool, default=False
340 Set to True to clip transformed values of held-out data to
341 provided `feature_range`.
342 Since this parameter will clip values, `inverse_transform` may not
343 be able to restore the original data.
344
345 .. note::
346 Setting `clip=True` does not prevent feature drift (a distribution
347 shift between training and test data). The transformed values are clipped
348 to the `feature_range`, which helps avoid unintended behavior in models
349 sensitive to out-of-range inputs (e.g. linear models). Use with care,
350 as clipping can distort the distribution of test data.
351
352 .. versionadded:: 0.24
353
354 Attributes
355 ----------
356 min_ : ndarray of shape (n_features,)
357 Per feature adjustment for minimum. Equivalent to
358 ``min - X.min(axis=0) * self.scale_``
359
360 scale_ : ndarray of shape (n_features,)
361 Per feature relative scaling of the data. Equivalent to
362 ``(max - min) / (X.max(axis=0) - X.min(axis=0))``

Callers 15

test_mlp.pyFile · 0.90
test_min_max_scaler_irisFunction · 0.90
test_min_max_scaler_1dFunction · 0.90
test_fit_cold_startFunction · 0.90
test_minmax_scaler_clipFunction · 0.90
fitMethod · 0.90
test_common.pyFile · 0.90

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…