Skip to content

Commit a7cd5e2

Browse files
committed
Classes analyzed in alphabetic order.
1 parent 1636f2b commit a7cd5e2

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

adaa.analytics.rules/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ codeQuality {
2727
}
2828

2929
sourceCompatibility = 1.8
30-
version = '1.7.7'
30+
version = '1.7.8'
3131

3232

3333
jar {

adaa.analytics.rules/src/main/java/adaa/analytics/rules/logic/induction/ClassificationExpertSnC.java

+11-6
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
******************************************************************************/
1515
package adaa.analytics.rules.logic.induction;
1616

17-
import java.util.HashSet;
18-
import java.util.Set;
17+
import java.util.*;
1918
import java.util.concurrent.Semaphore;
2019
import java.util.concurrent.atomic.AtomicInteger;
2120
import java.util.logging.Level;
@@ -64,8 +63,12 @@ public ClassificationRuleSet run(ExampleSet dataset)
6463
beginTime = System.nanoTime();
6564

6665
ClassificationRuleSet ruleset = (ClassificationRuleSet)factory.create(dataset);
67-
Attribute label = dataset.getAttributes().getLabel();
68-
NominalMapping mapping = label.getMapping();
66+
Attribute outputAttr = dataset.getAttributes().getLabel();
67+
NominalMapping mapping = outputAttr.getMapping();
68+
List<String> labels = new ArrayList<>();
69+
labels.addAll(mapping.getValues());
70+
Collections.sort(labels);
71+
6972

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

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

8186
IntegerBitSet positives = new IntegerBitSet(dataset.size());
8287
IntegerBitSet negatives = new IntegerBitSet(dataset.size());
@@ -185,7 +190,7 @@ public ClassificationRuleSet run(ExampleSet dataset)
185190
while (carryOn) {
186191
Rule rule = new ClassificationRule(
187192
new CompoundCondition(),
188-
new ElementaryCondition(label.getName(), new SingletonSet((double)classId, mapping.getValues())));
193+
new ElementaryCondition(outputAttr.getName(), new SingletonSet((double)classId, mapping.getValues())));
189194

190195
rule.setWeighted_P(weighted_P);
191196
rule.setWeighted_N(weighted_N);

adaa.analytics.rules/src/main/java/adaa/analytics/rules/logic/induction/ClassificationSnC.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ public RuleSetBase run(ExampleSet dataset) {
6767
: dataset.getAttributes().getSpecial(ContrastRule.CONTRAST_ATTRIBUTE_ROLE);
6868

6969
NominalMapping mapping = outputAttr.getMapping();
70+
List<String> labels = new ArrayList<>();
71+
labels.addAll(mapping.getValues());
72+
Collections.sort(labels);
7073

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

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

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

8588
preprocessClass(dataset, classId);
8689

0 commit comments

Comments
 (0)