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

Implements data normalization (of all feature values) to interval [0,1]. More...

#include <data_scaler_to01.hpp>

Inheritance diagram for FST::Data_Scaler_to01< DATATYPE >:
FST::Data_Scaler< DATATYPE >

Public Member Functions

 Data_Scaler_to01 (const int dims=1)
 no missing-value substitution; dims must be 1
 Data_Scaler_to01 (const DATATYPE missing_val_code, const int dims)
 values equal to missing_val_code are substituted by the per-feature mean; dims must be 1
 Data_Scaler_to01 (const Data_Scaler_to01 &ds)
 copies configuration and any already-learned statistics
virtual int learn_loops () const override
 one pass suffices: min, max and the mean are all accumulated together
virtual bool startFirstLoop () override
 resets the per-feature accumulators and requests the single pass
virtual bool startNextLoop () override
 one pass is always enough
virtual void learn (const DATATYPE &value) override
 accumulates value into the per-feature min, max and mean, unless it is the missing-value code
virtual DATATYPE scale (const DATATYPE &value) override
 returns (value-min)/(max-min); the mean's scaled position for a missing value; 0 if the feature is constant or had no available values
virtual void scale_inplace (DATATYPE &value) override
 the in-place form of scale()
virtual Data_Scaler_to01 * 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

bool first_learn
 true until the first learn() call of the current pass has initialized min/max
DATATYPE min
 minimum non-missing value seen for the current feature
DATATYPE max
 maximum non-missing value seen for the current feature
bool missing_values
 whether values equal to _missing_val_code are substituted 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)
long count
 number of non-missing values fed to learn() for the current feature
DATATYPE sum
 running sum of non-missing values, used to derive avg
DATATYPE avg
 running mean of non-missing values (sum/count); substituted, then scaled, for missing entries

Detailed Description

template<typename DATATYPE>
class FST::Data_Scaler_to01< DATATYPE >

Implements data normalization (of all feature values) to interval [0,1].

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-min)/(max-min), with min and max taken per feature over one pass.

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'. The substitution happens BEFORE the normalization, so a missing entry ends up at (mean-min)/(max-min) – the mean's position within [0,1] – not at the raw mean. Missing values take part in neither the min/max nor the mean.
Two degenerate cases both yield 0 silently, with no warning: a feature whose values are all missing (nothing was learned), and a constant feature, where max==min would divide by zero.

Member Function Documentation

◆ duplicate()

template<typename DATATYPE>
virtual Data_Scaler_to01 * FST::Data_Scaler_to01< DATATYPE >::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>
void FST::Data_Scaler_to01< DATATYPE >::learn ( const DATATYPE & value)
overridevirtual

accumulates value into the per-feature min, max and mean, unless it is the missing-value code

Implements FST::Data_Scaler< DATATYPE >.

◆ learn_loops()

template<typename DATATYPE>
virtual int FST::Data_Scaler_to01< DATATYPE >::learn_loops ( ) const
inlineoverridevirtual

one pass suffices: min, max and the mean are all accumulated together

Implements FST::Data_Scaler< DATATYPE >.

◆ print()

template<typename DATATYPE>
virtual std::ostream & FST::Data_Scaler_to01< DATATYPE >::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>
DATATYPE FST::Data_Scaler_to01< DATATYPE >::scale ( const DATATYPE & value)
overridevirtual

returns (value-min)/(max-min); the mean's scaled position for a missing value; 0 if the feature is constant or had no available values

Implements FST::Data_Scaler< DATATYPE >.

◆ scale_inplace()

template<typename DATATYPE>
void FST::Data_Scaler_to01< DATATYPE >::scale_inplace ( DATATYPE & value)
overridevirtual

the in-place form of scale()

Implements FST::Data_Scaler< DATATYPE >.

◆ startFirstLoop()

template<typename DATATYPE>
virtual bool FST::Data_Scaler_to01< DATATYPE >::startFirstLoop ( )
inlineoverridevirtual

resets the per-feature accumulators and requests the single pass

Implements FST::Data_Scaler< DATATYPE >.

◆ startNextLoop()

template<typename DATATYPE>
virtual bool FST::Data_Scaler_to01< DATATYPE >::startNextLoop ( )
inlineoverridevirtual

one pass is always enough

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.