Skip to content

Commit

Permalink
Classes analyzed in alphabetic order.
Browse files Browse the repository at this point in the history
  • Loading branch information
agudys committed Mar 28, 2024
1 parent 1636f2b commit a7cd5e2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion adaa.analytics.rules/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ codeQuality {
}

sourceCompatibility = 1.8
version = '1.7.7'
version = '1.7.8'


jar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
******************************************************************************/
package adaa.analytics.rules.logic.induction;

import java.util.HashSet;
import java.util.Set;
import java.util.*;
import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
Expand Down Expand Up @@ -64,8 +63,12 @@ public ClassificationRuleSet run(ExampleSet dataset)
beginTime = System.nanoTime();

ClassificationRuleSet ruleset = (ClassificationRuleSet)factory.create(dataset);
Attribute label = dataset.getAttributes().getLabel();
NominalMapping mapping = label.getMapping();
Attribute outputAttr = dataset.getAttributes().getLabel();
NominalMapping mapping = outputAttr.getMapping();
List<String> labels = new ArrayList<>();
labels.addAll(mapping.getValues());
Collections.sort(labels);


int totalExpertRules = 0;
int totalAutoRules = 0;
Expand All @@ -76,7 +79,9 @@ public ClassificationRuleSet run(ExampleSet dataset)
finder.preprocess(dataset);

// iterate over all classes
for (int classId = 0; classId < mapping.size(); ++classId) {
for (String label : labels) {
int classId = mapping.getIndex(label);
Logger.log("Class " + label + " (" +classId + ") started\n" , Level.FINE);

IntegerBitSet positives = new IntegerBitSet(dataset.size());
IntegerBitSet negatives = new IntegerBitSet(dataset.size());
Expand Down Expand Up @@ -185,7 +190,7 @@ public ClassificationRuleSet run(ExampleSet dataset)
while (carryOn) {
Rule rule = new ClassificationRule(
new CompoundCondition(),
new ElementaryCondition(label.getName(), new SingletonSet((double)classId, mapping.getValues())));
new ElementaryCondition(outputAttr.getName(), new SingletonSet((double)classId, mapping.getValues())));

rule.setWeighted_P(weighted_P);
rule.setWeighted_N(weighted_N);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ public RuleSetBase run(ExampleSet dataset) {
: dataset.getAttributes().getSpecial(ContrastRule.CONTRAST_ATTRIBUTE_ROLE);

NominalMapping mapping = outputAttr.getMapping();
List<String> labels = new ArrayList<>();
labels.addAll(mapping.getValues());
Collections.sort(labels);

boolean weighted = (dataset.getAttributes().getWeight() != null);

Expand All @@ -78,9 +81,9 @@ public RuleSetBase run(ExampleSet dataset) {
double defaultClassP = 0;

// iterate over all classes
for (int cid = 0; cid < mapping.size(); ++cid) {
final int classId = cid;
Logger.log("Class " + classId + " started\n" , Level.FINE);
for (String label : labels) {
int classId = mapping.getIndex(label);
Logger.log("Class " + label + " (" +classId + ") started\n" , Level.FINE);

preprocessClass(dataset, classId);

Expand Down

0 comments on commit a7cd5e2

Please sign in to comment.