Skip to content

Commit

Permalink
Disable Newton's methon in dispersion estimation in GLM Tweedie
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasfryda committed Jan 21, 2024
1 parent 35f65b8 commit 0e3d0c8
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions h2o-algos/src/main/java/hex/glm/DispersionUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,28 @@ private static double goldenRatioDispersionSearch(GLMModel.GLMParameters parms,
*/
public static double estimateTweedieDispersionOnly(GLMModel.GLMParameters parms, GLMModel model, Job job,
double[] beta, DataInfo dinfo) {
long currTime = System.currentTimeMillis();
long modelBuiltTime = currTime - model._output._start_time;
long timeLeft = parms._max_runtime_secs > 0 ? (long) (parms._max_runtime_secs * 1000 - modelBuiltTime)
: Long.MAX_VALUE;
TweedieMLDispersionOnly tDispersion = new TweedieMLDispersionOnly(parms.train(), parms, model, beta, dinfo);

DispersionTask.GenPrediction gPred = new DispersionTask.GenPrediction(beta, model, dinfo).doAll(
1, Vec.T_NUM, dinfo._adaptedFrame);
Vec mu = Scope.track(gPred.outputFrame(Key.make(), new String[]{"prediction"}, null)).vec(0);
List<Double> logLikelihoodSanityChecks = new ArrayList<>();
List<Double> dispersionsSanityChecks = new ArrayList<>();
logLikelihoodSanityChecks.add(getTweedieLogLikelihood(parms, dinfo, parms._init_dispersion_parameter, mu));
dispersionsSanityChecks.add(parms._init_dispersion_parameter);
final double dispersion = goldenRatioDispersionSearch(parms, dinfo, mu,logLikelihoodSanityChecks, dispersionsSanityChecks, job);
Log.info("Tweedie dispersion estimate = "+dispersion);
return dispersion;

/*
// FIXME: The Newton's method seems not to be reproducible on jenkins (runit_GLM_tweedie_ml_dispersion_estimation_only.R)
long timeLeft = parms._max_runtime_secs > 0 ? (long) (parms._max_runtime_secs * 1000 - modelBuiltTime)
: Long.MAX_VALUE;
long currTime = System.currentTimeMillis();
long modelBuiltTime = currTime - model._output._start_time;
TweedieMLDispersionOnly tDispersion = new TweedieMLDispersionOnly(parms.train(), parms, model, beta, dinfo);
double dispersionCurr = tDispersion._dispersionParameter; // initial value of dispersion parameter
double dispersionNew;
Expand Down Expand Up @@ -303,6 +317,8 @@ public static double estimateTweedieDispersionOnly(GLMModel.GLMParameters parms,
}
else
return dispersionCurr;
*/
}

static class NegativeBinomialGradientAndHessian extends MRTask<NegativeBinomialGradientAndHessian> {
Expand Down

0 comments on commit 0e3d0c8

Please sign in to comment.