|
PLearn 0.1
|
#include <StatsIterator.h>


Public Member Functions | |
| virtual string | info () const |
| Returns a bit more informative string about object (default returns classname()) | |
| virtual void | init (int inputsize) |
| Call this method once with the correct inputsize. | |
| virtual void | update (const Vec &input) |
| Then iterate over the data set and call this method for each row. | |
| virtual bool | finish () |
| QuantilesStatsIterator () | |
| QuantilesStatsIterator (Vec quantiles, int n_data=1000) | |
| virtual string | classname () const |
| virtual OptionList & | getOptionList () const |
| virtual OptionMap & | getOptionMap () const |
| virtual RemoteMethodMap & | getRemoteMethodMap () const |
| virtual QuantilesStatsIterator * | deepCopy (CopiesMap &copies) const |
| virtual void | makeDeepCopyFromShallowCopy (CopiesMap &copies) |
| Does the necessary operations to transform a shallow copy (this) into a deep copy by deep-copying all the members that need to be. | |
| virtual void | oldwrite (ostream &out) const |
Static Public Member Functions | |
| static string | _classname_ () |
| static OptionList & | _getOptionList_ () |
| static RemoteMethodMap & | _getRemoteMethodMap_ () |
| static Object * | _new_instance_for_typemap_ () |
| static bool | _isa_ (const Object *o) |
| static void | _static_initialize_ () |
| static const PPath & | declaringFile () |
Static Public Attributes | |
| static StaticInitializer | _static_initializer_ |
Static Protected Member Functions | |
| static void | declareOptions (OptionList &ol) |
| Declare options (data fields) for the class. | |
Protected Attributes | |
| int | nsamples |
| Vec | quantiles |
| Array< Vec > | data |
Private Types | |
| typedef StatsIterator | inherited |
result Vec has size N: the value of the observed variable at the N given quantiles.
Definition at line 344 of file StatsIterator.h.
typedef StatsIterator PLearn::QuantilesStatsIterator::inherited [private] |
Reimplemented from PLearn::StatsIterator.
Definition at line 346 of file StatsIterator.h.
| PLearn::QuantilesStatsIterator::QuantilesStatsIterator | ( | ) | [inline] |
Definition at line 358 of file StatsIterator.h.
{}
Definition at line 655 of file StatsIterator.cc.
| string PLearn::QuantilesStatsIterator::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::StatsIterator.
Definition at line 646 of file StatsIterator.cc.
| OptionList & PLearn::QuantilesStatsIterator::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::StatsIterator.
Definition at line 646 of file StatsIterator.cc.
| RemoteMethodMap & PLearn::QuantilesStatsIterator::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::StatsIterator.
Definition at line 646 of file StatsIterator.cc.
Reimplemented from PLearn::StatsIterator.
Definition at line 646 of file StatsIterator.cc.
| Object * PLearn::QuantilesStatsIterator::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 646 of file StatsIterator.cc.
| StaticInitializer QuantilesStatsIterator::_static_initializer_ & PLearn::QuantilesStatsIterator::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::StatsIterator.
Definition at line 646 of file StatsIterator.cc.
| string PLearn::QuantilesStatsIterator::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 646 of file StatsIterator.cc.
| void PLearn::QuantilesStatsIterator::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declare options (data fields) for the class.
Redefine this in subclasses: call declareOption(...) for each option, and then call inherited::declareOptions(options). Please call the inherited method AT THE END to get the options listed in a consistent order (from most recently defined to least recently defined).
static void MyDerivedClass::declareOptions(OptionList& ol) { declareOption(ol, "inputsize", &MyObject::inputsize_, OptionBase::buildoption, "The size of the input; it must be provided"); declareOption(ol, "weights", &MyObject::weights, OptionBase::learntoption, "The learned model weights"); inherited::declareOptions(ol); }
| ol | List of options that is progressively being constructed for the current class. |
Reimplemented from PLearn::StatsIterator.
Definition at line 711 of file StatsIterator.cc.
References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::StatsIterator::declareOptions(), nsamples, and quantiles.
{
declareOption(ol, "nsamples", &QuantilesStatsIterator::nsamples, OptionBase::buildoption,
" nsamples\n");
declareOption(ol, "quantiles", &QuantilesStatsIterator::quantiles, OptionBase::buildoption,
" quantiles\n");
inherited::declareOptions(ol);
}

