pub struct StandardScaler { /* private fields */ }Expand description
A transformer that scales items to have zero mean and unit standard deviation.
The standard score of a sample x is calculated as:
z = (x - mean) / std_devwhere mean is the mean and s is the standard deviation of the data first passed to
transform (or provided via with_parameters).
§Implementation
This transformer uses Welford’s online algorithm to compute mean and variance in one pass over the data. The standard deviation is calculated using the biased estimator, for parity with the scikit-learn implementation.
§Example
§Using the default constructor
use augurs_forecaster::transforms::{StandardScaler, Transformer};
let mut data = vec![1.0, 2.0, 3.0];
let mut scaler = StandardScaler::new();
scaler.fit_transform(&mut data);
assert_eq!(data, vec![-1.224744871391589, 0.0, 1.224744871391589]);Implementations§
Source§impl StandardScaler
impl StandardScaler
Sourcepub fn with_parameters(self, params: StandardScaleParams) -> Self
pub fn with_parameters(self, params: StandardScaleParams) -> Self
Set the parameters for the scaler.
This is useful if you know the mean and standard deviation in advance and want to avoid the overhead of fitting the scaler to the data during the initial transform, and instead want to set the parameters manually.
Sourcepub fn ignore_nans(self, ignore_nans: bool) -> Self
pub fn ignore_nans(self, ignore_nans: bool) -> Self
Whether to ignore NaN values when calculating the scaler parameters.
If true, NaN values will be ignored when calculating the scaler parameters.
This can be useful if you have NaN values in your data and want to avoid
errors when calculating the scaler parameters.
Defaults to false.
Trait Implementations§
Source§impl Clone for StandardScaler
impl Clone for StandardScaler
Source§fn clone(&self) -> StandardScaler
fn clone(&self) -> StandardScaler
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more