weka.classifiers.rules.Prism 為簡單規則集學習器,
訓練時逐一就每一類別之案例用覆蓋法建立精確率較高之規則,
測試時由規則集上往下,依案例屬性值找尋第1個符合規則作預測。
可提供案例集不錯表現值供標竿比較之用。
Prism 學習規則集時,依各類別分別學習適合該類別所有案例之規則集,作法如下:
為每一類別建立覆蓋該類別的規則集前,先將所有案例置於待學習案例集E中,
只要集合E尚存有該類別案例,就表示規則還待添加。
建立規則時,先從1個屬性條件,窮舉所有屬性配所有值的可能組合,取精確率最大組合;
再添下1個屬性條件,同樣窮舉所有屬性配所有值的可能組合,取精確率最大組合;
以此類推,直到添加屬性用光或已完全正確為止。
取精確率最大組合時,若有持平的屬性條件,則取覆蓋率(分母)較大者。
規則建好後,將該類別規則已預測正確的案例從集E中刪除,
針對尚未覆蓋案例學習下一條規則。
Prism 在學習類別規則時有敵情觀念(其他類別案例全部都在),
所以預測時,同類別的規則哪一條誰先檢查效果都一樣,不會誤含到其他類別的案例空間。
> java -cp weka.jar;. weka.classifiers.rules.Prism -t data\weather.nominal.arff
Prism rules
----------
If outlook = overcast then yes
If humidity = normal
and windy = FALSE then yes
If temperature = mild
and humidity = normal then yes
If outlook = rainy
and windy = FALSE then yes
If outlook = sunny
and humidity = high then no
If outlook = rainy
and windy = TRUE then no
Time taken to build model: 0 seconds
Time taken to test model on training data: 0 seconds
=== Error on training data ===
Correctly Classified Instances 14 100 %
Incorrectly Classified Instances 0 0 %
Kappa statistic 1
Mean absolute error 0
Root mean squared error 0
Relative absolute error 0 %
Root relative squared error 0 %
Total Number of Instances 14
=== Confusion Matrix ===
a b <-- classified as
9 0 | a = yes
0 5 | b = no
=== Stratified cross-validation ===
Correctly Classified Instances 9 64.2857 %
Incorrectly Classified Instances 3 21.4286 %
Kappa statistic 0.4375
Mean absolute error 0.25
Root mean squared error 0.5
Relative absolute error 59.2264 %
Root relative squared error 105.9121 %
UnClassified Instances 2 14.2857 %
Total Number of Instances 14
=== Confusion Matrix ===
a b <-- classified as
7 0 | a = yes
3 2 | b = no
如下 weather.nominal.arff 案例集的14個案例有9個yes、5個no。
outlook |
temperature |
humidity |
windy |
play |
sunny |
hot |
high |
FALSE |
no |
sunny |
hot |
high |
TRUE |
no |
rainy |
cool |
normal |
TRUE |
no |
sunny |
mild |
high |
FALSE |
no |
rainy |
mild |
high |
TRUE |
no |
overcast |
hot |
high |
FALSE |
yes |
rainy |
mild |
high |
FALSE |
yes |
rainy |
cool |
normal |
FALSE |
yes |
overcast |
cool |
normal |
TRUE |
yes |
sunny |
cool |
normal |
FALSE |
yes |
rainy |
mild |
normal |
FALSE |
yes |
sunny |
mild |
normal |
TRUE |
yes |
overcast |
mild |
high |
TRUE |
yes |
overcast |
hot |
normal |
FALSE |
yes |
| | | | |
| | | | |
參考:
1.weka.classifiers.rules.Prism
code |
doc
沒有留言:
張貼留言