PLearn 0.1
|
Generate samples from a mixture of two gaussians. More...
#include <CheckDond2FileSequence.h>
Public Member Functions | |
CheckDond2FileSequence () | |
Default constructor. | |
int | outputsize () const |
SUBCLASS WRITING: override this so that it returns the size of this learner's output, as a function of its inputsize(), targetsize() and set options. | |
void | train () |
*** SUBCLASS WRITING: *** | |
void | computeOutput (const Vec &, Vec &) const |
*** SUBCLASS WRITING: *** | |
void | computeCostsFromOutputs (const Vec &, const Vec &, const Vec &, Vec &) const |
*** SUBCLASS WRITING: *** | |
TVec< string > | getTestCostNames () const |
*** SUBCLASS WRITING: *** | |
TVec< string > | getTrainCostNames () const |
*** SUBCLASS WRITING: *** | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual CheckDond2FileSequence * | deepCopy (CopiesMap &copies) const |
virtual void | build () |
Finish building the object; just call inherited::build followed by build_() | |
virtual void | makeDeepCopyFromShallowCopy (CopiesMap &copies) |
Transforms a shallow copy into a deep copy. | |
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 () |
Public Attributes | |
int | key_col |
### declare public option fields (such as build options) here Start your comments with Doxygen-compatible comments such as //! | |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Static Protected Member Functions | |
static void | declareOptions (OptionList &ol) |
Declares the class options. | |
Private Types | |
typedef PLearner | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. |
Generate samples from a mixture of two gaussians.
Definition at line 51 of file CheckDond2FileSequence.h.
typedef PLearner PLearn::CheckDond2FileSequence::inherited [private] |
Reimplemented from PLearn::PLearner.
Definition at line 53 of file CheckDond2FileSequence.h.
PLearn::CheckDond2FileSequence::CheckDond2FileSequence | ( | ) |
string PLearn::CheckDond2FileSequence::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::PLearner.
Definition at line 51 of file CheckDond2FileSequence.cc.
OptionList & PLearn::CheckDond2FileSequence::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::PLearner.
Definition at line 51 of file CheckDond2FileSequence.cc.
RemoteMethodMap & PLearn::CheckDond2FileSequence::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::PLearner.
Definition at line 51 of file CheckDond2FileSequence.cc.
Reimplemented from PLearn::PLearner.
Definition at line 51 of file CheckDond2FileSequence.cc.
Object * PLearn::CheckDond2FileSequence::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 51 of file CheckDond2FileSequence.cc.
StaticInitializer CheckDond2FileSequence::_static_initializer_ & PLearn::CheckDond2FileSequence::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::PLearner.
Definition at line 51 of file CheckDond2FileSequence.cc.
void PLearn::CheckDond2FileSequence::build | ( | ) | [virtual] |
Finish building the object; just call inherited::build followed by build_()
Reimplemented from PLearn::PLearner.
Definition at line 84 of file CheckDond2FileSequence.cc.
{ // ### Nothing to add here, simply calls build_(). inherited::build(); build_(); }
void PLearn::CheckDond2FileSequence::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::PLearner.
Definition at line 94 of file CheckDond2FileSequence.cc.
References PLearn::endl(), and PLERROR.
{ MODULE_LOG << "build_() called" << endl; if (train_set) { int row; real prev_key; Vec input(train_set->width()); train_set->getRow(0, input); prev_key = input[key_col]; for (row = 1; row < train_set->length(); row++) { train_set->getRow(row, input); if (input[key_col] < prev_key) { cout << "CheckDond2FileSequence: train set out of sequence" << endl; cout << "CheckDond2FileSequence: row: " << row << " previous key: " << prev_key << " current key: " << input[key_col] << endl; PLERROR("CheckDond2FileSequence: we are done here"); } if (input[key_col] == prev_key) { cout << "CheckDond2FileSequence: row: " << row << " previous key: " << prev_key << " current key: " << input[key_col] << endl; } prev_key = input[key_col]; if (row % 25000 == 0) cout << "CheckDond2FileSequence: " << row << " records processed." << endl; } cout << "CheckDond2FileSequence: " << row << " records processed." << endl; PLERROR("CheckDond2FileSequence: we are done here"); } }
string PLearn::CheckDond2FileSequence::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 51 of file CheckDond2FileSequence.cc.
void PLearn::CheckDond2FileSequence::computeCostsFromOutputs | ( | const Vec & | input, |
const Vec & | output, | ||
const Vec & | target, | ||
Vec & | costs | ||
) | const [virtual] |
*** SUBCLASS WRITING: ***
This should be defined in subclasses to compute the weighted costs from already computed output. The costs should correspond to the cost names returned by getTestCostNames().
NOTE: In exotic cases, the cost may also depend on some info in the input, that's why the method also gets so see it.
Implements PLearn::PLearner.
Definition at line 128 of file CheckDond2FileSequence.cc.
{}
void PLearn::CheckDond2FileSequence::computeOutput | ( | const Vec & | input, |
Vec & | output | ||
) | const [virtual] |
*** SUBCLASS WRITING: ***
This should be defined in subclasses to compute the output from the input.
Reimplemented from PLearn::PLearner.
Definition at line 127 of file CheckDond2FileSequence.cc.
{}
void PLearn::CheckDond2FileSequence::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declares the class options.
Reimplemented from PLearn::PLearner.
Definition at line 63 of file CheckDond2FileSequence.cc.
References PLearn::OptionBase::buildoption, PLearn::declareOption(), and key_col.
{ declareOption(ol, "key_col", &CheckDond2FileSequence::key_col, OptionBase::buildoption, "The column of the sequence key."); inherited::declareOptions(ol); }
static const PPath& PLearn::CheckDond2FileSequence::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::PLearner.
Definition at line 83 of file CheckDond2FileSequence.h.
:
//##### Protected Member Functions ######################################
CheckDond2FileSequence * PLearn::CheckDond2FileSequence::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::PLearner.
Definition at line 51 of file CheckDond2FileSequence.cc.
OptionList & PLearn::CheckDond2FileSequence::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 51 of file CheckDond2FileSequence.cc.
OptionMap & PLearn::CheckDond2FileSequence::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 51 of file CheckDond2FileSequence.cc.
RemoteMethodMap & PLearn::CheckDond2FileSequence::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 51 of file CheckDond2FileSequence.cc.
TVec< string > PLearn::CheckDond2FileSequence::getTestCostNames | ( | ) | const [virtual] |
*** SUBCLASS WRITING: ***
This should return the names of the costs computed by computeCostsFromOutputs.
Implements PLearn::PLearner.
Definition at line 129 of file CheckDond2FileSequence.cc.
References PLearn::TVec< T >::append().
{ TVec<string> result; result.append( "MSE" ); return result; }
TVec< string > PLearn::CheckDond2FileSequence::getTrainCostNames | ( | ) | const [virtual] |
*** SUBCLASS WRITING: ***
This should return the names of the objective costs that the train method computes and for which it updates the VecStatsCollector train_stats.
Implements PLearn::PLearner.
Definition at line 135 of file CheckDond2FileSequence.cc.
References PLearn::TVec< T >::append().
{ TVec<string> result; result.append( "MSE" ); return result; }
void PLearn::CheckDond2FileSequence::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::PLearner.
Definition at line 74 of file CheckDond2FileSequence.cc.
References PLearn::deepCopyField().
{ deepCopyField(key_col, copies); inherited::makeDeepCopyFromShallowCopy(copies); }
int PLearn::CheckDond2FileSequence::outputsize | ( | ) | const [virtual] |
SUBCLASS WRITING: override this so that it returns the size of this learner's output, as a function of its inputsize(), targetsize() and set options.
Implements PLearn::PLearner.
Definition at line 125 of file CheckDond2FileSequence.cc.
{return 0;}
void PLearn::CheckDond2FileSequence::train | ( | ) | [virtual] |
*** SUBCLASS WRITING: ***
The role of the train method is to bring the learner up to stage==nstages, updating the stats with training costs measured on-line in the process.
TYPICAL CODE:
static Vec input; // static so we don't reallocate/deallocate memory each time... static Vec target; // (but be careful that static means shared!) input.resize(inputsize()); // the train_set's inputsize() target.resize(targetsize()); // the train_set's targetsize() real weight; if(!train_stats) // make a default stats collector, in case there's none train_stats = new VecStatsCollector(); if(nstages<stage) // asking to revert to a previous stage! forget(); // reset the learner to stage=0 while(stage<nstages) { // clear statistics of previous epoch train_stats->forget(); //... train for 1 stage, and update train_stats, // using train_set->getSample(input, target, weight); // and train_stats->update(train_costs) ++stage; train_stats->finalize(); // finalize statistics for this epoch }
Implements PLearn::PLearner.
Definition at line 126 of file CheckDond2FileSequence.cc.
{}
Reimplemented from PLearn::PLearner.
Definition at line 83 of file CheckDond2FileSequence.h.
### declare public option fields (such as build options) here Start your comments with Doxygen-compatible comments such as //!
Definition at line 61 of file CheckDond2FileSequence.h.
Referenced by declareOptions().