Skip to content

Commit

Permalink
Merge pull request #102 from sanity/treeBuildCompat
Browse files Browse the repository at this point in the history
made treeBuilder backwards compatible for ignoreAttributeAtNodeprobabili...
  • Loading branch information
athawk81 committed Mar 9, 2015
2 parents cf5bb08 + 8f8141a commit 5dbe2ab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
be accompanied by a bump in version number, regardless of how minor the change.
-->

<version>0.7.0</version>
<version>0.7.1</version>


<repositories>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public final class TreeBuilder<T extends ClassifierInstance> implements Predicti
public static final String PENALIZE_CATEGORICAL_SPLITS = "penalizeCategoricalSplitsBySplitAttributeIntrinsicValue";
public static final String ATTRIBUTE_IGNORING_STRATEGY = "attributeIgnoringStrategy";
public static final String DEGREE_OF_GAIN_RATIO_PENALTY = "degreeOfGainRatioPenalty";


public static final String IGNORE_ATTR_PROB = "ignoreAttributeAtNodeProbability";
public static final String ORDINAL_TEST_SPLITS = "ordinalTestSpilts";
public static final int SMALL_TRAINING_SET_LIMIT = 9;
public static final int RESERVOIR_SIZE = 1000;
Expand All @@ -55,6 +54,7 @@ public final class TreeBuilder<T extends ClassifierInstance> implements Predicti
private double degreeOfGainRatioPenalty = 1.0;
private int ordinalTestSpilts = 5;
private double fractionOfDataToUseInHoldOutSet;

private AttributeIgnoringStrategy attributeIgnoringStrategy = new IgnoreAttributesWithConstantProbability(0.0);

//TODO: make it so only one thread computes the below 4 values since all trees compute the same values..
Expand All @@ -74,6 +74,12 @@ public TreeBuilder attributeIgnoringStrategy(AttributeIgnoringStrategy attribute
return this;
}

@Deprecated
public TreeBuilder ignoreAttributeAtNodeProbability(double ignoreAttributeAtNodeProbability) {
attributeIgnoringStrategy(new IgnoreAttributesWithConstantProbability(ignoreAttributeAtNodeProbability));
return this;
}

public TreeBuilder copy() {
TreeBuilder<T> copy = new TreeBuilder<>();
copy.scorer = scorer;
Expand Down Expand Up @@ -110,6 +116,8 @@ public void updateBuilderConfig(final Map<String, Object> cfg) {
degreeOfGainRatioPenalty((Double) cfg.get(DEGREE_OF_GAIN_RATIO_PENALTY));
if (cfg.containsKey(ATTRIBUTE_IGNORING_STRATEGY))
attributeIgnoringStrategy((AttributeIgnoringStrategy) cfg.get(ATTRIBUTE_IGNORING_STRATEGY));
if (cfg.containsKey(IGNORE_ATTR_PROB))
ignoreAttributeAtNodeProbability((Double)cfg.get(IGNORE_ATTR_PROB));

penalizeCategoricalSplitsBySplitAttributeIntrinsicValue(cfg.containsKey(PENALIZE_CATEGORICAL_SPLITS) ? (Boolean) cfg.get(PENALIZE_CATEGORICAL_SPLITS) : true);
}
Expand Down

0 comments on commit 5dbe2ab

Please sign in to comment.