Definition at line 2308 of file svm.cpp. References C_SVC, svm_model::label, Malloc, max, min, multiclass_probability(), svm_model::nr_class, NU_SVC, svm_model::param, svm_model::probA, svm_model::probB, sigmoid_predict(), svm_predict(), svm_predict_values(), and svm_parameter::svm_type. Referenced by Impala::Core::Training::Svm::PredictSingle(), and svm_cross_validation(). 02310 { 02311 if ((model->param.svm_type == C_SVC || model->param.svm_type == NU_SVC) && 02312 model->probA!=NULL && model->probB!=NULL) 02313 { 02314 int i; 02315 int nr_class = model->nr_class; 02316 double *dec_values = Malloc(double, nr_class*(nr_class-1)/2); 02317 svm_predict_values(model, x, dec_values); 02318 02319 double min_prob=1e-7; 02320 double **pairwise_prob=Malloc(double *,nr_class); 02321 for(i=0;i<nr_class;i++) 02322 pairwise_prob[i]=Malloc(double,nr_class); 02323 int k=0; 02324 for(i=0;i<nr_class;i++) 02325 for(int j=i+1;j<nr_class;j++) 02326 { 02327 pairwise_prob[i][j]=min(std::max(sigmoid_predict(dec_values[k],model->probA[k],model->probB[k]),min_prob),1-min_prob); 02328 pairwise_prob[j][i]=1-pairwise_prob[i][j]; 02329 k++; 02330 } 02331 multiclass_probability(nr_class,pairwise_prob,prob_estimates); 02332 02333 int prob_max_idx = 0; 02334 for(i=1;i<nr_class;i++) 02335 if(prob_estimates[i] > prob_estimates[prob_max_idx]) 02336 prob_max_idx = i; 02337 for(i=0;i<nr_class;i++) 02338 free(pairwise_prob[i]); 02339 free(dec_values); 02340 free(pairwise_prob); 02341 return model->label[prob_max_idx]; 02342 } 02343 else 02344 return svm_predict(model, x); 02345 }
Here is the call graph for this function:
|