()
| 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. |
nothing calls this directly
no test coverage detected