MCPcopy Create free account
hub / github.com/EdwardRaff/JSAT / update

Method update

JSAT/src/jsat/classifiers/linear/kernelized/CSKLR.java:421–457  ·  view source on GitHub ↗
(DataPoint dataPoint, int targetClass)

Source from the content-addressed store, hash-verified

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)

Callers

nothing calls this directly

Calls 13

getPreScoreMethod · 0.95
getScoreMethod · 0.95
getNumericalValuesMethod · 0.80
ptMethod · 0.80
gradMethod · 0.80
addToCacheMethod · 0.65
evalMethod · 0.65
sizeMethod · 0.65
nextDoubleMethod · 0.45
getWeightMethod · 0.45
addMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected