(DataPoint dataPoint, int targetClass)
| 419 | } |
| 420 | |
| 421 | @Override |
| 422 | public void update(DataPoint dataPoint, int targetClass) |
| 423 | { |
| 424 | double y_t = targetClass*2-1; |
| 425 | Vec x_t = dataPoint.getNumericalValues(); |
| 426 | double pre = getPreScore(x_t); |
| 427 | double score = getScore(y_t, pre); |
| 428 | |
| 429 | switch(mode) |
| 430 | { |
| 431 | case NC: |
| 432 | break; |
| 433 | default: |
| 434 | double pt = mode.pt(y_t, score, pre, eta, gamma); |
| 435 | if(rand.nextDouble() > pt) |
| 436 | return; |
| 437 | break; |
| 438 | } |
| 439 | |
| 440 | |
| 441 | double alpha_i = -eta*y_t*mode.grad(y_t, score, pre, gamma)*dataPoint.getWeight(); |
| 442 | |
| 443 | alpha.add(alpha_i); |
| 444 | vecs.add(x_t); |
| 445 | k.addToCache(x_t, accelCache); |
| 446 | curNorm += Math.abs(alpha_i) * k.eval(vecs.size(), vecs.size(), vecs, accelCache); |
| 447 | |
| 448 | //projection step |
| 449 | if (curNorm > R) |
| 450 | { |
| 451 | double coef = R/curNorm; |
| 452 | for(int i = 0; i < alpha.size(); i++) |
| 453 | alpha.set(i, alpha.get(i)*coef); |
| 454 | curNorm = coef; |
| 455 | } |
| 456 | |
| 457 | } |
| 458 | |
| 459 | @Override |
| 460 | public CategoricalResults classify(DataPoint data) |
nothing calls this directly
no test coverage detected