Esempio n. 1
0
 public void add(double yreal, double ymodel) {
   null_deviance += _glm.deviance(yreal, _ymu);
   if (_glm.family == Family.binomial) // classification -> update confusion matrix too
   for (int i = 0; i < DEFAULT_THRESHOLDS.length; ++i)
       _cms[i].add((int) yreal, (ymodel >= DEFAULT_THRESHOLDS[i]) ? 1 : 0);
   if (Double.isNaN(_glm.deviance(yreal, ymodel)))
     System.out.println("NaN from yreal=" + yreal + ", ymodel=" + ymodel);
   residual_deviance += _glm.deviance(yreal, ymodel);
   ++nobs;
   avg_err += (ymodel - yreal) * (ymodel - yreal);
   if (_glm.family == Family.poisson) { // aic for poisson
     long y = Math.round(yreal);
     double logfactorial = 0;
     for (long i = 2; i <= y; ++i) logfactorial += Math.log(i);
     _aic2 += (yreal * Math.log(ymodel) - logfactorial - ymodel);
   }
 }