public ClassificationResult classify(IIndex testIndex, int docID) { ClassificationResult bagres = new ClassificationResult(); bagres.documentID = docID; for (int i = 0; i < _classifiers.length; ++i) { ClassificationResult res = _classifiers[i].classify(testIndex, docID); if (bagres.categoryID.size() == 0) { for (int j = 0; j < res.categoryID.size(); ++j) { bagres.categoryID.add(res.categoryID.getQuick(j)); bagres.score.add(0); } } for (int j = 0; j < res.score.size(); ++j) { bagres.score.setQuick(j, bagres.score.getQuick(j) + res.score.getQuick(j)); } } for (int j = 0; j < bagres.score.size(); ++j) { bagres.score.setQuick(j, bagres.score.getQuick(j) / _classifiers.length); } return bagres; }
bagres.score.setQuick(j, bagres.score.getQuick(j) + Math.pow(avg[j] - values[j].getQuick(i), 2.0));
private ClassificationResult classify(IIndex index, int docID, TreeNode node) { IClassifier classifier = node.getClassifier(); ClassificationResult result = classifier.classify(index, docID); if (result.score.get(0) > _range.border) { if (node.getPositiveChild() != null) return classify(index, docID, node.getPositiveChild()); else { result.categoryID.clear(); result.categoryID.add(node.getPositiveCategories()[0]); return result; } } else { if (node.getNegativeChild() != null) return classify(index, docID, node.getNegativeChild()); else { result.score.setQuick(0, -result.score.getQuick(0)); result.categoryID.clear(); result.categoryID.add(node.getNegativeCategories()[0]); return result; } } }