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

virtual void Impala::Core::Training::Svm::Train ( Util::PropertySet properties,
TrainDataSrc data 
) [inline, virtual]

Trains a model.

Note:
The use of random numbers by libsvm is cumbersome with regression tests. In our current setup, libsvm only uses random numbers when training the "final" model, not during crossvalidation. With precomputed kernels, there is no difference the MPI and the non-MPI version since a single process does the training. However, the old-fashioned way of training uses various processes and thus produces different probA and probB values in the model. To prevent this, we reset the random seed when training a probabilistic 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:


Generated on Thu Jan 13 09:21:20 2011 for ImpalaSrc by  doxygen 1.5.1