Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

PLearn::PCA Class Reference

#include <PCA.h>

Inheritance diagram for PLearn::PCA:

Inheritance graph
[legend]
Collaboration diagram for PLearn::PCA:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 PCA ()
 Default constructor.

virtual void build ()
 Simply calls inherited::build() then build_().

virtual void makeDeepCopyFromShallowCopy (map< const void *, void * > &copies)
 Transforms a shallow copy into a deep copy.

 PLEARN_DECLARE_OBJECT (PCA)
virtual int outputsize () const
 returns the size of this learner's output, (which typically may depend on its inputsize(), targetsize() and set options)

virtual void forget ()
 (Re-)initializes the PLearner in its fresh state (that state may depend on the 'seed' option) And sets 'stage' back to 0 (this is the stage of a fresh learner!)

virtual void train ()
 The role of the train method is to bring the learner up to stage==nstages, updating the train_stats collector with training costs measured on-line in the process.

virtual void computeOutput (const Vec &input, Vec &output) const
 Computes the output from the input.

void reconstruct (const Vec &output, Vec &input) const
 Reconstructs an input from a (possibly partial) output (i.e. the first few princial components kept).

virtual void computeCostsFromOutputs (const Vec &input, const Vec &output, const Vec &target, Vec &costs) const
 Computes the costs from already computed output.

virtual TVec< stringgetTestCostNames () const
 Returns [ "squared_reconstruction_error" ].

virtual TVec< stringgetTrainCostNames () const
 No trian costs are computed for this learner.


Public Attributes

string algo
int ncomponents
real sigmasq
 The number of principal components to keep (that's also the outputsize).

bool normalize
 This gets added to the diagonal of the covariance matrix prior to eigen-decomposition.

Vec mu
 If true, we divide by sqrt(eigenval) after projecting on the eigenvec.

Vec eigenvals
 The (weighted) mean of the samples.

Mat eigenvecs
 The ncomponents eigenvalues corresponding to the principal directions kept.


Static Protected Member Functions

void declareOptions (OptionList &ol)
 Declares this class' options.


Private Types

typedef PLearner inherited

Private Member Functions

void build_ ()
 This does the actual building.


Member Typedef Documentation

typedef PLearner PLearn::PCA::inherited [private]
 

Reimplemented from PLearn::PLearner.

Definition at line 53 of file PCA.h.


Constructor & Destructor Documentation

PLearn::PCA::PCA  ) 
 

Default constructor.

Definition at line 50 of file PCA.cc.

References PLearn::normalize().


Member Function Documentation

void PLearn::PCA::build  )  [virtual]
 

Simply calls inherited::build() then build_().

Reimplemented from PLearn::PLearner.

Definition at line 102 of file PCA.cc.

References build_().

void PLearn::PCA::build_  )  [private]
 

This does the actual building.

Reimplemented from PLearn::PLearner.

Definition at line 111 of file PCA.cc.

Referenced by build().

void PLearn::PCA::computeCostsFromOutputs const Vec input,
const Vec output,
const Vec target,
Vec costs
const [virtual]
 

Computes the costs from already computed output.

The only computed cost is the squared_reconstruction_error

Implements PLearn::PLearner.

Definition at line 118 of file PCA.cc.

References PLearn::powdistance(), reconstruct(), PLearn::TVec< T >::resize(), and PLearn::Vec.

void PLearn::PCA::computeOutput const Vec input,
Vec output
const [virtual]
 

Computes the output from the input.

Implements PLearn::PLearner.

Definition at line 130 of file PCA.cc.

References PLearn::dot(), eigenvals, eigenvecs, PLearn::TVec< T >::length(), mu, ncomponents, normalize, PLearn::TVec< T >::resize(), PLearn::sqrt(), and x.

void PLearn::PCA::declareOptions OptionList ol  )  [static, protected]
 

Declares this class' options.

Reimplemented from PLearn::PLearner.

Definition at line 69 of file PCA.cc.

References PLearn::declareOption(), and PLearn::OptionList.

void PLearn::PCA::forget  )  [virtual]
 

(Re-)initializes the PLearner in its fresh state (that state may depend on the 'seed' option) And sets 'stage' back to 0 (this is the stage of a fresh learner!)

Implements PLearn::PLearner.

Definition at line 153 of file PCA.cc.

TVec< string > PLearn::PCA::getTestCostNames  )  const [virtual]
 

Returns [ "squared_reconstruction_error" ].

Implements PLearn::PLearner.

Definition at line 161 of file PCA.cc.

TVec< string > PLearn::PCA::getTrainCostNames  )  const [virtual]
 

No trian costs are computed for this learner.

Implements PLearn::PLearner.

Definition at line 169 of file PCA.cc.

void PLearn::PCA::makeDeepCopyFromShallowCopy map< const void *, void * > &  copies  )  [virtual]
 

Transforms a shallow copy into a deep copy.

Definition at line 177 of file PCA.cc.

References PLearn::deepCopyField(), eigenvals, eigenvecs, and mu.

int PLearn::PCA::outputsize  )  const [virtual]
 

returns the size of this learner's output, (which typically may depend on its inputsize(), targetsize() and set options)

Implements PLearn::PLearner.

Definition at line 189 of file PCA.cc.

References ncomponents.

PLearn::PCA::PLEARN_DECLARE_OBJECT PCA   ) 
 

void PLearn::PCA::reconstruct const Vec output,
Vec input
const
 

Reconstructs an input from a (possibly partial) output (i.e. the first few princial components kept).

Definition at line 368 of file PCA.cc.

References eigenvals, eigenvecs, PLearn::TVec< T >::length(), mu, PLearn::multiplyAcc(), normalize, PLearn::TVec< T >::resize(), and PLearn::sqrt().

Referenced by computeCostsFromOutputs().

void PLearn::PCA::train  )  [virtual]
 

The role of the train method is to bring the learner up to stage==nstages, updating the train_stats collector with training costs measured on-line in the process.

Implements PLearn::PLearner.

Definition at line 197 of file PCA.cc.

References PLearn::abs(), algo, PLearn::computeInputMeanAndCovar(), PLearn::computeMeanAndVariance(), PLearn::dot(), eigenvals, PLearn::eigenVecOfSymmMat(), eigenvecs, PLearn::fill_random_normal(), PLearn::GramSchmidtOrthogonalization(), k, PLearn::TVec< T >::length(), PLearn::VMat::length(), PLearn::matInvert(), mu, ncomponents, PLearn::negateElements(), PLearn::normalize(), normalize, PLERROR, PLWARNING, PLearn::product(), PLearn::productAcc(), PLearn::productTranspose(), PLearn::TMat< T >::resize(), PLearn::TVec< T >::resize(), PLearn::PLearner::setTrainingSet(), PLearn::TMat< T >::subMatColumns(), PLearn::TMat< T >::subMatRows(), PLearn::VMat::toMat(), PLearn::transposeProduct(), and PLearn::ProgressBar::update().


Member Data Documentation

string PLearn::PCA::algo
 

Definition at line 61 of file PCA.h.

Referenced by train().

Vec PLearn::PCA::eigenvals
 

The (weighted) mean of the samples.

Definition at line 68 of file PCA.h.

Referenced by computeOutput(), makeDeepCopyFromShallowCopy(), reconstruct(), and train().

Mat PLearn::PCA::eigenvecs
 

The ncomponents eigenvalues corresponding to the principal directions kept.

Definition at line 69 of file PCA.h.

Referenced by computeOutput(), makeDeepCopyFromShallowCopy(), reconstruct(), and train().

Vec PLearn::PCA::mu
 

If true, we divide by sqrt(eigenval) after projecting on the eigenvec.

Definition at line 67 of file PCA.h.

Referenced by computeOutput(), makeDeepCopyFromShallowCopy(), reconstruct(), and train().

int PLearn::PCA::ncomponents
 

Definition at line 62 of file PCA.h.

Referenced by computeOutput(), outputsize(), and train().

bool PLearn::PCA::normalize
 

This gets added to the diagonal of the covariance matrix prior to eigen-decomposition.

Definition at line 64 of file PCA.h.

Referenced by computeOutput(), reconstruct(), and train().

real PLearn::PCA::sigmasq
 

The number of principal components to keep (that's also the outputsize).

Definition at line 63 of file PCA.h.


The documentation for this class was generated from the following files:
Generated on Tue Aug 17 16:28:00 2004 for PLearn by doxygen 1.3.7