/** Creates a default RandomForest */ public Classifier getClassifier() { return new RandomForest(); }
result.add("" + getBagSizePercent()); if (getCalcOutOfBag()) { result.add("-O"); if (getStoreOutOfBagPredictions()) { result.add("-store-out-of-bag-predictions"); if (getOutputOutOfBagComplexityStatistics()) { result.add("-output-out-of-bag-complexity-statistics"); if (getPrintClassifiers()) { result.add("-print"); if (getComputeAttributeImportance()) { result.add("-attribute-importance"); result.add("" + getNumIterations()); result.add("" + getNumExecutionSlots()); if (getDoNotCheckCapabilities()) { result.add("-do-not-check-capabilities"); ((OptionHandler) getClassifier()).getOptions()); Option.deleteFlagString(classifierOptions, "-do-not-check-capabilities"); result.addAll(classifierOptions);
/** * Main method for this class. * * @param argv the options */ public static void main(String[] argv) { runClassifier(new RandomForest(), argv); } }
setBagSizePercent(Integer.parseInt(bagSize)); } else { setBagSizePercent(100); setCalcOutOfBag(Utils.getFlag('O', options)); setStoreOutOfBagPredictions(Utils.getFlag("store-out-of-bag-predictions", options)); setOutputOutOfBagComplexityStatistics(Utils.getFlag( "output-out-of-bag-complexity-statistics", options)); setPrintClassifiers(Utils.getFlag("print", options)); setComputeAttributeImportance(Utils .getFlag("attribute-importance", options)); setNumIterations(Integer.parseInt(iterations)); } else { setNumIterations(defaultNumberOfIterations()); setNumExecutionSlots(Integer.parseInt(numSlots)); } else { setNumExecutionSlots(1); ((RandomTree) AbstractClassifier.forName(defaultClassifierString(), options)); classifier.setComputeImpurityDecreases(m_computeAttributeImportance); setDoNotCheckCapabilities(classifier.getDoNotCheckCapabilities());
trainData.setClassIndex(trainData.numAttributes() - 1); RandomForest rf = new RandomForest(); rf.setNumTrees(50); rf.setOptions(options); rf.buildClassifier(trainData);
/** * Set the maximum depth of the tree, 0 for unlimited. * * @param value the maximum depth. */ public void setMaxDepth(int value) { ((RandomTree) getClassifier()).setMaxDepth(value); }
buffer.append(super.toString()); if (getComputeAttributeImportance()) { try { double[] nodeCounts = new double[m_data.numAttributes()]; double[] impurityScores = computeAverageImpurityDecreasePerAttribute(nodeCounts); int[] sortedIndices = Utils.sort(impurityScores); buffer .append( Utils.doubleToString(impurityScores[index], 10, getNumDecimalPlaces())).append(" (") .append(Utils.doubleToString(nodeCounts[index], 6, 0)) .append(") ").append(m_data.attribute(index).name())
/** * Constructor that sets base classifier for bagging to RandomTre and default * number of iterations to 100. */ public RandomForest() { RandomTree rTree = new RandomTree(); rTree.setDoNotCheckCapabilities(true); super.setClassifier(rTree); super.setRepresentCopiesUsingWeights(true); setNumIterations(defaultNumberOfIterations()); }
+ "\t(current value " + getNumIterations() + ")", "I", 1, "-I <num>")); Collections.list(((OptionHandler) getClassifier()).listOptions()); newVector.addAll(list);
if (!getComputeAttributeImportance()) { throw new WekaException("Stats for attribute importance have not " + "been collected!");
setBagSizePercent(Integer.parseInt(bagSize)); } else { setBagSizePercent(100); setCalcOutOfBag(Utils.getFlag('O', options)); setStoreOutOfBagPredictions(Utils.getFlag("store-out-of-bag-predictions", options)); setOutputOutOfBagComplexityStatistics(Utils.getFlag( "output-out-of-bag-complexity-statistics", options)); setPrintClassifiers(Utils.getFlag("print", options)); setComputeAttributeImportance(Utils .getFlag("attribute-importance", options)); setNumIterations(Integer.parseInt(iterations)); } else { setNumIterations(defaultNumberOfIterations()); setNumExecutionSlots(Integer.parseInt(numSlots)); } else { setNumExecutionSlots(1); ((RandomTree) AbstractClassifier.forName(defaultClassifierString(), options)); classifier.setComputeImpurityDecreases(m_computeAttributeImportance); setDoNotCheckCapabilities(classifier.getDoNotCheckCapabilities());
/** * Main method for this class. * * @param argv the options */ public static void main(String[] argv) { runClassifier(new RandomForest(), argv); } }
/** * Returns the tip text for this property * * @return tip text for this property suitable for displaying in the * explorer/experimenter gui */ public String breakTiesRandomlyTipText() { return ((RandomTree) getClassifier()).breakTiesRandomlyTipText(); }
buffer.append(super.toString()); if (getComputeAttributeImportance()) { try { double[] nodeCounts = new double[m_data.numAttributes()]; double[] impurityScores = computeAverageImpurityDecreasePerAttribute(nodeCounts); int[] sortedIndices = Utils.sort(impurityScores); buffer .append( Utils.doubleToString(impurityScores[index], 10, getNumDecimalPlaces())).append(" (") .append(Utils.doubleToString(nodeCounts[index], 6, 0)) .append(") ").append(m_data.attribute(index).name())
/** * Constructor that sets base classifier for bagging to RandomTre and default * number of iterations to 100. */ public RandomForest() { RandomTree rTree = new RandomTree(); rTree.setDoNotCheckCapabilities(true); super.setClassifier(rTree); super.setRepresentCopiesUsingWeights(true); setNumIterations(defaultNumberOfIterations()); }
+ "\t(current value " + getNumIterations() + ")", "I", 1, "-I <num>")); Collections.list(((OptionHandler) getClassifier()).listOptions()); newVector.addAll(list);
if (!getComputeAttributeImportance()) { throw new WekaException("Stats for attribute importance have not " + "been collected!");
result.add("" + getBagSizePercent()); if (getCalcOutOfBag()) { result.add("-O"); if (getStoreOutOfBagPredictions()) { result.add("-store-out-of-bag-predictions"); if (getOutputOutOfBagComplexityStatistics()) { result.add("-output-out-of-bag-complexity-statistics"); if (getPrintClassifiers()) { result.add("-print"); if (getComputeAttributeImportance()) { result.add("-attribute-importance"); result.add("" + getNumIterations()); result.add("" + getNumExecutionSlots()); if (getDoNotCheckCapabilities()) { result.add("-do-not-check-capabilities"); ((OptionHandler) getClassifier()).getOptions()); Option.deleteFlagString(classifierOptions, "-do-not-check-capabilities"); result.addAll(classifierOptions);
/** Creates a default RandomForest */ public Classifier getClassifier() { return new RandomForest(); }
/** * Returns the tip text for this property * * @return tip text for this property suitable for displaying in the * explorer/experimenter gui */ public String breakTiesRandomlyTipText() { return ((RandomTree) getClassifier()).breakTiesRandomlyTipText(); }