14
14
******************************************************************************/
15
15
package adaa .analytics .rules .logic .induction ;
16
16
17
- import java .util .HashSet ;
18
- import java .util .Set ;
17
+ import java .util .*;
19
18
import java .util .concurrent .Semaphore ;
20
19
import java .util .concurrent .atomic .AtomicInteger ;
21
20
import java .util .logging .Level ;
@@ -64,8 +63,12 @@ public ClassificationRuleSet run(ExampleSet dataset)
64
63
beginTime = System .nanoTime ();
65
64
66
65
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
+
69
72
70
73
int totalExpertRules = 0 ;
71
74
int totalAutoRules = 0 ;
@@ -76,7 +79,9 @@ public ClassificationRuleSet run(ExampleSet dataset)
76
79
finder .preprocess (dataset );
77
80
78
81
// 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 );
80
85
81
86
IntegerBitSet positives = new IntegerBitSet (dataset .size ());
82
87
IntegerBitSet negatives = new IntegerBitSet (dataset .size ());
@@ -185,7 +190,7 @@ public ClassificationRuleSet run(ExampleSet dataset)
185
190
while (carryOn ) {
186
191
Rule rule = new ClassificationRule (
187
192
new CompoundCondition (),
188
- new ElementaryCondition (label .getName (), new SingletonSet ((double )classId , mapping .getValues ())));
193
+ new ElementaryCondition (outputAttr .getName (), new SingletonSet ((double )classId , mapping .getValues ())));
189
194
190
195
rule .setWeighted_P (weighted_P );
191
196
rule .setWeighted_N (weighted_N );
0 commit comments