#include <PCA.h>
Inheritance diagram for PLearn::PCA:
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< string > | getTestCostNames () const |
Returns [ "squared_reconstruction_error" ]. | |
virtual TVec< string > | getTrainCostNames () 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. |
|
Reimplemented from PLearn::PLearner. |
|
Default constructor.
Definition at line 50 of file PCA.cc. References PLearn::normalize(). |
|
Simply calls inherited::build() then build_().
Reimplemented from PLearn::PLearner. Definition at line 102 of file PCA.cc. References build_(). |
|
This does the actual building.
Reimplemented from PLearn::PLearner. Definition at line 111 of file PCA.cc. Referenced by build(). |
|
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. |
|
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. |
|
Declares this class' options.
Reimplemented from PLearn::PLearner. Definition at line 69 of file PCA.cc. References PLearn::declareOption(), and PLearn::OptionList. |
|
(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. |
|
Returns [ "squared_reconstruction_error" ].
Implements PLearn::PLearner. |
|
No trian costs are computed for this learner.
Implements PLearn::PLearner. |
|
Transforms a shallow copy into a deep copy.
Definition at line 177 of file PCA.cc. References PLearn::deepCopyField(), eigenvals, eigenvecs, and mu. |
|
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. |
|
|
|
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(). |
|
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(). |
|
Definition at line 61 of file PCA.h. Referenced by train(). |
|
The (weighted) mean of the samples.
Definition at line 68 of file PCA.h. Referenced by computeOutput(), makeDeepCopyFromShallowCopy(), reconstruct(), and train(). |
|
The ncomponents eigenvalues corresponding to the principal directions kept.
Definition at line 69 of file PCA.h. Referenced by computeOutput(), makeDeepCopyFromShallowCopy(), reconstruct(), and train(). |
|
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(). |
|
Definition at line 62 of file PCA.h. Referenced by computeOutput(), outputsize(), and train(). |
|
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(). |
|
The number of principal components to keep (that's also the outputsize).
|