Implements data normalization (of all feature values) to interval [0,1]. More...
#include <data_scaler_to01.hpp>
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 | |
Implements data normalization (of all feature values) to interval [0,1].
The transform is (value-min)/(max-min), with min and max taken per feature over one pass.
|
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 >.
|
overridevirtual |
accumulates value into the per-feature min, max and mean, unless it is the missing-value code
Implements FST::Data_Scaler< DATATYPE >.
|
inlineoverridevirtual |
one pass suffices: min, max and the mean are all accumulated together
Implements FST::Data_Scaler< DATATYPE >.
|
inlineoverridevirtual |
writes a human-readable identification of the scaler and its configuration; base default writes nothing
Reimplemented from FST::Data_Scaler< DATATYPE >.
|
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 >.
|
overridevirtual |
the in-place form of scale()
Implements FST::Data_Scaler< DATATYPE >.
|
inlineoverridevirtual |
resets the per-feature accumulators and requests the single pass
Implements FST::Data_Scaler< DATATYPE >.
|
inlineoverridevirtual |
one pass is always enough
Implements FST::Data_Scaler< DATATYPE >.