| static const PPath& PLearn::QuantilesStatsIterator::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::StatsIterator.
Definition at line 360 of file StatsIterator.h.
:
static void declareOptions(OptionList& ol);
| QuantilesStatsIterator * PLearn::QuantilesStatsIterator::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::StatsIterator.
Definition at line 646 of file StatsIterator.cc.
| bool PLearn::QuantilesStatsIterator::finish | ( | ) | [virtual] |
Call this method when all the data has been shown (through update) If the method returns false, then a further pass through the data is required.
Implements PLearn::StatsIterator.
Definition at line 690 of file StatsIterator.cc.
References data, PLearn::TMat< T >::fill(), i, j, PLearn::TVec< T >::length(), MISSING_VALUE, nsamples, quantiles, PLearn::StatsIterator::result, PLearn::sortElements(), and PLearn::TVec< T >::toMat().
{
for (int i=0;i<data.length();i++)
sortElements(data[i]);
real dq =real(1.0)/nsamples;
real hdq = dq*real(0.5);
Mat results = result.toMat(data.length(),quantiles.length());
results.fill(MISSING_VALUE);
for (int i=0;i<data.length();i++) // loop over "variables"
{
real q=0;
for (int t=0;t<nsamples;t++,q+=dq)
{
for (int j=0;j<quantiles.length();j++)
if (quantiles[j]>q-hdq && quantiles[j]<=q+hdq)
results(i,j) = data[i][t];
}
}
return true;
}

| OptionList & PLearn::QuantilesStatsIterator::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 646 of file StatsIterator.cc.
| OptionMap & PLearn::QuantilesStatsIterator::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 646 of file StatsIterator.cc.
| RemoteMethodMap & PLearn::QuantilesStatsIterator::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 646 of file StatsIterator.cc.
| virtual string PLearn::QuantilesStatsIterator::info | ( | ) | const [inline, virtual] |
Returns a bit more informative string about object (default returns classname())
Reimplemented from PLearn::Object.
Definition at line 354 of file StatsIterator.h.
References PLearn::tostring().

| void PLearn::QuantilesStatsIterator::init | ( | int | inputsize | ) | [virtual] |
Call this method once with the correct inputsize.
Implements PLearn::StatsIterator.
Definition at line 660 of file StatsIterator.cc.
References data, i, PLearn::TVec< T >::length(), nsamples, quantiles, PLearn::TVec< T >::resize(), and PLearn::StatsIterator::result.
{
data.resize(inputsize);
for (int i=0;i<inputsize;i++)
{
data[i].resize(nsamples);
data[i].resize(0);
}
nsamples=0;
// We do not use resize on purpose, so
// that the previous result Vec does not get overwritten
result = Vec(quantiles.length()*data.length());
}

| void PLearn::QuantilesStatsIterator::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Does the necessary operations to transform a shallow copy (this) into a deep copy by deep-copying all the members that need to be.
This needs to be overridden by every class that adds "complex" data members to the class, such as Vec, Mat, PP<Something>, etc. Typical implementation:
void CLASS_OF_THIS::makeDeepCopyFromShallowCopy(CopiesMap& copies) { inherited::makeDeepCopyFromShallowCopy(copies); deepCopyField(complex_data_member1, copies); deepCopyField(complex_data_member2, copies); ... }
| copies | A map used by the deep-copy mechanism to keep track of already-copied objects. |
Reimplemented from PLearn::StatsIterator.
Definition at line 648 of file StatsIterator.cc.
References data, PLearn::deepCopyField(), and quantiles.
{
StatsIterator::makeDeepCopyFromShallowCopy(copies);
deepCopyField(quantiles, copies);
deepCopyField(data, copies);
}

| void PLearn::QuantilesStatsIterator::oldwrite | ( | ostream & | out | ) | const [virtual] |
Reimplemented from PLearn::StatsIterator.
Definition at line 722 of file StatsIterator.cc.
References nsamples, quantiles, PLearn::Object::write(), PLearn::writeField(), PLearn::writeFooter(), and PLearn::writeHeader().
{
writeHeader(out,"QuantilesStatsIterator");
inherited::write(out);
writeField(out,"nsamples",nsamples);
writeField(out,"quantiles",quantiles);
writeFooter(out,"QuantilesStatsIterator");
}

| void PLearn::QuantilesStatsIterator::update | ( | const Vec & | input | ) | [virtual] |
Then iterate over the data set and call this method for each row.
Implements PLearn::StatsIterator.
Definition at line 674 of file StatsIterator.cc.
References data, i, PLearn::TVec< T >::length(), nsamples, and PLearn::TVec< T >::resize().
{
if (nsamples == data[0].length())
{
for (int i=0;i<data.length();i++)
{
data[i].resize(10*(nsamples+1));
data[i].resize(nsamples);
}
}
for (int i=0;i<input.length();i++)
data[i].push_back(input[i]);
nsamples++;
}

Reimplemented from PLearn::StatsIterator.
Definition at line 360 of file StatsIterator.h.
Array<Vec> PLearn::QuantilesStatsIterator::data [protected] |
Definition at line 351 of file StatsIterator.h.
Referenced by finish(), init(), makeDeepCopyFromShallowCopy(), and update().
int PLearn::QuantilesStatsIterator::nsamples [protected] |
Definition at line 349 of file StatsIterator.h.
Referenced by declareOptions(), finish(), init(), oldwrite(), and update().
Vec PLearn::QuantilesStatsIterator::quantiles [protected] |
Definition at line 350 of file StatsIterator.h.
Referenced by declareOptions(), finish(), init(), makeDeepCopyFromShallowCopy(), and oldwrite().
1.7.4