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

Class MaxAbsScaler

sklearn/preprocessing/_data.py:1190–1448  ·  view source on GitHub ↗

Scale each feature by its maximum absolute value. This estimator scales and translates each feature individually such that the maximal absolute value of each feature in the training set will be 1.0. It does not shift/center the data, and thus does not destroy any sparsity. This

Source from the content-addressed store, hash-verified

1188
1189
1190class MaxAbsScaler(OneToOneFeatureMixin, TransformerMixin, BaseEstimator):
1191 """Scale each feature by its maximum absolute value.
1192
1193 This estimator scales and translates each feature individually such
1194 that the maximal absolute value of each feature in the
1195 training set will be 1.0. It does not shift/center the data, and
1196 thus does not destroy any sparsity.
1197
1198 This scaler can also be applied to sparse CSR or CSC matrices.
1199
1200 `MaxAbsScaler` doesn't reduce the effect of outliers; it only linearly
1201 scales them down. For an example visualization, refer to :ref:`Compare
1202 MaxAbsScaler with other scalers <plot_all_scaling_max_abs_scaler_section>`.
1203
1204 .. versionadded:: 0.17
1205
1206 Parameters
1207 ----------
1208 copy : bool, default=True
1209 Set to False to perform inplace scaling and avoid a copy (if the input
1210 is already a numpy array).
1211
1212 clip : bool, default=False
1213 Set to True to clip transformed values of held-out data to [-1, 1].
1214 Since this parameter will clip values, `inverse_transform` may not
1215 be able to restore the original data.
1216
1217 .. note::
1218 Setting `clip=True` does not prevent feature drift (a distribution
1219 shift between training and test data). The transformed values are clipped
1220 to the [-1, 1] range, which helps avoid unintended behavior in models
1221 sensitive to out-of-range inputs (e.g. linear models). Use with care,
1222 as clipping can distort the distribution of test data.
1223
1224 Attributes
1225 ----------
1226 scale_ : ndarray of shape (n_features,)
1227 Per feature relative scaling of the data.
1228
1229 .. versionadded:: 0.17
1230 *scale_* attribute.
1231
1232 max_abs_ : ndarray of shape (n_features,)
1233 Per feature maximum absolute value.
1234
1235 n_features_in_ : int
1236 Number of features seen during :term:`fit`.
1237
1238 .. versionadded:: 0.24
1239
1240 feature_names_in_ : ndarray of shape (`n_features_in_`,)
1241 Names of features seen during :term:`fit`. Defined only when `X`
1242 has feature names that are all strings.
1243
1244 .. versionadded:: 1.0
1245
1246 n_samples_seen_ : int
1247 The number of samples processed by the estimator. Will be reset on

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…