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

Method testScale

JSAT/test/jsat/classifiers/linear/SDCATest.java:151–178  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

149 }
150
151 @Test
152 public void testScale()
153 {
154 System.out.println("testScale");
155 ClassificationDataSet train = FixedProblems.get2ClassLinear(1000, RandomUtil.getRandom());
156
157 Vec base = null;
158 for(double max : new double[]{1.0, 2.0, 4.0, 5.0, 6.0, 10.0, 20.0, 50.0})
159 {
160 SDCA sdca = new SDCA();
161
162 sdca.setUseBias(false);//bias term makes scaling non-trivial, so remove from this test
163 sdca.setLoss(new LogisticLoss());
164 sdca.setLambda(1.0 / train.getSampleSize());
165 sdca.setAlpha(0.0);
166
167 ClassificationDataSet t = train.shallowClone();
168 t.applyTransform(new LinearTransform(t, 0, max));
169
170 sdca.trainC(t);
171 if(base == null)
172 base = sdca.getRawWeight(0).clone();
173 else
174 assertTrue("Failed on scale " + max, base.equals(sdca.getRawWeight(0).multiply(max), 0.1));
175// System.out.println(sdca.getRawWeight(0).multiply(max));
176// System.out.println(sdca.getBias(0));
177 }
178 }
179
180 /**
181 * Test of setLambda method, of class NewGLMNET.

Callers

nothing calls this directly

Calls 14

get2ClassLinearMethod · 0.95
getRandomMethod · 0.95
setUseBiasMethod · 0.95
setLossMethod · 0.95
setLambdaMethod · 0.95
getSampleSizeMethod · 0.95
setAlphaMethod · 0.95
shallowCloneMethod · 0.95
trainCMethod · 0.95
getRawWeightMethod · 0.95
equalsMethod · 0.95
applyTransformMethod · 0.80

Tested by

no test coverage detected