@Test public void testDecision() { BitSet activeCategories = new BitSet(10); activeCategories.set(2); activeCategories.set(5); Decision decision = new CategoricalDecision(0, activeCategories, true); for (int i = 0; i < 10; i++) { assertEquals(activeCategories.get(i), decision.isPositive(new Example(null, CategoricalFeature.forValue(i)))); } assertTrue(decision.isPositive(new Example(null, new Feature[] {null}))); }
@Override public boolean isPositive(Example example) { CategoricalFeature feature = (CategoricalFeature) example.getFeature(getFeatureNumber()); return feature == null ? defaultDecision : activeCategories.get(feature.getValueID()); }
CategoricalDecision extends Decision { @Override public boolean isPositive(Example example) { CategoricalFeature feature = (CategoricalFeature) example.getFeature(getFeatureNumber()); return feature == null ? defaultDecision : activeCategories.get(feature.getValueID()); } }
CategoricalDecision extends Decision { @Override public boolean isPositive(Example example) { CategoricalFeature feature = (CategoricalFeature) example.getFeature(getFeatureNumber()); return feature == null ? defaultDecision : activeCategories.get(feature.getValueID()); } CategoricalDecision(int featureNumber, BitSet activeCategories, boolean defaultDecision); private  CategoricalDecision(int featureNumber,
                              int categoryCount,
                              List<Pair<Double,Integer>> scoreCategoryPairs,
                              int from,
                              int to,
                              int maxCategory); }
CategoricalDecision extends Decision { @Override public boolean isPositive(Example example) { CategoricalFeature feature = (CategoricalFeature) example.getFeature(getFeatureNumber()); return feature == null ? defaultDecision : activeCategories.get(feature.getValueID()); } CategoricalDecision(int featureNumber, BitSet activeCategories, boolean defaultDecision); private  CategoricalDecision(int featureNumber,
                              int categoryCount,
                              List<Pair<Double,Integer>> scoreCategoryPairs,
                              int from,
                              int to,
                              int maxCategory); BitSet getCategoryIDs(); @Override boolean getDefaultDecision(); @Override boolean isPositive(Example example); @Override FeatureType getType(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
CategoricalDecision extends Decision { @Override public boolean isPositive(Example example) { CategoricalFeature feature = (CategoricalFeature) example.getFeature(getFeatureNumber()); return feature == null ? defaultDecision : activeCategories.get(feature.getValueID()); } CategoricalDecision(int featureNumber, BitSet activeCategories, boolean defaultDecision); private  CategoricalDecision(int featureNumber,
                              int categoryCount,
                              List<Pair<Double,Integer>> scoreCategoryPairs,
                              int from,
                              int to,
                              int maxCategory); BitSet getCategoryIDs(); @Override boolean getDefaultDecision(); @Override boolean isPositive(Example example); @Override FeatureType getType(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }