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

void svm_predict_values ( const svm_model model,
const svm_node x,
double *  dec_values 
)

Definition at line 2209 of file svm.cpp.

References EPSILON_SVR, Kernel::k_function(), svm_model::l, Malloc, svm_model::nr_class, svm_model::nSV, NU_SVR, ONE_CLASS, svm_model::param, svm_model::rho, svm_model::SV, svm_model::sv_coef, and svm_parameter::svm_type.

Referenced by svm_binary_svc_probability(), svm_predict(), and svm_predict_probability().

02210 {
02211         if(model->param.svm_type == ONE_CLASS ||
02212            model->param.svm_type == EPSILON_SVR ||
02213            model->param.svm_type == NU_SVR)
02214         {
02215                 double *sv_coef = model->sv_coef[0];
02216                 double sum = 0;
02217                 for(int i=0;i<model->l;i++)
02218                         sum += sv_coef[i] * Kernel::k_function(x,model->SV[i],model->param);
02219                 sum -= model->rho[0];
02220                 *dec_values = sum;
02221         }
02222         else
02223         {
02224                 int i;
02225                 int nr_class = model->nr_class;
02226                 int l = model->l;
02227                 
02228                 double *kvalue = Malloc(double,l);
02229                 for(i=0;i<l;i++)
02230                         kvalue[i] = Kernel::k_function(x,model->SV[i],model->param);
02231 
02232                 int *start = Malloc(int,nr_class);
02233                 start[0] = 0;
02234                 for(i=1;i<nr_class;i++)
02235                         start[i] = start[i-1]+model->nSV[i-1];
02236 
02237                 int p=0;
02238                 int pos=0;
02239                 for(i=0;i<nr_class;i++)
02240                         for(int j=i+1;j<nr_class;j++)
02241                         {
02242                                 double sum = 0;
02243                                 int si = start[i];
02244                                 int sj = start[j];
02245                                 int ci = model->nSV[i];
02246                                 int cj = model->nSV[j];
02247                                 
02248                                 int k;
02249                                 double *coef1 = model->sv_coef[j-1];
02250                                 double *coef2 = model->sv_coef[i];
02251                                 for(k=0;k<ci;k++)
02252                                         sum += coef1[si+k] * kvalue[si+k];
02253                                 for(k=0;k<cj;k++)
02254                                         sum += coef2[sj+k] * kvalue[sj+k];
02255                                 sum -= model->rho[p++];
02256                                 dec_values[pos++] = sum;
02257                         }
02258 
02259                 free(kvalue);
02260                 free(start);
02261         }
02262 }

Here is the call graph for this function:


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