Trains a model.
Implements Impala::Core::Training::Classifier. Definition at line 104 of file Svm.h. References Impala::Util::PropertySet::Add(), CheckTestMode(), Impala::Core::Training::TrainDataSrc::FreeProblem(), Impala::Util::PropertySet::GetBool(), Impala::Util::PropertySet::GetString(), Impala::Core::Training::TrainDataSrc::GetTotalNegativeCount(), Impala::Core::Training::TrainDataSrc::GetTotalPositiveCount(), Impala::Core::Training::TrainDataSrc::GetVectorLength(), ILOG_DEBUG, Impala::Core::Training::TrainDataSrc::MakeSvmProblem(), and SetModel(). Referenced by Impala::Application::LearnConceptFromAnnotations(). 00105 { 00106 if (properties->GetBool("autoweight")) 00107 { 00108 double pos = data->GetTotalPositiveCount(); 00109 double neg = data->GetTotalNegativeCount(); 00110 double posweight = (pos+neg) / pos; 00111 double negweight = (pos+neg) / neg; 00112 properties->Add("w1", posweight); 00113 properties->Add("w2", negweight); 00114 ILOG_DEBUG("autoweight: w+1=" << posweight << " w-1= " << negweight); 00115 } 00116 if ((properties->GetBool("probability")) && 00117 (properties->GetString("kernel") == "rbf")) 00118 { 00119 //ILOG_WARNING("[Train] Random seed reset"); 00120 std::srand(1); 00121 } 00122 svm_parameter* parameters = 00123 MakeSvmParams(properties, data->GetVectorLength(), 0); 00124 svm_problem* p = data->MakeSvmProblem(); 00125 CheckTestMode(p); 00126 ILOG_DEBUG_NODE("svm_train called with problem size = " << p->l); 00127 svm_model* model = svm_train(p, parameters); 00128 FixModelDependency(model); 00129 data->FreeProblem(p); 00130 DestroySvmParameters(parameters); 00131 SetModel(model); 00132 }
Here is the call graph for this function:
|