Definition at line 46 of file mainTrainModel.cpp. References Impala::Core::DataFactory::CanMakeConceptModel(), Impala::Core::Training::AveragePrecision::Compute(), Impala::Core::Training::AveragePrecision::ComputeReversed(), Impala::Core::Training::Factory::GetBestFileParams(), ILOG_DEBUG, ILOG_VAR, main(), Impala::Core::DataFactory::MakeAnnotation(), Impala::Core::Training::Factory::MakeClassifier(), Impala::Core::DataFactory::MakeConceptList(), Impala::Core::Training::Factory::MakeDataSrc(), Impala::Core::Training::Classifier::Predict(), Impala::Util::Mpi::SelectWorkLoadInPlace(), Impala::Util::PropertySet::Size(), Impala::Core::Training::Classifier::Train(), Impala::Core::DataFactory::WriteConceptModel(), and Impala::Core::DataFactory::WriteScoreOnSelf(). Referenced by mainTrainModel(). 00048 { 00049 ILOG_VAR(main); 00050 std::vector<String> conceptList = dataFactory->MakeConceptList(); 00051 if(!distKernel) 00052 Util::Mpi::SelectWorkLoadInPlace(&conceptList); 00053 for (int i=0 ; i<conceptList.size(); ++i) 00054 { 00055 String concept = conceptList[i]; 00056 00057 if(!dataFactory->CanMakeConceptModel(concept)) 00058 { 00059 ILOG_WARNING_NODE("cannot create model for " << concept << 00060 "; skipping concept"); 00061 continue; 00062 } 00063 ILOG_INFO_NODE("concept " << concept); 00064 00065 // read params 00066 Util::PropertySet params = 00067 trainFactory->GetBestFileParams(dataFactory, concept); 00068 ILOG_INFO_NODE(params); 00069 if(params.Size() == 0) 00070 { 00071 ILOG_WARNING_NODE("no best file found for " << concept << 00072 "; skipping concept"); 00073 continue; 00074 } 00075 00076 //load annotation 00077 Table::AnnotationTable* annotation = dataFactory->MakeAnnotation(concept); 00078 if(annotation == 0) 00079 { 00080 ILOG_WARNING_NODE("no annotation found for " << concept << 00081 "; skipping concept"); 00082 continue; 00083 } 00084 annotation->Sort(); 00085 00086 //compute model 00087 TrainDataSrc* src = trainFactory->MakeDataSrc(annotation, dataFactory); 00088 Core::Training::Classifier* svm = trainFactory->MakeClassifier("svm"); 00089 svm->Train(¶ms, src); 00090 dataFactory->WriteConceptModel(concept, svm); 00091 00092 // score on self 00093 Table::ScoreTable* ranking = svm->Predict(src); 00094 Training::AveragePrecision ap(annotation); 00095 double score = ap.Compute(ranking); 00096 if(score < ap.ComputeReversed(ranking)) 00097 { 00098 ILOG_ERROR_NODE("reversed ranking > normal ranking => logic error in svm"); 00099 } 00100 delete ranking; 00101 dataFactory->WriteScoreOnSelf(concept, score); 00102 ILOG_INFO_NODE("score on self = " << score); 00103 ILOG_DEBUG("deleting svm"); 00104 delete svm; 00105 ILOG_DEBUG_NODE("deleting src"); 00106 delete src; 00107 ILOG_DEBUG_NODE("deleting annotation"); 00108 delete annotation; 00109 ILOG_DEBUG_NODE("done iteration"); 00110 } 00111 return 0; 00112 }
Here is the call graph for this function:
|