Definition at line 26 of file mainActiveLearner.cpp. References Impala::Util::PropertySet::Add(), Impala::Core::Table::Copy(), Impala::Core::Matrix::DistributedAccess::GetColumnQuids(), Impala::CmdOptions::GetInt(), Impala::Util::PropertySet::GetName(), Impala::Core::Matrix::DistributedAccess::GetRowQuids(), Impala::Util::PropertySet::GetValue(), ILOG_INFO, ILOG_VAR, Impala::Core::Training::Svm::PredictForActiveLearn(), Impala::Core::Table::Select(), Impala::Util::PropertySet::Size(), and Impala::Core::Training::Svm::Train(). Referenced by RunDistributedLearningEngine(). 00030 { 00031 ILOG_VAR(Application.LearnConceptFromAnnotations); 00032 00033 00034 ILOG_INFO("concept " << concept); 00035 00036 //load annotation 00037 Table::QuidTable* allQuids = da->GetColumnQuids(); 00038 Table::CriterionElement1InSet<Table::AnnotationTable> c(allQuids); 00039 Table::AnnotationTable* annotation = Select(annotations, c); 00040 00041 Table::QuidTable* positive = annotation->GetPositive(); 00042 Table::QuidTable* negative = annotation->GetNegative(); 00043 Table::QuidTable* learnQuids = positive; 00044 learnQuids->Append(negative); 00045 delete negative; 00046 00047 if ((positive->Size() == 0) || (negative->Size() == 0)) 00048 { 00049 delete learnQuids; 00050 delete annotation; 00051 return 0; 00052 } 00053 00054 Util::PropertySet params; 00055 params.Add("probability", 1); 00056 params.Add("cache", options.GetInt("cache")); 00057 00058 params.Add("gamma", -1); 00059 params.Add("autoweight", 1); 00060 params.Add("kernel", "dist-precomputed"); 00061 params.Add("precompute-kernel", "chi2"); 00062 params.Add("evaluator", "AP"); 00063 params.Add("C", 1.0); 00064 params.Add("w1", 30.0); // estimate these 00065 params.Add("w2", 1.2); // estimate these 00066 for(int i = 0; i < params.Size(); i++) 00067 ILOG_INFO(params.GetName(i) + " " + params.GetValue(i)); 00068 00069 //compute model: 00070 Training::Svm svm; 00071 Training::TrainDataSrcKernelDistributed* dataSrc = 00072 new TrainDataSrcKernelDistributed(da, annotation); 00073 svm.Train(¶ms, dataSrc); 00074 ILOG_INFO("saving model"); 00075 SvmRepository().Add(modelLoc, &svm); 00076 00077 // compute resulting ranking: 00078 std::vector<String> names; 00079 names.push_back(concept); 00080 Table::QuidTable* rowQuids = da->GetRowQuids(); 00081 Table::SimilarityTableSet *simSet = 00082 new Table::SimilarityTableSet(names, rowQuids->Size()); 00083 Table::Copy(simSet->GetQuidTable(), rowQuids); 00084 00085 ILOG_INFO("applying model"); 00086 svm.PredictForActiveLearn(da, learnQuids, simSet->GetSimTable(0)); 00087 00088 ILOG_INFO("ranking"); 00089 simSet->ComputeRank(0, true); 00090 00091 delete annotation; 00092 delete learnQuids; 00093 delete dataSrc; 00094 return simSet; 00095 }
Here is the call graph for this function: ![]()
|