-1
我正在使用以下代碼爲了找到有趣的關聯規則
在文件data.arff
。問題了解weka apriori算法輸出
我的問題是,我不知道如何解釋輸出。 輸出告訴我什麼? 例如,我期望像[a = 1,b = 1] - > [c = 1]
這樣的規則,我沒有得到。
//Define ArrayList to Add Clustered Information
Apriori apriori = new Apriori();
apriori.setNumRules(10);
BufferedReader datafile = readDataFile("C:\\data.arff");
Instances data = new Instances(datafile);
apriori.buildAssociations(data);
System.out.println("-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-");
System.out.println("Number of Associations : " + apriori.getNumRules());
System.out.println("Adding Association Information to ArrayList ..");
AssociationRules arules = apriori.getAssociationRules();
int num = apriori.getAllTheRules().length;
System.out.println("Num :" + num);
for(AssociationRule ar : arules.getRules())
{
System.out.println("premise: " + ar.getPremise());
System.out.println("consequence: "+ar.getConsequence());
System.out.println("---");
}
data.arff
@relation Presence-Absence-Representation
@attribute a {0,1}
@attribute b {0,1}
@attribute c {0,1}
@attribute d {0,1}
@attribute e {0,1}
@attribute f {0,1}
@attribute g {0,1}
@attribute h {0,1}
@data
1,0,1,0,0,1,0,0
0,1,1,0,1,0,0,1
1,1,1,1,0,0,0,1
1,1,0,0,0,1,1,1
1,0,1,0,0,1,0,0
1,0,1,0,0,1,0,0
1,0,0,0,0,0,0,1
0,0,0,0,1,1,0,0
0,0,0,0,0,1,1,1
,我得到以下的輸出:
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
Number of Associations : 10
Adding Association Information to ArrayList ..
Num :6
premise: [a=1]
consequence: [e=0]
---
premise: [b=0]
consequence: [d=0]
---
premise: [f=1]
consequence: [d=0]
---
premise: [c=1]
consequence: [g=0]
---
premise: [a=1, d=0]
consequence: [e=0]
---
premise: [e=0, g=0]
consequence: [a=1]
---
premise: [a=1, g=0]
consequence: [e=0]
---
premise: [b=0, e=0]
consequence: [d=0]
---
premise: [b=0, f=1]
consequence: [d=0]
---
premise: [b=0, g=0]
consequence: [d=0]
---