source: orange/docs/reference/rst/code/bayes-mestimate.py @ 9638:eb3af38491f2

Revision 9638:eb3af38491f2, 921 bytes checked in by umek@…, 2 years ago (diff)

Changed table to data or name of the data set.

For example - instead of

table = Orange.data.Table("housing")

is changed to

housing = Orange.data.Table("housing")

Line 
1# Description: Naive Bayes Learner with m-estimate
2# Category:    classification
3# Uses:        iris
4# Referenced:  Orange.classification.bayes
5# Classes:     Orange.classification.bayes.NaiveLearner, Orange.classification.bayes.NaiveClassifier
6
7import Orange
8
9lenses = Orange.data.Table("lenses.tab")
10
11bayes_L = Orange.classification.bayes.NaiveLearner(name="Naive Bayes")
12bayesWithM_L = Orange.classification.bayes.NaiveLearner(m=2, name="Naive Bayes w/ m-estimate")
13bayes = bayes_L(lenses)
14bayesWithM = bayesWithM_L(lenses)
15
16print bayes.conditional_distributions
17# prints: <<'pre-presbyopic': <0.625, 0.125, 0.250>, 'presbyopic': <0.750, 0.125, 0.125>, ...>>
18print bayesWithM.conditional_distributions
19# prints: <<'pre-presbyopic': <0.625, 0.133, 0.242>, 'presbyopic': <0.725, 0.133, 0.142>, ...>>
20
21print bayes.distribution
22# prints: <0.625, 0.167, 0.208>
23print bayesWithM.distribution
24# prints: <0.625, 0.167, 0.208>
Note: See TracBrowser for help on using the repository browser.