diff --git a/adaa.analytics.rules/src/main/java/adaa/analytics/rules/logic/induction/AbstractFinder.java b/adaa.analytics.rules/src/main/java/adaa/analytics/rules/logic/induction/AbstractFinder.java index e7c4307..586a9fd 100644 --- a/adaa.analytics.rules/src/main/java/adaa/analytics/rules/logic/induction/AbstractFinder.java +++ b/adaa.analytics.rules/src/main/java/adaa/analytics/rules/logic/induction/AbstractFinder.java @@ -350,8 +350,8 @@ protected Set names2attributes(Set names, ExampleSet dataset) return out; } - double countAbsoluteMinimumCovered(double size, int ruleOrderNum, double uncoveredSize) { - if (params.getMaxRuleCount()>1 && ruleOrderNum>-1) { + double countAbsoluteMinimumCovered(double size, int ruleOrderNum, double uncoveredSize) { + if (params.getMaxRuleCount()>0 && ruleOrderNum>-1) { double sizeToCover = uncoveredSize * (1.0 - params.getMaximumUncoveredFraction()); int toGenerateRulesCount = params.getMaxRuleCount()- ruleOrderNum; double fractionCurrentGeneration = 1.0 / (double) toGenerateRulesCount; diff --git a/adaa.analytics.rules/src/main/java/adaa/analytics/rules/logic/induction/ClassificationSnC.java b/adaa.analytics.rules/src/main/java/adaa/analytics/rules/logic/induction/ClassificationSnC.java index 481552c..0869010 100644 --- a/adaa.analytics.rules/src/main/java/adaa/analytics/rules/logic/induction/ClassificationSnC.java +++ b/adaa.analytics.rules/src/main/java/adaa/analytics/rules/logic/induction/ClassificationSnC.java @@ -138,7 +138,7 @@ public RuleSetBase run(ExampleSet dataset) { rule.setCoveredNegatives(new IntegerBitSet(dataset.size())); rule.getCoveredPositives().addAll(positives); rule.getCoveredNegatives().addAll(negatives); - rule.setRuleOrderNum(ruleset.getRules().size()); + rule.setRuleOrderNum(countRuleOrderNumber(ruleset,label)); rule.getConsequence().setCovering(positives); @@ -201,4 +201,20 @@ public RuleSetBase run(ExampleSet dataset) { public void preprocessClass(ExampleSet dataset, int classId) { } + + int countRuleOrderNumber(ClassificationRuleSet ruleSet, String currentClassLabel) + { + int counter = 0; + + for(Rule r: ruleSet.getRules()) + { + ClassificationRule cr = (ClassificationRule)r; + if (cr.getClassLabel().equals(currentClassLabel)) + { + counter++; + } + } + + return counter; + } } diff --git a/adaa.analytics.rules/src/main/java/adaa/analytics/rules/logic/representation/ClassificationRule.java b/adaa.analytics.rules/src/main/java/adaa/analytics/rules/logic/representation/ClassificationRule.java index 58aa4d0..1f3bbda 100644 --- a/adaa.analytics.rules/src/main/java/adaa/analytics/rules/logic/representation/ClassificationRule.java +++ b/adaa.analytics.rules/src/main/java/adaa/analytics/rules/logic/representation/ClassificationRule.java @@ -38,6 +38,10 @@ public class ClassificationRule extends Rule { /** Serialization identifier. */ private static final long serialVersionUID = -809625670611500594L; + public String getClassLabel() { + SingletonSet ss = (SingletonSet)getConsequence().getValueSet(); + return ss.getValueAsString(); + } /** * Creates empty classification rule. */ diff --git a/adaa.analytics.rules/src/main/java/adaa/analytics/rules/logic/representation/SingletonSet.java b/adaa.analytics.rules/src/main/java/adaa/analytics/rules/logic/representation/SingletonSet.java index c18458a..03f41ed 100644 --- a/adaa.analytics.rules/src/main/java/adaa/analytics/rules/logic/representation/SingletonSet.java +++ b/adaa.analytics.rules/src/main/java/adaa/analytics/rules/logic/representation/SingletonSet.java @@ -41,7 +41,10 @@ public class SingletonSet implements IValueSet, Serializable { public double getValue() { return value; } /** Sets {@link #value} */ public void setValue(double v) { value = v; } - + + /** Gets {@link #value} as string */ + public String getValueAsString() { return mapping.get((int)value); } + /** Gets {@link #mapping} */ public List getMapping() { return mapping; } /** Sets {@link #mapping} */