/** * Return an AdaBoost classifier that uses only the first * <tt>numWeakClassifiersToUse</tt> weak learners. * * <p>The returned classifier's Pipe and weak classifiers * are backed by the respective objects of this classifier, * so changes to the returned classifier's Pipe and weak * classifiers are reflected in this classifier, and vice versa. */ public AdaBoost getTrimmedClassifier(int numWeakClassifiersToUse) { if (numWeakClassifiersToUse <= 0 || numWeakClassifiersToUse > weakClassifiers.length) throw new IllegalArgumentException("number of weak learners to use out of range:" + numWeakClassifiersToUse); Classifier[] newWeakClassifiers = new Classifier[numWeakClassifiersToUse]; System.arraycopy(weakClassifiers, 0, newWeakClassifiers, 0, numWeakClassifiersToUse); double[] newAlphas = new double[numWeakClassifiersToUse]; System.arraycopy(alphas, 0, newAlphas, 0, numWeakClassifiersToUse); return new AdaBoost(instancePipe, newWeakClassifiers, newAlphas); }
/** * Return an AdaBoost classifier that uses only the first * <tt>numWeakClassifiersToUse</tt> weak learners. * * <p>The returned classifier's Pipe and weak classifiers * are backed by the respective objects of this classifier, * so changes to the returned classifier's Pipe and weak * classifiers are reflected in this classifier, and vice versa. */ public AdaBoost getTrimmedClassifier(int numWeakClassifiersToUse) { if (numWeakClassifiersToUse <= 0 || numWeakClassifiersToUse > weakClassifiers.length) throw new IllegalArgumentException("number of weak learners to use out of range:" + numWeakClassifiersToUse); Classifier[] newWeakClassifiers = new Classifier[numWeakClassifiersToUse]; System.arraycopy(weakClassifiers, 0, newWeakClassifiers, 0, numWeakClassifiersToUse); double[] newAlphas = new double[numWeakClassifiersToUse]; System.arraycopy(alphas, 0, newAlphas, 0, numWeakClassifiersToUse); return new AdaBoost(instancePipe, newWeakClassifiers, newAlphas); }
/** * Return an AdaBoost classifier that uses only the first * <tt>numWeakClassifiersToUse</tt> weak learners. * * <p>The returned classifier's Pipe and weak classifiers * are backed by the respective objects of this classifier, * so changes to the returned classifier's Pipe and weak * classifiers are reflected in this classifier, and vice versa. */ public AdaBoost getTrimmedClassifier(int numWeakClassifiersToUse) { if (numWeakClassifiersToUse <= 0 || numWeakClassifiersToUse > weakClassifiers.length) throw new IllegalArgumentException("number of weak learners to use out of range:" + numWeakClassifiersToUse); Classifier[] newWeakClassifiers = new Classifier[numWeakClassifiersToUse]; System.arraycopy(weakClassifiers, 0, newWeakClassifiers, 0, numWeakClassifiersToUse); double[] newAlphas = new double[numWeakClassifiersToUse]; System.arraycopy(alphas, 0, newAlphas, 0, numWeakClassifiersToUse); return new AdaBoost(instancePipe, newWeakClassifiers, newAlphas); }