main.cpp

00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 //#include <iostream>
00004 #include <fstream>
00005 #include <string.h>
00006 #include <string>
00007 #include <math.h>
00008 #include <vector>
00009 #include <deque>
00010 
00011 #include "config.h"
00012 #include "Data.h"
00013 #include "Scheduler.h"
00014 #include "StreamOutput.h"
00015 #include "AlgorithmExploration.h"
00016 #include "NumericalTools.h"
00017 
00090 using namespace std;
00091 
00092 StreamOutput cout;
00093 
00094 int main ( int argc, char *argv[] )
00095 {
00096     // number of arguments check
00097     if ( argc <= 1 )
00098     {
00099         cout<<"1) Please supply at least one argument [e] for algorithm exploration"<<endl;
00100         cout<<"2) Please supply a dataset directory and [t,p,b,x,y] for training, prediction, blending, bagging or boosting"<<endl;
00101         cout<<"   Example: ./EnsembleLearningFramework MNIST t"<<endl<<endl;
00102         exit ( 0 );
00103     }
00104 
00105     // set max. number of threads for OPENMP sections
00106     Framework::setMaxThreads ( omp_get_max_threads() );  // store max. number of threads of the machine
00107 
00108     // Algorithm exploration
00109     // one argument 'e'
00110     if ( argc == 2 )
00111         if ( argv[1][0] == 'e' || argv[1][0] == 'E' )
00112         {
00113             AlgorithmExploration a;
00114             a.start();
00115             exit ( 0 );
00116         }
00117 
00118     // training/prediction/blending
00119     // two arguments: 'DATASET'  and 't' 'p' or 'b' for train, predict or blend
00120     if ( argc <= 2 )
00121     {
00122         cout<<"Please supply a dataset directory and [t,p,b,x,y] for training, prediction, blending, bagging or boosting"<<endl;
00123         cout<<"Example: ./EnsembleLearningFramework MNIST t"<<endl<<endl;
00124         exit ( 0 );
00125     }
00126     if ( argc >= 4 )
00127         Framework::setAdditionalStartupParameter ( argv[3] );
00128 
00129     // the scheduler is responsible for sequential training of the algorithms
00130     // at the begining, the master description file is read
00131     Scheduler s;
00132     s.readMasterDscFile ( argv[1], "Master.dsc" );
00133 
00134     // training mode
00135     if ( argv[2][0] == 't' || argv[2][0] == 'T' )
00136         s.train();
00137 
00138     // prediction mode
00139     if ( argv[2][0] == 'p' || argv[2][0] == 'P' )
00140         s.predict();
00141 
00142     // blending mode (after successful training)
00143     if ( argv[2][0] == 'b' || argv[2][0] == 'B' )
00144         s.blend();
00145 
00146     // OBSOLETE! bagging: produce a set of predictions with slightly modified train set and average them
00147     if ( argv[2][0] == 'x' || argv[2][0] == 'X' )
00148         s.bagging();
00149 
00150     // OBSOLETE! boosting: reweight sample probabilites based on train error
00151     if ( argv[2][0] == 'y' || argv[2][0] == 'Y' )
00152         s.boosting();
00153 
00154     return 0;
00155 }

Generated on Tue Jan 26 09:20:59 2010 for ELF by  doxygen 1.5.8