metbit.scaler
NMR and preprocessing module in metbit 4.4.8.
import metbit.scalerClasses
Scaler
Extension of Scikit-learn's StandardScaler which allows scaling by different powers of the standard deviation.
:param scale_power: To which power should the standard deviation of each variable be raised for scaling. 0: Mean centering; 0.5: Pareto; 1:Unit Variance. :type scale_power: Float :param bool copy: Copy the array containing the data. :param bool with_mean: Perform mean centering. :param bool with_std: Scale the data.
Methods
__init__(self, scale_power=1, copy=True, with_mean=True, with_std=True)
fit(self, X, y=None)
Compute the mean and standard deviation from a dataset to use in future scaling operations.
:param X: Data matrix to scale. :type X: numpy.ndarray, shape [n_samples, n_features] :param y: Passthrough for Scikit-learn ``Pipeline`` compatibility. :type y: None :return: Fitted object. :rtype: py.Scaler
partial_fit(self, X, y=None)
Performs online computation of mean and standard deviation on X for later scaling. All of X is processed as a single batch. This is intended for cases when `fit` is not feasible due to very large number of `n_samples` or because X is read from a continuous stream.
The algorithm for incremental mean and std is given in Equation 1.5a,b in Chan, Tony F., Gene H. Golub, and Randall J. LeVeque. "Algorithms
for computing the sample varianceAnalysis and recommendations."The American Statistician 37.3 (1983): 242-247
:param X: Data matrix to scale. :type X: numpy.ndarray, shape [n_samples, n_features] :param y: Passthrough for Scikit-learn ``Pipeline`` compatibility. :type y: None :return: Fitted object. :rtype: py.Scaler
transform(self, X, y=None, copy=None)
Perform standardization by centering and scaling using the parameters.
:param X: Data matrix to scale. :type X: numpy.ndarray, shape [n_samples, n_features] :param y: Passthrough for scikit-learn ``Pipeline`` compatibility. :type y: None :param bool copy: Copy the X matrix. :return: Scaled version of the X data matrix. :rtype: numpy.ndarray, shape [n_samples, n_features]
inverse_transform(self, X, copy=None)
Scale back the data to the original representation.
:param X: Scaled data matrix. :type X: numpy.ndarray, shape [n_samples, n_features] :param bool copy: Copy the X data matrix. :return: X data matrix with the scaling operation reverted. :rtype: numpy.ndarray, shape [n_samples, n_features]