Darwin  1.10(beta)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | List of all members
drwnFeatureWhitener Class Reference

Whitens (zero mean, unit variance) feature vector (see also drwnPCA). More...

Inheritance diagram for drwnFeatureWhitener:
drwnUnsupervisedTransform drwnFeatureTransform drwnStdObjIface drwnProperties drwnWriteable drwnCloneable drwnTypeable

Public Member Functions

 drwnFeatureWhitener ()
 default constructor
 
 drwnFeatureWhitener (const drwnSuffStats &stats)
 construct a feature whitener from sufficient statistics
 
 drwnFeatureWhitener (const drwnFeatureWhitener &fw)
 copy constructor
 
const char * type () const
 returns object type as a string (e.g., Foo::type() { return "Foo"; })
 
drwnFeatureWhitenerclone () const
 returns a copy of the class usually implemented as virtual Foo* clone() { return new Foo(*this); }
 
void clear ()
 clears the parameters of the feature transform object
 
bool save (drwnXMLNode &node) const
 write object to XML node (see also write)
 
bool load (drwnXMLNode &node)
 read object from XML node (see also read)
 
double train (const drwnSuffStats &stats)
 Estimate the parameters of the feature transformation from previously accumulated second-order sufficient statistics.
 
double train (const vector< vector< double > > &features)
 Estimate the parameters of the features transformation. This function must be implemented in the derived class.
 
void transform (vector< double > &x) const
 transforms a feature vector in-place
 
void transform (const vector< double > &x, vector< double > &y) const
 transforms feature vector x into feature vector y
 
- Public Member Functions inherited from drwnUnsupervisedTransform
 drwnUnsupervisedTransform ()
 default constructor
 
 drwnUnsupervisedTransform (const drwnUnsupervisedTransform &t)
 copy constructor
 
virtual double train (const vector< vector< double > > &features, const vector< double > &weights)
 Estimate the parameters of the feature transformation using weighted training examples.
 
virtual double train (const vector< vector< double > > &features, const drwnFeatureTransform &xform)
 Estimate the parameters of the features transformation first applying another transform. The default implementation of this function naively transforms the data and passes the transformed data onto the relevant training code.
 
virtual double train (const vector< vector< double > > &features, const vector< double > &weights, const drwnFeatureTransform &xform)
 Estimate the parameters of the feature transformation using weighted training examples first applying another transform. The default implementation of this function naively transforms the data and passes the transformed data onto the relevant training code.
 
- Public Member Functions inherited from drwnFeatureTransform
 drwnFeatureTransform ()
 default constructor
 
 drwnFeatureTransform (const drwnFeatureTransform &t)
 copy constructor
 
int numFeatures () const
 returns the length of the feature vector expected by the feature transform object (or zero for arbitrary)
 
virtual bool valid () const
 returns true if the feature transform object is initialized (and trained)
 
virtual void transform (vector< vector< double > > &x) const
 transforms a set of feature vectors in-place
 
virtual void transform (const vector< vector< double > > &x, vector< vector< double > > &y) const
 transforms a set of feature vectors from x to corresponding feature vectors y
 
virtual void transform (vector< double > &x, const drwnFeatureTransform &xform) const
 transforms a feature vector in-place first applying another transform
 
virtual void transform (const vector< double > &x, vector< double > &y, const drwnFeatureTransform &xform) const
 transforms feature vector x into feature vector y first applying another transform
 
virtual void transform (vector< vector< double > > &x, const drwnFeatureTransform &xform) const
 transforms a set of feature vectors in-place first applying another transform
 
virtual void transform (const vector< vector< double > > &x, vector< vector< double > > &y, const drwnFeatureTransform &xform) const
 transforms a set of feature vectors from x to corresponding feature vectors y first applying another transform
 
- Public Member Functions inherited from drwnWriteable
bool write (const char *filename) const
 write object to file (calls save)
 
bool read (const char *filename)
 read object from file (calls load)
 
void dump () const
 print object's current state to standard output (for debugging)
 
- Public Member Functions inherited from drwnProperties
unsigned numProperties () const
 
bool hasProperty (const string &name) const
 
bool hasProperty (const char *name) const
 
unsigned findProperty (const string &name) const
 
unsigned findProperty (const char *name) const
 
void setProperty (unsigned indx, bool value)
 
void setProperty (unsigned indx, int value)
 
void setProperty (unsigned indx, double value)
 
void setProperty (unsigned indx, const string &value)
 
void setProperty (unsigned indx, const char *value)
 
void setProperty (unsigned indx, const Eigen::VectorXd &value)
 
void setProperty (unsigned indx, const Eigen::MatrixXd &value)
 
void setProperty (const char *name, bool value)
 
void setProperty (const char *name, int value)
 
void setProperty (const char *name, double value)
 
void setProperty (const char *name, const string &value)
 
void setProperty (const char *name, const char *value)
 
void setProperty (const char *name, const Eigen::VectorXd &value)
 
void setProperty (const char *name, const Eigen::MatrixXd &value)
 
string getPropertyAsString (unsigned indx) const
 
drwnPropertyType getPropertyType (unsigned indx) const
 
bool isReadOnly (unsigned indx) const
 
const drwnPropertyInterfacegetProperty (unsigned indx) const
 
const drwnPropertyInterfacegetProperty (const char *name) const
 
bool getBoolProperty (unsigned indx) const
 
int getIntProperty (unsigned indx) const
 
double getDoubleProperty (unsigned indx) const
 
const string & getStringProperty (unsigned indx) const
 
const list< string > & getListProperty (unsigned indx) const
 
int getSelectionProperty (unsigned indx) const
 
const Eigen::VectorXd & getVectorProperty (unsigned indx) const
 
const Eigen::MatrixXd & getMatrixProperty (unsigned indx) const
 
const string & getPropertyName (unsigned indx) const
 
vector< string > getPropertyNames () const
 
void readProperties (drwnXMLNode &xml, const char *tag="property")
 
void writeProperties (drwnXMLNode &xml, const char *tag="property") const
 
void printProperties (ostream &os) const
 

Additional Inherited Members

- Protected Member Functions inherited from drwnProperties
void declareProperty (const string &name, drwnPropertyInterface *optif)
 
void undeclareProperty (const string &name)
 
void exposeProperties (drwnProperties *opts, const string &prefix=string(""), bool bSerializable=false)
 
virtual void propertyChanged (const string &name)
 
- Protected Attributes inherited from drwnFeatureTransform
int _nFeatures
 number of (input) features
 
bool _bValid
 true if transform parameters are trained or loaded
 

Detailed Description

Whitens (zero mean, unit variance) feature vector (see also drwnPCA).

Each features is whitened independently by subtracting the sample mean and dividing by sample standard-deviation. Constant features (i.e., those with near zero-variance) are not whitened.

The following code snippet demonstrates example usage:

// load training dataset
dataset.read("training.bin");
// whiten features
whitener.train(dataset.features);
whitener.transform(dataset.features);
// save whitened features
dataset.write("training.bin");
// apply same whitening to test dataset
dataset.clear();
dataset.read("testing.bin");
whitener.transform(dataset.features);
dataset.write("testing.bin");

The documentation for this class was generated from the following files: