#include <SequentialModelSelector.h>
Inheritance diagram for PLearn::SequentialModelSelector:
Public Member Functions | |
SequentialModelSelector () | |
Constructor. | |
real | sequenceCost (const Vec &sequence_errors) |
compute the cost of the given sequence of errors (based on the cost_type) | |
real | paired_t_test (const int &m1, const int &m2, int cc=0) const |
Computes a paired t-test between common_cost[cc] series of models m1 and m2. | |
virtual void | build () |
simply calls inherited::build() then build_() | |
virtual void | setExperimentDirectory (const string &_expdir) |
Redefines so that it ALSO calls the method on all the learners in the TVec models. | |
virtual void | train () |
virtual void | test (VMat testset, PP< VecStatsCollector > test_stats, VMat testoutputs=0, VMat testcosts=0) const |
virtual void | computeOutput (const Vec &input, Vec &output) const |
*** SUBCLASS WRITING: *** This should be defined in subclasses to compute the output from the input | |
virtual void | computeCostsFromOutputs (const Vec &input, const Vec &output, const Vec &target, Vec &costs) const |
*** SUBCLASS WRITING: *** This should be defined in subclasses to compute the weighted costs from already computed output. | |
virtual void | computeOutputAndCosts (const Vec &input, const Vec &target, Vec &output, Vec &costs) const |
Default calls computeOutput and computeCostsFromOutputs You may overload this if you have a more efficient way to compute both output and weighted costs at the same time. | |
virtual void | computeCostsOnly (const Vec &input, const Vec &target, Vec &costs) const |
Default calls computeOutputAndCosts This may be overloaded if there is a more efficient way to compute the costs directly, without computing the whole output vector. | |
virtual void | matlabSave (const string &matlab_subdir) |
virtual TVec< string > | getTestCostNames () const |
This should return the names of the costs computed by computeCostsFromOutputs. | |
virtual TVec< string > | getTrainCostNames () const |
This should return the names of the objective costs that the train method computes and for which it updates the VecStatsCollector train_stats. | |
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!) | |
PLEARN_DECLARE_OBJECT (SequentialModelSelector) | |
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 | makeDeepCopyFromShallowCopy (CopiesMap &copies) |
Public Attributes | |
bool | stepwise_save |
TVec< PP< SequentialLearner > > | models |
List of all the models. | |
TVec< string > | model_names |
If the user desires to provide a name for each model instead of model_i. | |
TVec< string > | common_costs |
int | comparison_type |
int | comparison_window |
Static Protected Member Functions | |
void | declareOptions (OptionList &ol) |
Declare this class' options. | |
Protected Attributes | |
TMat< int > | common_cost_indices |
See common_costs options for details. Row index: model. Column index: common_cost. | |
TVec< int > | best_model |
Vec | sequence_costs |
bool | report_paired_T_tests |
Private Types | |
typedef SequentialLearner | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. | |
void | checkModelNames () const |
|
Reimplemented from PLearn::SequentialLearner. Definition at line 55 of file SequentialModelSelector.h. |
|
Constructor.
Definition at line 48 of file SequentialModelSelector.cc. |
|
simply calls inherited::build() then build_()
Reimplemented from PLearn::SequentialLearner. Definition at line 106 of file SequentialModelSelector.cc. References build_(). |
|
This does the actual building.
Reimplemented from PLearn::SequentialLearner. Definition at line 71 of file SequentialModelSelector.cc. References best_model, common_cost_indices, common_costs, forget(), PLearn::TVec< string >::length(), PLearn::TVec< PP< SequentialLearner > >::length(), models, PLERROR, PLWARNING, PLearn::TVec< T >::resize(), PLearn::TVec< int >::resize(), PLearn::TMat< int >::resize(), and sequence_costs. Referenced by build(). |
|
Definition at line 460 of file SequentialModelSelector.cc. References PLearn::TVec< string >::length(), PLearn::TVec< PP< SequentialLearner > >::length(), model_names, models, PLERROR, PLearn::TVec< string >::resize(), and PLearn::tostring(). Referenced by getTestCostNames(), and setExperimentDirectory(). |
|
*** 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. Reimplemented from PLearn::SequentialLearner. Definition at line 442 of file SequentialModelSelector.cc. References best_model, and models. |
|
Default calls computeOutputAndCosts This may be overloaded if there is a more efficient way to compute the costs directly, without computing the whole output vector.
Reimplemented from PLearn::SequentialLearner. Definition at line 454 of file SequentialModelSelector.cc. References best_model, and models. |
|
*** SUBCLASS WRITING: *** This should be defined in subclasses to compute the output from the input
Reimplemented from PLearn::SequentialLearner. Definition at line 437 of file SequentialModelSelector.cc. References best_model, and models. |
|
Default calls computeOutput and computeCostsFromOutputs You may overload this if you have a more efficient way to compute both output and weighted costs at the same time.
Reimplemented from PLearn::SequentialLearner. Definition at line 448 of file SequentialModelSelector.cc. References best_model, and models. |
|
Declare this class' options.
Reimplemented from PLearn::SequentialLearner. Definition at line 112 of file SequentialModelSelector.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!) *** SUBCLASS WRITING: *** A typical forget() method should do the following:
Reimplemented from PLearn::SequentialLearner. Definition at line 200 of file SequentialModelSelector.cc. References best_model, PLearn::TVec< int >::fill(), models, PLearn::TVec< int >::resize(), and PLearn::TVec< PP< SequentialLearner > >::size(). Referenced by build_(). |
|
This should return the names of the costs computed by computeCostsFromOutputs.
Implements PLearn::PLearner. Definition at line 474 of file SequentialModelSelector.cc. References PLearn::TVec< T >::append(), checkModelNames(), common_costs, PLearn::TVec< T >::length(), PLearn::TVec< PP< SequentialLearner > >::length(), model_names, models, and report_paired_T_tests. |
|
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 495 of file SequentialModelSelector.cc. References common_costs. |
|
Does the necessary operations to transform a shallow copy (this) into a deep copy by deep-copying all the members that need to be. Typical implementation: void CLASS_OF_THIS::makeDeepCopyFromShallowCopy(CopiesMap& copies) { SUPERCLASS_OF_THIS::makeDeepCopyFromShallowCopy(copies); member_ptr = member_ptr->deepCopy(copies); member_smartptr = member_smartptr->deepCopy(copies); member_mat.makeDeepCopyFromShallowCopy(copies); member_vec.makeDeepCopyFromShallowCopy(copies); ... } Reimplemented from PLearn::SequentialLearner. Definition at line 498 of file SequentialModelSelector.cc. References PLearn::CopiesMap, PLearn::deepCopyField(), and models. |
|
Any SequentialLearner will have the possiblity to save some data in a matlab 'readable' format. The data will be saved in expdir/matlab_subdir through the global matlabSave function (MatIO.h). Reimplemented from PLearn::SequentialLearner. Definition at line 505 of file SequentialModelSelector.cc. References PLearn::add(), PLearn::TVec< T >::append(), PLearn::append_slash(), common_cost_indices, common_costs, PLearn::concat(), PLearn::PLearner::getExperimentDirectory(), PLearn::hconcat(), PLearn::TVec< T >::length(), PLearn::TVec< string >::length(), PLearn::TVec< PP< SequentialLearner > >::length(), PLearn::Mat, PLearn::matlabSave(), model_names, models, and PLearn::TVec< T >::subVec(). |
|
Computes a paired t-test between common_cost[cc] series of models m1 and m2.
Definition at line 182 of file SequentialModelSelector.cc. References PLearn::TMat< T >::column(), common_cost_indices, PLearn::TVec< T >::length(), PLearn::mean(), models, PLERROR, PLearn::remove_missing(), PLearn::sqrt(), and PLearn::sumsquare(). |
|
Does the necessary operations to transform a shallow copy (this) into a deep copy by deep-copying all the members that need to be.
|
|
compute the cost of the given sequence of errors (based on the cost_type)
Definition at line 157 of file SequentialModelSelector.cc. References PLearn::abs(), comparison_type, comparison_window, PLearn::TVec< T >::length(), PLearn::mean(), MISSING_VALUE, PLERROR, PLearn::TVec< T >::subVec(), and PLearn::variance(). Referenced by train(). |
|
Redefines so that it ALSO calls the method on all the learners in the TVec models.
Reimplemented from PLearn::PLearner. Definition at line 55 of file SequentialModelSelector.cc. References PLearn::append_slash(), checkModelNames(), PLearn::TVec< PP< SequentialLearner > >::length(), model_names, and models. |
|
*** SUBCLASS WRITING: *** The method should:
Implements PLearn::SequentialLearner. Definition at line 346 of file SequentialModelSelector.cc. References PLearn::TVec< T >::append(), PLearn::append_slash(), best_model, PLearn::ProgressBar::close(), common_cost_indices, PLearn::endl(), PLearn::TVec< PP< SequentialLearner > >::length(), PLearn::VMat::length(), MAX, MISSING_VALUE, models, PLearn::paired_t_test(), PLWARNING, report_paired_T_tests, PLearn::saveAsciiWithoutSize(), PLearn::TVec< PP< SequentialLearner > >::size(), stepwise_save, PLearn::tostring(), PLearn::ProgressBar::update(), and PLearn::update(). |
|
|
Definition at line 70 of file SequentialModelSelector.h. Referenced by build_(), computeCostsFromOutputs(), computeCostsOnly(), computeOutput(), computeOutputAndCosts(), forget(), test(), and train(). |
|
See common_costs options for details. Row index: model. Column index: common_cost.
Definition at line 69 of file SequentialModelSelector.h. Referenced by build_(), matlabSave(), paired_t_test(), test(), and train(). |
|
The names of costs that are common to all models and that the user wishes the model selector to keep track of. The first one is considered to be the main cost, the one from which models will be compared to choose the best model. Definition at line 112 of file SequentialModelSelector.h. Referenced by build_(), getTestCostNames(), getTrainCostNames(), and matlabSave(). |
|
From the common_costs list, the first cost is the one from which models will be compared to choose the best model. But should the best model be chosen according to the max/min +/- 1: Mean +/- 2: Mean / Variance +/- 3: more to come. of the cost realizations. Default: 1. Definition at line 126 of file SequentialModelSelector.h. Referenced by sequenceCost(), and train(). |
|
If positive, the comparison performed on the basis of common_cost[0] will be applyed only the comparison_window last elements of the cost sequence. Default: -1. (No window) Definition at line 133 of file SequentialModelSelector.h. Referenced by sequenceCost(). |
|
If the user desires to provide a name for each model instead of model_i.
Definition at line 105 of file SequentialModelSelector.h. Referenced by checkModelNames(), getTestCostNames(), matlabSave(), and setExperimentDirectory(). |
|
List of all the models.
Definition at line 102 of file SequentialModelSelector.h. Referenced by build_(), checkModelNames(), computeCostsFromOutputs(), computeCostsOnly(), computeOutput(), computeOutputAndCosts(), forget(), getTestCostNames(), makeDeepCopyFromShallowCopy(), matlabSave(), paired_t_test(), setExperimentDirectory(), test(), and train(). |
|
If true, the model selector will report as costs the paired T tests on common_cost_indices[0] for models[0] against each other model. The model selector will only report T tests once, at t=(max_seq_len-1) Default: false. Definition at line 80 of file SequentialModelSelector.h. Referenced by getTestCostNames(), and test(). |
|
Definition at line 71 of file SequentialModelSelector.h. |
|
Does the model selector hass to save errors at each step. Default: true. Definition at line 99 of file SequentialModelSelector.h. |