| 188 | } |
| 189 | |
| 190 | @Override |
| 191 | public CategoricalResults classify(DataPoint data) |
| 192 | { |
| 193 | if(baseClassifier == null) |
| 194 | throw new RuntimeException("Bagging instance created for regression, not classification"); |
| 195 | else if(learners == null || learners.isEmpty()) |
| 196 | throw new RuntimeException("Classifier has not yet been trained"); |
| 197 | CategoricalResults totalResult = new CategoricalResults(predicting.getNumOfCategories()); |
| 198 | for(int i = 0; i < learners.size(); i++) |
| 199 | { |
| 200 | CategoricalResults result = ((Classifier) learners.get(i)).classify(data); |
| 201 | totalResult.incProb(result.mostLikely(), 1.0); |
| 202 | } |
| 203 | |
| 204 | totalResult.normalize(); |
| 205 | return totalResult; |
| 206 | } |
| 207 | |
| 208 | @Override |
| 209 | public void trainC(final ClassificationDataSet dataSet, final ExecutorService threadPool) |