Bonjour a tous ,
J'ai une classe appelé PrismRule () ,et j'ai creer une list de type Prism Rule et je vais ajouter a chaque fois une instance de Prism Rule et voila mon code
BTW la class PrismmRule a un champ appelé m_next qui est detype Prismrule il va pointer vers la classe suivante ce qui est bizarre c'est que la liste CR affiche toute les regles possible mes CR_rules n'as que la premiere et la derniere regles ???!!!!
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61 public List<PrismRule> CR = new ArrayList<PrismRule>(); public void buildClassifier(Instances data) throws Exception { PrismRule CR_rules = addRule(null , new PrismRule(data, 0)); System.out.println("Start build------------------"); int cl=0; // possible value of theClass Instances E, ruleE; Test test = null, oldTest = null; int bestCorrect, bestCovers, attUsed; Enumeration enumAtt; getCapabilities().testWithFail(data); // can classifier handle the data? data = new Instances(data); data.deleteWithMissingClass();// remove instances with missing class E = data; // initialize E to the instance set ruleE = E; // examples covered by this rule test = new Test(); CR_rules.m_test=test; // for every attribute not mentioned in the rule enumAtt = ruleE.enumerateAttributes(); while (enumAtt.hasMoreElements()) { Attribute attr = (Attribute) enumAtt.nextElement(); if (isMentionedIn(attr, CR_rules.m_test)) {continue;} int M = attr.numValues(); for (int val = 0; val < M; val ++) // ... for each value of this attribute { PrismRule cr = addRule(null , new PrismRule(data, 0)); Test Tst =new Test() ; Tst.m_attr = attr.index(); Tst.m_val = val; cr.m_test=Tst; CR.add(cr); } } System.out.println("********************End build***************************"); for(int i=0; i<CR.size(); i++) { System.out.println("CR ["+i+"] == [ "+(CR.get(i)).toString()+" ]"); CR_rules.m_next = CR.get(i) ; } System.out.println("My rules are = "+CR_rules.toString()); System.out.println("-------------------------------------------"); }
voila l'affichage
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 CR [0] == [ If length = long then True ] CR [1] == [ If length = small then True ] CR [2] == [ If length = medium then True ] CR [3] == [ If color = Red then True ] CR [4] == [ If color = Green then True ] CR [5] == [ If color = Blue then True ] CR [6] == [ If age = young then True ] CR [7] == [ If age = old then True ] CR [8] == [ If neighbors = 1 then True ] CR [9] == [ If neighbors = 2-to-4 then True ] CR [10] == [ If neighbors = 5-to-9 then True ] CR [11] == [ If neighbors = more-than-10 then True ] My rules are = If ? then True If neighbors = more-than-10 then True
Partager