Standard Scaler¶
Standardize features by removing the mean and scaling to unit variance.
Centering and scaling happen independently on each feature by computing the relevant statistics on the samples in the training set. Mean and standard deviation are then stored to be used on later data using the transform method. Standardization of a dataset is a common requirement for many machine learning estimators: they might behave badly if the individual feature do not more or less look like standard normally distributed data (e.g. Gaussian with 0 mean and unit variance).
Documentation¶
Attributes¶
- mean_
The mean value for each feature in the training set. Equal to
None
whenwith_mean=False
andwith_std=False
.- n_samples_seen_
The number of samples processed by the estimator for each feature. If there are no missing samples, the
n_samples_seen
will be an integer, otherwise it will be an array of dtype int. If sample_weights are used it will be a float (if no missing data) or an array of dtype float that sums the weights seen so far. Will be reset on new calls to fit, but increments acrosspartial_fit
calls.- scale_
Per feature relative scaling of the data to achieve zero mean and unit variance. Generally this is calculated using np.sqrt(var_). If a variance is zero, we can’t achieve unit variance, and the data is left as-is, giving a scaling factor of 1. scale_ is equal to None when with_std=False.
Added in version 0.17: scale_
- var_
The variance for each feature in the training set. Used to compute scale_. Equal to
None
whenwith_mean=False
andwith_std=False
.
Definition¶
Output ports¶
- model model
Model
Configuration¶
- Center the data before scaling (with_mean)
If True, center the data before scaling. This does not work (and will raise an exception) when attempted on sparse matrices, because centering them entails building a dense matrix which in common use cases is likely to be too large to fit in memory.
- Scale to unit variance (with_std)
If True, scale the data to unit variance (or equivalently, unit standard deviation).
Implementation¶
- class node_preprocessing.StandardScaler[source]