/** * Create a {@link Stage} from a trained ensemble. * * @param ensemble * the ensemble * @return the stage */ private Stage createStage(final List<ObjectFloatPair<StumpClassifier>> ensemble) { final HaarFeatureClassifier[] trees = new HaarFeatureClassifier[ensemble.size()]; for (int i = 0; i < trees.length; i++) { final ObjectFloatPair<StumpClassifier> wc = ensemble.get(i); final StumpClassifier c = wc.first; final float alpha = wc.second; final float threshold = c.threshold; final float leftValue = c.sign > 0 ? -alpha : alpha; final HaarFeature feature = features.get(c.dimension); final ValueClassifier left = new ValueClassifier(leftValue); final ValueClassifier right = new ValueClassifier(-leftValue); trees[i] = new HaarFeatureClassifier(feature, threshold, left, right); } final Stage root = new Stage(0, trees, null, null); return root; }
final StageNode node = stageNodes.get(i); stages[i] = new Stage(node.threshold, buildClassifiers(node.trees), null, null);
final StageNode node = stageNodes.get(i); stages[i] = new Stage(node.threshold, buildClassifiers(node.trees), null, null);
/** * Create a {@link Stage} from a trained ensemble. * * @param ensemble * the ensemble * @return the stage */ private Stage createStage(final List<ObjectFloatPair<StumpClassifier>> ensemble) { final HaarFeatureClassifier[] trees = new HaarFeatureClassifier[ensemble.size()]; for (int i = 0; i < trees.length; i++) { final ObjectFloatPair<StumpClassifier> wc = ensemble.get(i); final StumpClassifier c = wc.first; final float alpha = wc.second; final float threshold = c.threshold; final float leftValue = c.sign > 0 ? -alpha : alpha; final HaarFeature feature = features.get(c.dimension); final ValueClassifier left = new ValueClassifier(leftValue); final ValueClassifier right = new ValueClassifier(-leftValue); trees[i] = new HaarFeatureClassifier(feature, threshold, left, right); } final Stage root = new Stage(0, trees, null, null); return root; }