2017年4月23日 星期日

weka.classifiers.bayes.BayesNet

weka.classifiers.bayes.BayesNet 為貝氏網路學習器,
可克服屬性之間相關性,學得貝氏網路結構及其機率表,以進行類別預測。
若遇數值屬性,將先進行離散化後再學習。

參數說明:
 -B <BIF file> 供結構比對之用的貝氏網路描述檔,副檔名.bif。預設無。

 -D  不要使用ADTree資料結構,較省記憶體,但跑較慢。預設使用,較耗記憶體,但跑較快。

 -Q <weka.classifiers.bayes.net.search.searchAlgorithm> 結構學習演算法。
    -- 條件獨立法
     weka.classifiers.bayes.net.search.ci.CISearchAlgorithm
     weka.classifiers.bayes.net.search.ci.ICSSearchAlgorithm
    -- 採用固定結構
     weka.classifiers.bayes.net.search.fixed.FromFile  外部檔案結構
     weka.classifiers.bayes.net.search.fixed.NaiveBayes  簡單貝氏結構
    -- 全域法,-S LOO-CV 預設值表示選用留一法交叉驗證決定好壞
     weka.classifiers.bayes.net.search.global.GeneticSearch
     weka.classifiers.bayes.net.search.global.HillClimber
     weka.classifiers.bayes.net.search.global.K2
     weka.classifiers.bayes.net.search.global.SimulatedAnnealing
     weka.classifiers.bayes.net.search.global.TabuSearch
     weka.classifiers.bayes.net.search.global.TAN
    -- 區域法,-S BAYES 預設值表示選用Bayes評分指標決定好壞
     weka.classifiers.bayes.net.search.local.GeneticSearch
     weka.classifiers.bayes.net.search.local.HillClimber
     weka.classifiers.bayes.net.search.local.K2 (-P 1 表示親節點個數限制1個)
     weka.classifiers.bayes.net.search.local.SimulatedAnnealing
     weka.classifiers.bayes.net.search.local.TabuSearch
     weka.classifiers.bayes.net.search.local.TAN
     預設值weka.classifiers.bayes.net.search.local.K2。

 -E <weka.classifiers.bayes.net.estimate.estimateAlgorithm> 機率表學習演算法。
     weka.classifiers.bayes.net.estimate.BayesNetEstimator
     weka.classifiers.bayes.net.estimate.BMAEstimator
     weka.classifiers.bayes.net.estimate.MultinomialBMAEstimator
     weka.classifiers.bayes.net.estimate.SimpleEstimator (-A 0.5 表示初始機率值0.5)
     預設值weka.classifiers.bayes.net.estimate.SimpleEstimator。


>java -cp weka.jar;. weka.classifiers.bayes.BayesNet -t data\weather.nominal.arff
    -D 
    -Q weka.classifiers.bayes.net.search.local.K2 -- -P 1 -S BAYES 
    -E weka.classifiers.bayes.net.estimate.SimpleEstimator -- -A 0.5

Options: -D -Q weka.classifiers.bayes.net.search.local.K2 -- -P 1 -S BAYES -E weka.classifiers.bayes.net.estimate.SimpleEstimator -- -A 0.5


Bayes Network Classifier
not using ADTree
#attributes=5 #classindex=4
Network structure (nodes followed by parents)
outlook(3): play
temperature(3): play
humidity(2): play
windy(2): play
play(2):
LogScore Bayes: -69.07317135664013
LogScore BDeu: -83.46880542273107
LogScore MDL: -82.71568504897063
LogScore ENTROPY: -65.56181240647145
LogScore AIC: -78.56181240647145


Time taken to build model: 0.02 seconds Time taken to test model on training data: 0 seconds === Error on training data === Correctly Classified Instances 13 92.8571 % Incorrectly Classified Instances 1 7.1429 % Kappa statistic 0.8372 Mean absolute error 0.2615 Root mean squared error 0.3242 Relative absolute error 56.3272 % Root relative squared error 67.6228 % Total Number of Instances 14 === Confusion Matrix === a b <-- classified as 9 0 | a = yes 1 4 | b = no === Stratified cross-validation === Correctly Classified Instances 8 57.1429 % Incorrectly Classified Instances 6 42.8571 % Kappa statistic -0.0244 Mean absolute error 0.415 Root mean squared error 0.4909 Relative absolute error 87.1501 % Root relative squared error 99.5104 % Total Number of Instances 14 === Confusion Matrix === a b <-- classified as 7 2 | a = yes 4 1 | 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.bayes.BayesNet code | doc 2.weka.classifiers.bayes.net.search code | doc 3.weka.classifiers.bayes.net.estimate code | doc

沒有留言: