Definition at line 1288 of file svm.cpp. References svm_problem::l, min, svm_parameter::nu, and svm_problem::y. Referenced by svm_train_one(). 01291 { 01292 int i; 01293 int l = prob->l; 01294 double nu = param->nu; 01295 01296 schar *y = new schar[l]; 01297 01298 for(i=0;i<l;i++) 01299 if(prob->y[i]>0) 01300 y[i] = +1; 01301 else 01302 y[i] = -1; 01303 01304 double sum_pos = nu*l/2; 01305 double sum_neg = nu*l/2; 01306 01307 for(i=0;i<l;i++) 01308 if(y[i] == +1) 01309 { 01310 alpha[i] = min(1.0,sum_pos); 01311 sum_pos -= alpha[i]; 01312 } 01313 else 01314 { 01315 alpha[i] = min(1.0,sum_neg); 01316 sum_neg -= alpha[i]; 01317 } 01318 01319 double *zeros = new double[l]; 01320 01321 for(i=0;i<l;i++) 01322 zeros[i] = 0; 01323 01324 Solver_NU s; 01325 s.Solve(l, SVC_Q(*prob,*param,y), zeros, y, 01326 alpha, 1.0, 1.0, param->eps, si, param->shrinking); 01327 double r = si->r; 01328 01329 info("C = %f\n",1/r); 01330 01331 for(i=0;i<l;i++) 01332 alpha[i] *= y[i]/r; 01333 01334 si->rho /= r; 01335 si->obj /= (r*r); 01336 si->upper_bound_p = 1/r; 01337 si->upper_bound_n = 1/r; 01338 01339 delete[] y; 01340 delete[] zeros; 01341 }
|