00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
#ifndef SEQUENTIAL_MODEL_SELECTOR
00039 
#define SEQUENTIAL_MODEL_SELECTOR
00040 
00041 
#include "SequentialLearner.h"
00042 
00043 
namespace PLearn {
00044 
using namespace std;
00045 
00049 class SequentialModelSelector: 
public SequentialLearner
00050 {
00051 
private:
00052   
00053   
00054   
00055   typedef SequentialLearner inherited;
00056 
00058   
void build_();
00059 
00060   
void checkModelNames() const;
00061 
00062 protected:
00063 
00064   
00065   
00066   
00067   
00069   TMat<
int> common_cost_indices;
00070   TVec<
int> best_model; 
00071   Vec sequence_costs;  
00072 
00080   bool report_paired_T_tests;
00081 
00082   
00083   
00084   
00085   
00087   static 
void declareOptions(
OptionList& ol);
00088   
00089 public:
00090 
00091   
00092   
00093   
00094 
00099   bool stepwise_save;
00100 
00102   TVec< 
PP<
SequentialLearner> > models;  
00103 
00105   mutable 
TVec< 
string > model_names;
00106 
00112   TVec<
string> common_costs;
00113   
00126   int comparison_type;
00127 
00133   int comparison_window;
00134 
00135   
00136   
00137   
00138 
00140   
SequentialModelSelector();
00141 
00143   
real sequenceCost(const 
Vec& sequence_errors);
00144   
00146   
real paired_t_test(const 
int& m1, const 
int& m2, 
int cc=0) const;
00147 
00149   virtual 
void build();
00150 
00152   virtual 
void setExperimentDirectory(const 
string& _expdir);
00153   
00154   virtual 
void train();
00155  
00156   virtual 
void test(
VMat testset, 
PP<
VecStatsCollector> test_stats,
00157         
VMat testoutputs=0, 
VMat testcosts=0) const;
00158 
00159   virtual 
void computeOutput(const 
Vec& input, 
Vec& output) const;
00160   
00161   virtual 
void computeCostsFromOutputs(const 
Vec& input, const 
Vec& output,
00162                                        const 
Vec& target, 
Vec& costs) const;
00163   
00164   virtual 
void computeOutputAndCosts(const 
Vec& input, const 
Vec& target,
00165                                      
Vec& output, 
Vec& costs) const;
00166   
00167   virtual 
void computeCostsOnly(const 
Vec& input, const 
Vec& target, 
Vec& costs) const;
00168 
00169   virtual 
void matlabSave(const 
string& matlab_subdir);
00170 
00172   virtual 
TVec<
string> getTestCostNames() const;
00173   
00176   virtual 
TVec<
string> getTrainCostNames() const;
00177 
00178   virtual 
void forget();
00179   
00182   PLEARN_DECLARE_OBJECT(
SequentialModelSelector);
00183   virtual 
void makeDeepCopyFromShallowCopy(CopiesMap& copies);
00184 };
00185 
00187 DECLARE_OBJECT_PTR(SequentialModelSelector);
00188 
00189 } 
00190 
00191 #endif