public static List<DecisionTree> getStumpsFor(DataSet ds, String returnValueIfMatched, String returnValueIfUnmatched) { List<String> attributes = ds.getNonTargetAttributes(); List<DecisionTree> trees = new List<DecisionTree>(); foreach (String attribute in attributes) { List<String> values = ds.getPossibleAttributeValues(attribute); foreach (String value in values) { List<String> unmatchedValues = Util.removeFrom(ds .getPossibleAttributeValues(attribute), value); DecisionTree tree = getStumpFor(ds, attribute, value, returnValueIfMatched, unmatchedValues, returnValueIfUnmatched); trees.Add(tree); } } return trees; }
public virtual void train(DataSet ds) { List<String> attributes = ds.getNonTargetAttributes(); this.tree = decisionTreeLearning(ds, attributes, new ConstantDecisonTree(defaultValue)); }