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

double svm_predict ( const svm_model model,
const svm_node x 
)

Definition at line 2264 of file svm.cpp.

References EPSILON_SVR, svm_model::label, Malloc, svm_model::nr_class, NU_SVR, ONE_CLASS, svm_model::param, svm_predict_values(), and svm_parameter::svm_type.

Referenced by Impala::Core::Trec::TrecSVM::Predict(), Impala::Core::Training::Svm::PredictSingle(), svm_cross_validation(), and svm_predict_probability().

02265 {
02266         if(model->param.svm_type == ONE_CLASS ||
02267            model->param.svm_type == EPSILON_SVR ||
02268            model->param.svm_type == NU_SVR)
02269         {
02270                 double res;
02271                 svm_predict_values(model, x, &res);
02272                 
02273                 if(model->param.svm_type == ONE_CLASS)
02274                         return (res>0)?1:-1;
02275                 else
02276                         return res;
02277         }
02278         else
02279         {
02280                 int i;
02281                 int nr_class = model->nr_class;
02282                 double *dec_values = Malloc(double, nr_class*(nr_class-1)/2);
02283                 svm_predict_values(model, x, dec_values);
02284 
02285                 int *vote = Malloc(int,nr_class);
02286                 for(i=0;i<nr_class;i++)
02287                         vote[i] = 0;
02288                 int pos=0;
02289                 for(i=0;i<nr_class;i++)
02290                         for(int j=i+1;j<nr_class;j++)
02291                         {
02292                                 if(dec_values[pos++] > 0)
02293                                         ++vote[i];
02294                                 else
02295                                         ++vote[j];
02296                         }
02297 
02298                 int vote_max_idx = 0;
02299                 for(i=1;i<nr_class;i++)
02300                         if(vote[i] > vote[vote_max_idx])
02301                                 vote_max_idx = i;
02302                 free(vote);
02303                 free(dec_values);
02304                 return model->label[vote_max_idx];
02305         }
02306 }

Here is the call graph for this function:


Generated on Fri Mar 19 10:17:14 2010 for ImpalaSrc by  doxygen 1.5.1