Skip to content

Commit

Permalink
Added proximal test case on standardized data.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasnykodym committed Apr 17, 2015
1 parent 146d651 commit fcb8e43
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/test/java/hex/GLMTest2.java
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,17 @@ final static public void testHTML(GLMModel m) {
for(int i = 0; i < beta.length; ++i)
Assert.assertEquals(0,grad[i] + betaConstraints.vec("rho").at(i) * (beta[i] - betaConstraints.vec("beta_given").at(i)),1e-8);
// now standardized
src = new GLM2.Source((Frame)fr.clone(), fr.vec("CAPSULE"), true, true);
new GLM2("GLM offset test on prostate.", Key.make(), modelKey, src, Family.binomial).setNonNegative(false).setRegularization(new double[]{0},new double[]{0.000}).setBetaConstraints(betaConstraints).setHighAccuracy().doInit().fork().get(); //.setHighAccuracy().doInit().fork().get();
model = DKV.get(modelKey).get();
fr.add("CAPSULE", fr.remove("CAPSULE"));
dinfo = new DataInfo(fr, 1, true, false, TransformType.STANDARDIZE, DataInfo.TransformType.NONE);
glmt = new GLMTask.GLMIterationTask(0,null, dinfo, new GLMParams(Family.binomial),false, true, true, model.norm_beta(0), 0, 1.0/380, ModelUtils.DEFAULT_THRESHOLDS, null).doAll(dinfo._adaptedFrame);
double [] beta2 = model.norm_beta(0);
double [] grad2 = glmt.gradient(0,0);
for(int i = 0; i < beta.length-1; ++i)
Assert.assertEquals("grad[" + i + "] != 0",0,grad2[i] + betaConstraints.vec("rho").at(i) * (beta2[i] - betaConstraints.vec("beta_given").at(i) * dinfo._adaptedFrame.vec(i).sigma()),1e-8);
Assert.assertEquals("grad[intercept] != 0",0,grad2[grad2.length-1],1e-8);
} finally {
fr.delete();
if(model != null)model.delete();
Expand Down

0 comments on commit fcb8e43

Please sign in to comment.