Feature Selection Toolbox FST4
UTIA · Czech Academy of Sciences
Loading...
Searching...
No Matches
FST::Data_Scaler_white< DATATYPE, IDXTYPE > Class Template Reference

Implements data whitening (as result, each feature mean value is 0 with normalized stddev). More...

#include <data_scaler_white.hpp>

Inheritance diagram for FST::Data_Scaler_white< DATATYPE, IDXTYPE >:
FST::Data_Scaler< DATATYPE >

Public Member Functions

 Data_Scaler_white (const int dims=1)
 no missing-value substitution; dims must be 1
 Data_Scaler_white (const DATATYPE missing_val_code, const int dims)
 values equal to missing_val_code are substituted (scaled value 0) rather than learned/scaled normally; dims must be 1
 Data_Scaler_white (const Data_Scaler_white &ds)
 copies configuration and any already-learned statistics
virtual int learn_loops () const override
 two passes: the variance of pass 2 needs the mean from pass 1
virtual bool startFirstLoop () override
 resets the mean accumulator and begins pass 1
virtual bool startNextLoop () override
 finalizes the mean (after pass 1) or the standard deviation (after pass 2); returns false once both passes are done
virtual void learn (const DATATYPE &value) override
 accumulates value into the mean (pass 1) or its squared deviation from that mean (pass 2), unless it is the missing-value code
virtual DATATYPE scale (const DATATYPE &value) override
 returns (value-mean)/stddev; 0 for a missing value (which is the mean in whitened coordinates) and 0 for a feature with zero standard deviation
virtual void scale_inplace (DATATYPE &value) override
 the in-place form of scale()
virtual Data_Scaler_white * duplicate () const override
virtual std::ostream & print (std::ostream &os) const override
 writes a human-readable identification of the scaler and its configuration; base default writes nothing
Public Member Functions inherited from FST::Data_Scaler< DATATYPE >
 Data_Scaler (const int dims=1)
 Data_Scaler (const Data_Scaler &ds)
 Copy constructor. The base class carries no state of its own; the concrete scalers' copy constructors copy both the configuration and whatever statistics have been learned so far, which is what makes a copy usable for scaling straight away. duplicate() is the virtual entry point that per-split scaling uses to obtain such a copy through a base-class pointer.

Protected Attributes

int learn_loop
 which of the two learn() passes is active: 1 = accumulating the mean, 2 = accumulating the variance against that mean
IDXTYPE count1
 number of non-missing values fed to learn() during pass 1 (mean accumulation)
DATATYPE mean
 running sum during pass 1, finalized to the per-feature mean by startNextLoop()
IDXTYPE count2
 number of non-missing values fed to learn() during pass 2 (variance accumulation)
DATATYPE stddev
 running sum of squared deviations during pass 2, finalized to the per-feature standard deviation by startNextLoop()
bool missing_values
 whether values equal to _missing_val_code are substituted (scaled to 0) rather than learned/scaled normally
const DATATYPE _missing_val_code
 the numerical code that marks a missing value (only meaningful when missing_values is true)

Detailed Description

template<typename DATATYPE, typename IDXTYPE>
class FST::Data_Scaler_white< DATATYPE, IDXTYPE >

Implements data whitening (as result, each feature mean value is 0 with normalized stddev).

Note
this implementation supports only scaling of one-dimensional data, thus is applicable only to scale feature values individually and independently for each other feature

The transform is (value-mean)/stddev, learned per feature in two passes: the first accumulates the mean, the second the squared deviations from it. The variance is divided by the number of values (the population convention), not by that number minus one.

Note
Optionally substitutes missing values by the mean of those values that are available (separately per feature). Missing values are assumed to be coded by dedicated numerical value 'missing_val_code'. Because the output is already centred, the mean of the whitened feature is 0 by construction – which is exactly the value scale() returns for a missing entry. Missing values take part in neither the mean nor the standard deviation.
A feature whose standard deviation comes out as 0 – a constant feature, or one with no available values at all – scales to 0 everywhere, silently.
better implementation may be needed in case of large sample sizes to prevent mean computation bias

Member Function Documentation

◆ duplicate()

template<typename DATATYPE, typename IDXTYPE>
virtual Data_Scaler_white * FST::Data_Scaler_white< DATATYPE, IDXTYPE >::duplicate ( ) const
inlineoverridevirtual

returns a new independent copy of this scaler (configuration and learned state), owned by the caller; needed by per-split scaling, where each sharing_clone of a data accessor re-learns the transform concurrently and thus needs a private scaler instance. The base implementation throws — a user-derived scaler must override it to be usable for per-split scaling in threaded searches (the built-in scalers all do).

Reimplemented from FST::Data_Scaler< DATATYPE >.

◆ learn()

template<typename DATATYPE, typename IDXTYPE>
void FST::Data_Scaler_white< DATATYPE, IDXTYPE >::learn ( const DATATYPE & value)
overridevirtual

accumulates value into the mean (pass 1) or its squared deviation from that mean (pass 2), unless it is the missing-value code

Implements FST::Data_Scaler< DATATYPE >.

◆ learn_loops()

template<typename DATATYPE, typename IDXTYPE>
virtual int FST::Data_Scaler_white< DATATYPE, IDXTYPE >::learn_loops ( ) const
inlineoverridevirtual

two passes: the variance of pass 2 needs the mean from pass 1

Implements FST::Data_Scaler< DATATYPE >.

◆ print()

template<typename DATATYPE, typename IDXTYPE>
virtual std::ostream & FST::Data_Scaler_white< DATATYPE, IDXTYPE >::print ( std::ostream & os) const
inlineoverridevirtual

writes a human-readable identification of the scaler and its configuration; base default writes nothing

Reimplemented from FST::Data_Scaler< DATATYPE >.

◆ scale()

template<typename DATATYPE, typename IDXTYPE>
DATATYPE FST::Data_Scaler_white< DATATYPE, IDXTYPE >::scale ( const DATATYPE & value)
overridevirtual

returns (value-mean)/stddev; 0 for a missing value (which is the mean in whitened coordinates) and 0 for a feature with zero standard deviation

Implements FST::Data_Scaler< DATATYPE >.

◆ scale_inplace()

template<typename DATATYPE, typename IDXTYPE>
void FST::Data_Scaler_white< DATATYPE, IDXTYPE >::scale_inplace ( DATATYPE & value)
overridevirtual

the in-place form of scale()

Implements FST::Data_Scaler< DATATYPE >.

◆ startFirstLoop()

template<typename DATATYPE, typename IDXTYPE>
bool FST::Data_Scaler_white< DATATYPE, IDXTYPE >::startFirstLoop ( )
overridevirtual

resets the mean accumulator and begins pass 1

Implements FST::Data_Scaler< DATATYPE >.

◆ startNextLoop()

template<typename DATATYPE, typename IDXTYPE>
bool FST::Data_Scaler_white< DATATYPE, IDXTYPE >::startNextLoop ( )
overridevirtual

finalizes the mean (after pass 1) or the standard deviation (after pass 2); returns false once both passes are done

Implements FST::Data_Scaler< DATATYPE >.


The documentation for this class was generated from the following file:
Copyright © 2000–present ÚTIA, Institute of Information Theory and Automation of the Czech Academy of Sciences · Contacts · This site sets no cookies and uses no analytics.