Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/adaa-polsl/RuleKit-dev i…
Browse files Browse the repository at this point in the history
…nto develop
  • Loading branch information
agudys committed Apr 5, 2024
2 parents a2de3da + ca0c47c commit 0a22c07
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,8 @@ protected Set<Attribute> names2attributes(Set<String> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> getMapping() { return mapping; }
/** Sets {@link #mapping} */
Expand Down

0 comments on commit 0a22c07

Please sign in to comment.