bach.DataFrame.scale
scale
(with_mean=True, with_std=True)Standardizes all numeric series based on mean and population standard deviation.
Parameters
with_mean
(bool) – if true, each feature value will be centered before scalingwith_std
(bool) – if true, each feature value will be scaled to unit variance
Returns
DataFrame
Return type
Each transformation per feature is performed as follows:
In:
feature.to_pandas()
Out:
index
a 1
b 2
c 3
d 4
Name: feature, dtype: int64
>>> scaled_feature = feature.copy()
>>> if with_mean:
... scaled_feature -= mean_feature
>>> if with_std:
... scaled_feature /= std_feature
>>> scaled_feature.to_pandas()
index
a -1.341641
b -0.447214
c 0.447214
d 1.341641
Name: feature, dtype: float64
Where:
feature
is the series to be scaledmean_feature
is the mean offeature
std_feature
is the (population-based) standard deviation offeature