#include <VecStatsCollector.h>
Inheritance diagram for PLearn::VecStatsCollector:
Public Member Functions | |
VecStatsCollector () | |
int | length () const |
int | size () const |
virtual void | build () |
simply calls inherited::build() then build_() | |
virtual void | forget () |
clears all previously accumulated statistics | |
virtual void | update (const Vec &x, real weight=1.0) |
updates the statistics when seeing x The weight applies to all elements of x | |
void | setFieldNames (TVec< string > the_fieldnames) |
Declares names for the columns of the vector passed to update. | |
TVec< string > | getFieldNames () const |
Returns the declared names. | |
int | getFieldNum (const string &fieldname_or_num) const |
Returns the index corresponding to a fieldname or to the fieldnum passed as a string. | |
virtual double | getStat (const string &statspec) |
Returns a particular statistic. | |
void | update (const Mat &m) |
calls update on all rows of m | |
void | update (const Mat &m, const Vec &weights) |
calls update on all rows of m, with given weight vector | |
virtual void | finalize () |
finishes whatever computation are needed after all updates have been made | |
const StatsCollector & | getStats (int i) const |
returns statistics for element i | |
Vec | getMean () const |
returns the empirical mean (sample average) vec | |
Vec | getVariance () const |
returns the empirical variance vec | |
Vec | getStdDev () const |
returns the empirical standard deviation vec | |
Vec | getStdError () const |
returns the empirical standard deviation vec | |
const Mat & | getXtX () const |
returns uncentered covariance matrix (mean not subtracted X'.X) | |
Mat | getCovariance () const |
returns centered covariance matrix (mean subtracted) | |
Mat | getCorrelation () const |
returns correlation matrix | |
Vec | getAllStats (Vec &st) const |
Fills vector st with [mean, variance, stddev, min, max] (after resizing it if it had a size of 0) However the order and number may change in future versions, so it's better to first call getIndexInAllStats to get the index of a given stat. | |
int | getIndexInAllStats (int fieldindex, const string &statname) const |
Returns the index in the vector returned by getAllStats of the stat with the given name. | |
virtual void | makeDeepCopyFromShallowCopy (map< const void *, void * > &copies) |
Transforms a shallow copy into a deep copy. | |
PLEARN_DECLARE_OBJECT (VecStatsCollector) | |
Declares name and deepCopy methods. | |
Public Attributes | |
int | maxnvalues |
maximum number of different values to keep track of for each element | |
TVec< string > | fieldnames |
(default: 0, meaning we only keep track of global statistics) names of the fields of the update vector | |
bool | compute_covariance |
Should we compute and keep X'.X ? | |
TVec< StatsCollector > | stats |
(default false) | |
Mat | cov |
Static Protected Member Functions | |
void | declareOptions (OptionList &ol) |
Declares this class' options. | |
Private Types | |
typedef Object | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. |
|
Reimplemented from PLearn::Object. Reimplemented in PLearn::LiftStatsCollector. Definition at line 51 of file VecStatsCollector.h. |
|
Definition at line 46 of file VecStatsCollector.cc. |
|
simply calls inherited::build() then build_()
Reimplemented from PLearn::Object. Reimplemented in PLearn::LiftStatsCollector. Definition at line 182 of file VecStatsCollector.cc. References build_(). |
|
This does the actual building.
Reimplemented from PLearn::Object. Reimplemented in PLearn::LiftStatsCollector. Definition at line 179 of file VecStatsCollector.cc. Referenced by build(). |
|
Declares this class' options.
Reimplemented from PLearn::Object. Reimplemented in PLearn::LiftStatsCollector. Definition at line 55 of file VecStatsCollector.cc. References PLearn::declareOption(), and PLearn::OptionList. |
|
finishes whatever computation are needed after all updates have been made
Reimplemented in PLearn::LiftStatsCollector. Definition at line 194 of file VecStatsCollector.cc. References PLearn::TVec< StatsCollector >::size(), and stats. Referenced by PLearn::computeStats(). |
|
clears all previously accumulated statistics
Reimplemented in PLearn::LiftStatsCollector. Definition at line 188 of file VecStatsCollector.cc. References cov, PLearn::TMat< T >::resize(), PLearn::TVec< StatsCollector >::resize(), and stats. Referenced by PLearn::computeStats(). |
|
Fills vector st with [mean, variance, stddev, min, max] (after resizing it if it had a size of 0) However the order and number may change in future versions, so it's better to first call getIndexInAllStats to get the index of a given stat.
|
|
returns correlation matrix
Definition at line 254 of file VecStatsCollector.cc. References cov, PLearn::externalProduct(), getCovariance(), getStdDev(), PLearn::norm(), and PLearn::TMat< T >::width(). |
|
returns centered covariance matrix (mean subtracted)
Definition at line 242 of file VecStatsCollector.cc. References cov, PLearn::covariance(), getMean(), PLearn::TMat< T >::length(), stats, and PLearn::TMat< T >::width(). Referenced by getCorrelation(). |
|
Returns the declared names.
Definition at line 111 of file VecStatsCollector.h. References fieldnames. |
|
Returns the index corresponding to a fieldname or to the fieldnum passed as a string. returns -1 if not found Definition at line 100 of file VecStatsCollector.cc. References fieldnames, PLearn::TVec< string >::find(), PLearn::pl_isnumber(), and PLearn::toint(). Referenced by getStat(). |
|
Returns the index in the vector returned by getAllStats of the stat with the given name. Currently available names are E (mean) V (variance) STDDEV MIN MAX Will throw an exception if statname is invalid |
|
returns the empirical mean (sample average) vec
Definition at line 202 of file VecStatsCollector.cc. References k, PLearn::TVec< StatsCollector >::size(), and stats. Referenced by getCovariance(), and PLearn::Experiment::run(). |
|
Returns a particular statistic. Standard statistics specifications are of the form ex: STAT[fieldname] or STAT[fieldnum] where STAT is one of the statistics names understood by StatsCollector::getStat. fieldnum start at 0, and fieldnames must have been registered with setFieldNames. Subclasses may overload this to handle more exotic statistics than the few standard ones. Reimplemented in PLearn::LiftStatsCollector. Definition at line 80 of file VecStatsCollector.cc. References getFieldNum(), PLearn::StatsCollector::getStat(), getStats(), PLearn::TVec< StatsCollector >::length(), MISSING_VALUE, PLERROR, PLearn::PStream::smartReadUntilNext(), and stats. |
|
returns statistics for element i
Definition at line 138 of file VecStatsCollector.h. References getStats(), and stats. Referenced by getStat(), and getStats(). |
|
returns the empirical standard deviation vec
Definition at line 222 of file VecStatsCollector.cc. References k, PLearn::TVec< StatsCollector >::size(), and stats. Referenced by getCorrelation(), and PLearn::Experiment::run(). |
|
returns the empirical standard deviation vec
Definition at line 232 of file VecStatsCollector.cc. References k, PLearn::TVec< StatsCollector >::size(), and stats. Referenced by PLearn::Experiment::run(). |
|
returns the empirical variance vec
Definition at line 212 of file VecStatsCollector.cc. References k, PLearn::TVec< StatsCollector >::size(), and stats. |
|
returns uncentered covariance matrix (mean not subtracted X'.X)
Definition at line 154 of file VecStatsCollector.h. References cov. |
|
Definition at line 93 of file VecStatsCollector.h. References PLearn::TVec< StatsCollector >::length(), and stats. Referenced by size(). |
|
Transforms a shallow copy into a deep copy.
Reimplemented in PLearn::LiftStatsCollector. Definition at line 261 of file VecStatsCollector.cc. References PLearn::deepCopyField(), and stats. |
|
Declares name and deepCopy methods.
|
|
Declares names for the columns of the vector passed to update.
Definition at line 107 of file VecStatsCollector.h. References fieldnames, and setFieldNames(). Referenced by PLearn::computeStats(), and setFieldNames(). |
|
Definition at line 94 of file VecStatsCollector.h. References length(). |
|
calls update on all rows of m, with given weight vector
Definition at line 168 of file VecStatsCollector.cc. References PLearn::TMat< T >::length(), PLERROR, PLearn::TVec< T >::size(), and PLearn::update(). |
|
calls update on all rows of m
Definition at line 160 of file VecStatsCollector.cc. References PLearn::TMat< T >::length(), and PLearn::update(). |
|
updates the statistics when seeing x The weight applies to all elements of x
Reimplemented in PLearn::LiftStatsCollector. Definition at line 116 of file VecStatsCollector.cc. References compute_covariance, cov, PLearn::externalProductScaleAcc(), PLearn::TMat< T >::fill(), k, maxnvalues, PLERROR, PLearn::TMat< T >::resize(), PLearn::TVec< StatsCollector >::resize(), PLearn::TVec< StatsCollector >::size(), stats, PLearn::Vec, and x. Referenced by PLearn::computeStats(), PLearn::GradientOptimizer::optimizeN(), PLearn::ConjGradientOptimizer::optimizeN(), PLearn::AdaptGradientOptimizer::optimizeN(), and PLearn::Experiment::run(). |
|
Should we compute and keep X'.X ?
Definition at line 65 of file VecStatsCollector.h. Referenced by update(). |
|
Definition at line 69 of file VecStatsCollector.h. Referenced by forget(), getCorrelation(), getCovariance(), getXtX(), and update(). |
|
(default: 0, meaning we only keep track of global statistics) names of the fields of the update vector
Definition at line 62 of file VecStatsCollector.h. Referenced by getFieldNames(), getFieldNum(), and setFieldNames(). |
|
maximum number of different values to keep track of for each element
Definition at line 59 of file VecStatsCollector.h. Referenced by update(). |
|
(default false)
Definition at line 68 of file VecStatsCollector.h. Referenced by finalize(), forget(), getCovariance(), getMean(), getStat(), getStats(), getStdDev(), getStdError(), getVariance(), length(), makeDeepCopyFromShallowCopy(), and update(). |