#include <FeatureScaling.h>
Standard template library (stl) functionals are used as template parameters to perform the scaling calculations. An example:
include <functional>
...
List<Sample<double> > samples; //produce these somehow
List<double> means, variances;
//Loop through all features
for (int i=0;i<featureCount;i++)
{
//Collect the ith features
List<double> tmpLst(FeatureScaling::getFeature(samples,i));
//Calculate mean and variance
means += Math::mean(tmpLst);
variances += Math::variance(tmpList);
}
//Subtract the mean value from each feature.
FeatureScaling::scaleFeatures<minus<double> >(samples,means);
//Divide by variance.
FeatureScaling::scaleFeatures<divides<double> >(samples,variances);
Static Public Methods | |
| template<class T, class I, class C> List< T > | getFeature (const List< Sample< T, I, C > > &samples, int n) |
| Get the nth feature from each sample in a sample list. | |
| template<class T, class I, class C> List< T > | getFeature (const List< Sample< List< T >, I, C > > &samples, int featureVector, int n) |
| Get the nth feature from the given feature vector of each sample in a sample list. | |
| template<class operation, class T, class I, class C> void | scaleFeatures (List< Sample< T, I, C > > &samples, const List< T > &values) |
| template<class operation, class T, class I, class C> void | scaleFeatures (List< Sample< List< T >, I, C > > &samples, int featureVector, const List< T > &values) |
| Scale feature values with the corresponding values in a list. | |
|
||||||||||||||||||||
|
Get the nth feature from the given feature vector of each sample in a sample list. This method goes through all samples in a list and stores the nth sample of the required feature vector into the resulting list.
|
|
||||||||||||||||
|
Get the nth feature from each sample in a sample list. This method goes through all samples in a list and stores the nth sample into the resulting list.
|
|
||||||||||||||||||||
|
Scale feature values with the corresponding values in a list.
|