sklearn
Python open source framework for machine learning.
sklearn official website
sklearn Chinese network
sklearn.preprocessing.StandardScaler
The features are normalized by removing the mean and scaling to unit variance.
The formula is as follows:
$ z = \ frac {x- \ mu} {\ sigma} $
where $ \ mu $ is the average value of the training sample and $ \ sigma $ is the standard deviation of the training sample.
from sklearn.preprocessing import StandardScaler
StandardScaler(copy=True, with_mean=True, with_std=True)
- Parameters:
copy : Boolean value, the default is True.
If it is False, it will be scaled in place and no new object will be generated.
with_mean : Boolean value, the default is True.
If True, try to center the data before scaling.
with_std : Boolean value, the default is True.
If True, the data is scaled to unit variance.
- Attributes:
scale_ : ndarray or None
The relative scale of each feature data.
mean_ : ndarray or None
The average value of each feature in the training set.
var_ : ndarray of None
The variance of each feature in the training set.
n_samples_seen_ : int or array
is the number of samples processed for each feature. If there is no missing value, it is an integer, otherwise it is an array.
- Method :
fit (self, X, y = None)
calculate the mean and std for later scaling.
fit_transform (self, X, y = None, ** fit_params)
calculate the mean and std, and then transform it
Parameters:
X : numpy array, training set.
y : numpy array, target value.
** fit_params : dict, other fitting parameters.
Return value:
numpy array, converted array.
get_params (self, deep = True) *
Get the parameters of this estimate.
inverse_transform (self, X, copy = None)
scales the data proportionally to the original form
partial_fit (self, X, y = None)
calculates the average value and std on X online for future scaling.
set_params (self, ** params)
sets the parameters of this estimator.
transform (self, X, copy = None)
performs standardization by centering and scaling.