Home || Visual Search || Applications || Architecture || Important Messages || OGL || Src

int @44::RandomForest ( int  argc,
char **  argv 
) [static]

Definition at line 227 of file mainRandomForest.cpp.

References Impala::Core::Training::Factory::CodebookExists(), DumpTree(), DumpTreeCounts(), GetFeatures(), ILOG_ERROR_COUNT, ILOG_FUNCTION, ILOG_INFO, ILOG_WARNING, Impala::CmdOptions::Initialise(), main(), Impala::Core::Feature::MakeFeatureTable(), Impala::Core::Feature::MakeRandomTree(), Impala::CmdOptions::ParseArgs(), ProjectAndDump(), SelectQuids(), Impala::Core::Table::Table::Size(), Impala::Util::Write(), and Impala::Core::Training::Factory::WriteCodebook().

Referenced by main().

00228 {
00229     ILOG_FUNCTION(main);
00230     RandomForestConfig config;
00231     CmdOptions& options = CmdOptions::GetInstance();
00232     options.Initialise(false, false, true);
00233     config.InitOptions(options);
00234     if (options.ParseArgs(argc, argv, "dataSet concepts 0 featureDef", 4))
00235     {
00236         // setup the application
00237         config.RetrieveOptions(options);
00238         Core::Training::Factory factory(&options, false);
00239         if (factory.CodebookExists())
00240         {
00241             ILOG_WARNING("codebook already exists; skipping...");
00242             return ILOG_ERROR_COUNT;
00243         }
00244         
00245         // get the quids of the classes
00246         SelectionTable quidSampling(0);
00247         int nrClasses;
00248         SelectQuids(quidSampling, nrClasses, &factory);
00249         Feature::AnnotatedFeatureTable featureSampling
00250             (Vector::ColumnVectorSet(true, 64, 0), Column::ColumnInt32(0));
00251         
00252         // get the features
00253         GetFeatures(featureSampling, quidSampling, &factory, config.surfParams);
00254         ILOG_INFO("got "<< featureSampling.Size() <<" samples for random forest");
00255         
00256         // make the forest
00257         Feature::RandomTreeTable forest(0);
00258         for(int i=0 ; i<4 ; ++i)
00259         {
00260             Util::Random rng;
00261             rng.SetSeed(i);
00262             Feature::RandomTree* tree = Feature::MakeRandomTree
00263                 (&featureSampling, nrClasses, config.depth, config.tries, rng);
00264             Write(tree, &forest);
00265             if(config.dumpTreeCounts)
00266                 DumpTreeCounts(tree, i);
00267             if(config.dumpTree)
00268                 DumpTree(tree);
00269             delete tree;
00270         }
00271 
00272         if(forest.Size() > 0)
00273         {
00274             // save results to disk
00275             Feature::FeatureTable* ft = Feature::MakeFeatureTable(&forest);
00276             if(config.projectAndDump)
00277                 ProjectAndDump(ft, featureSampling);
00278             factory.WriteCodebook(ft);
00279             ILOG_INFO("saved code books");
00280             delete ft;
00281         }
00282     }
00283     return ILOG_ERROR_COUNT;
00284 }

Here is the call graph for this function:


Generated on Thu Jan 13 09:05:38 2011 for ImpalaSrc by  doxygen 1.5.1