## 2014年5月29日 星期四

### [ML in DH] Classification 之 Naive Bayesian Categorization

Preface:

Naive Bayesian Training:

Example: Naive Bayesian Categorization

Toolkit Usage:

1. def labels = ["Age""Income""Student?""CC""Class"]
2. def datas =  [["<=30""高""N""O""N"],
3.               ["<=30""高""N""G""N"],
4.               ["31-40""高""N""O""Y"],
5.               [">40""中""N""O""Y"],
6.               [">40""低""Y""O""Y"],
7.               [">40""低""Y""G""N"],
8.               ["31-40""低""Y""G""Y"],
9.               ["<=30""中""N""O""N"],
10.               ["<=30""低""Y""O""Y"],
11.               [">40""中""Y""O""Y"],
12.               ["<=30""中""Y""G""Y"],
13.               ["31-40""中""N""G""Y"],
14.               ["31-40""高""Y""O""Y"],
15.               [">40""中""N""G""N"]]
16. NaiveBayes nb = new NaiveBayes()
17.
18. // 收集每個 Instance 的 Category
19. def cateList = datas.collect {it[4]}
20. def instances = []
21. datas.each { data->
22.     //printf "\t[Test] %s\n", data[0..3].join(",")
24. }
25. printf "\t[Info] NaiveBayes training...%s\n", nb.train2(instances, cateList)
26. def testInst = ["<=30""中""Y""O"]
27. printf "\t[Info] Instance=[%s] is classified as %s!\n", testInst.join(","), nb.classify2(testInst)
28. testInst = ["31-40""高""N""O"]
29. printf "\t[Info] Instance=[%s] is classified as %s!\n", testInst.join(","), nb.classify2(testInst)

Supplement:
[ ML In Action ] Classifying with probability theory : naive Bayes

### [Linux 常見問題] What's the best way to send a signal to all members of a process group?

Source From  Here   Question   I want to  kill a whole process tree.  What is the best way to do this using any common scripting languages? ...