()
| 140 | } |
| 141 | |
| 142 | @Test |
| 143 | public void testClone() |
| 144 | { |
| 145 | System.out.println("clone"); |
| 146 | |
| 147 | Bagging instance = new Bagging((Classifier)new DecisionTree()); |
| 148 | |
| 149 | ClassificationDataSet t1 = FixedProblems.getCircles(1000, 0.1, 10.0); |
| 150 | ClassificationDataSet t2 = FixedProblems.getCircles(1000, 0.1, 10.0); |
| 151 | |
| 152 | t2.applyTransform(new LinearTransform(t2)); |
| 153 | |
| 154 | int errors; |
| 155 | |
| 156 | instance = instance.clone(); |
| 157 | |
| 158 | instance.trainC(t1); |
| 159 | |
| 160 | Bagging result = instance.clone(); |
| 161 | |
| 162 | errors = 0; |
| 163 | for (int i = 0; i < t1.getSampleSize(); i++) |
| 164 | errors += Math.abs(t1.getDataPointCategory(i) - result.classify(t1.getDataPoint(i)).mostLikely()); |
| 165 | assertTrue(errors < 100); |
| 166 | result.trainC(t2); |
| 167 | |
| 168 | for (int i = 0; i < t1.getSampleSize(); i++) |
| 169 | errors += Math.abs(t1.getDataPointCategory(i) - instance.classify(t1.getDataPoint(i)).mostLikely()); |
| 170 | assertTrue(errors < 100); |
| 171 | |
| 172 | for (int i = 0; i < t2.getSampleSize(); i++) |
| 173 | errors += Math.abs(t2.getDataPointCategory(i) - result.classify(t2.getDataPoint(i)).mostLikely()); |
| 174 | assertTrue(errors < 100); |
| 175 | } |
| 176 | |
| 177 | } |
nothing calls this directly
no test coverage detected