#ifndef NUMREDUCEPCAB_HH #define NUMREDUCEPCAB_HH //////////////////////////////////////////////////////////////////////////// //! author="Robert Crida" //! lib=NumReduce //! date="4/3/1998" //! userlevel=Develop //! file="amma/PatternRec/FuncTools/Reduce/NumReducePCAB.hh" //! docentry="Pattern Recognition.Feature Reduction.Implementation" //! rcsid="$Id: NumReducePCAB.hh,v 1.13 2000/02/16 14:11:30 ees1cg Exp $" #include "amma/Num/NumReduceUnsupervisedB.hh" // -------------------------------------------------------------------------- // ********** NumReducePCABC ********************************************** // -------------------------------------------------------------------------- //: Implementation class for Principal Component Analysis feature reduction. // // Feature space reduction using Principal Component Analysis. The handle // class NumReducePCAC should be used. class NumReducePCABC: public NumReduceUnsupervisedBC { VecMatC _Wpca; VectorC _mean; UIntT _numSamples; //: Number of samples to use for calculating PCA RealT _variation; //: Determines amount of variation in original set to be accounted for RealT _proportionAccountedFor; //: Actual proportion of original variation that is accounted for public: NumReducePCABC (UIntT numSamples, RealT variation); //: Constructor //!param: numSamples - max number of samples from training set to use //!param: variation - proportion of variation to account for in subspace // Note that this algorithm can become very slow with a large number of high // dimensional feature vectors so numSamples should be set to a reasonable // value. variation can be used in 2 ways: if it is less than 1 then that // fraction of the variation is preserved. If it is greater than 1, then // that number of the most significant modes of variation will be preserved. NumReducePCABC (RealT variation); //: Constructor NumReducePCABC (istream &in); //: Constructs from stream NumReducePCABC (const NumReducePCABC &oth); //: Copy constructor virtual BodyRefCounterVC & Copy () const; //: Makes a deep copy and is virtual protected: virtual VectorC Evaluate (const VectorC &X) const; //: Evaluate Y=f(X) where Y is X projected into a lower dimension virtual void Design (const DListC &trainX); //: Used to determine how to do dimensionality reduction void DesignLowDim(const DListC &trainX); //: Used to design for low dimensional problems const MatrixC GetWpca () const; //: Access to the transformation matrix const VectorC GetEigenValues () const; //: Access to the eigen values const VectorC GetMean () const {return _mean;} //: Access to mean virtual const StringC GetInfo () const; //: Prints derived class information virtual BooleanT Save (ostream &out) const; //: Writes object to stream, can be loaded using constructor friend class NumReducePCAC; //: Handle class }; #endif