(double[] targets, LSSVM warmSolution, DataSet data)
| 333 | } |
| 334 | |
| 335 | private void initializeVariables(double[] targets, LSSVM warmSolution, DataSet data) |
| 336 | { |
| 337 | alphas = new double[targets.length]; |
| 338 | fcache = new double[targets.length]; |
| 339 | dualObjective = 0; |
| 340 | if(warmSolution != null) |
| 341 | { |
| 342 | if(warmSolution.alphas.length != this.alphas.length) |
| 343 | throw new FailedToFitException("Warm LS-SVM solution could not have been trained on the sama data, different number of alpha values present"); |
| 344 | double C_ratio = this.C/warmSolution.C; |
| 345 | for(int i = 0; i < targets.length; i++) |
| 346 | { |
| 347 | alphas[i] = warmSolution.alphas[i]; |
| 348 | fcache[i] = warmSolution.fcache[i]-(C_ratio-1)*warmSolution.alphas[i]/(this.C); |
| 349 | dualObjective += alphas[i]*(targets[i]-fcache[i]); |
| 350 | } |
| 351 | dualObjective /= 2; |
| 352 | } |
| 353 | else |
| 354 | { |
| 355 | for(int i = 0; i < targets.length; i++) |
| 356 | fcache[i] = -targets[i]; |
| 357 | } |
| 358 | |
| 359 | //Compute (i_low, b_low) and (i_up, b_up) using (3.4) |
| 360 | b_up = Double.NEGATIVE_INFINITY; |
| 361 | b_low = Double.POSITIVE_INFINITY; |
| 362 | |
| 363 | //Update Fcache[i] for all i in I using (4.10) |
| 364 | //Compute (i_low, b_low) and (i_up, b_up) using (3.4) |
| 365 | for (int i = 0; i < fcache.length; i++) |
| 366 | { |
| 367 | final double Fi = fcache[i]; |
| 368 | if(Fi > b_up) |
| 369 | { |
| 370 | b_up = Fi; |
| 371 | i_up = i; |
| 372 | } |
| 373 | |
| 374 | if(Fi < b_low) |
| 375 | { |
| 376 | b_low = Fi; |
| 377 | i_low = i; |
| 378 | } |
| 379 | } |
| 380 | setCacheMode(getCacheMode());//Initializes the cahce |
| 381 | } |
| 382 | |
| 383 | |
| 384 | @Override |
no test coverage detected