Definition at line 227 of file mainRandomForest.cpp. References Impala::Core::DataFactory::CanWriteCodebook(), DumpTree(), DumpTreeCounts(), GetFeatures(), ILOG_FUNCTION, ILOG_INFO, ILOG_WARNING, Impala::CmdOptions::Initialise(), main(), Impala::Core::ApplicationFactory::MakeDataFactory(), Impala::Core::Feature::MakeFeatureTable(), Impala::Core::Feature::MakeRandomTree(), Impala::CmdOptions::ParseArgs(), ProjectAndDump(), SelectQuids(), Impala::Util::SetRandomSeed(), Impala::Core::Table::Table::Size(), Impala::Core::Table::Write(), Impala::Core::DataFactory::WriteCodebook(), and Impala::Core::DataFactory::WriteRandomForest(). 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::ApplicationFactory factory(&options); 00239 DataFactory* dataFactory = factory.MakeDataFactory(); 00240 if(!dataFactory->CanWriteCodebook()) 00241 { 00242 ILOG_WARNING("codebook already exists; skipping..."); 00243 delete dataFactory; 00244 return 0; 00245 } 00246 00247 // get the quids of the classes 00248 SelectionTable quidSampling(0); 00249 int nrClasses; 00250 SelectQuids(quidSampling, nrClasses, dataFactory); 00251 Feature::AnnotatedFeatureTable featureSampling 00252 (Vector::ColumnVectorSet(true, 64, 0), Column::ColumnInt32(0)); 00253 00254 // get the features 00255 GetFeatures(featureSampling, quidSampling, dataFactory, config.surfParams); 00256 ILOG_INFO("got "<< featureSampling.Size() <<" samples for random forest"); 00257 00258 // make the forest 00259 Feature::RandomTreeTable forest(0); 00260 for(int i=0 ; i<4 ; ++i) 00261 { 00262 Util::SetRandomSeed(i); 00263 Feature::RandomTree* tree = Feature::MakeRandomTree 00264 (&featureSampling, nrClasses, config.depth, config.tries); 00265 Write(tree, &forest); 00266 if(config.dumpTreeCounts) 00267 DumpTreeCounts(tree, i); 00268 if(config.dumpTree) 00269 DumpTree(tree); 00270 delete tree; 00271 } 00272 00273 if(forest.Size() > 0) 00274 { 00275 // save results to disk 00276 dataFactory->WriteRandomForest(&forest); 00277 Feature::FeatureTable* ft = Feature::MakeFeatureTable(&forest); 00278 if(config.projectAndDump) 00279 ProjectAndDump(ft, featureSampling); 00280 dataFactory->WriteCodebook(ft); 00281 ILOG_INFO("saved code books"); 00282 delete ft; 00283 } 00284 delete dataFactory; 00285 } 00286 return 0; 00287 }
Here is the call graph for this function:
|