source: orange/docs/reference/rst/Orange.classification.bayes.rst @ 9635:f7279fdd2d42

Revision 9635:f7279fdd2d42, 2.1 KB checked in by anze <anze.staric@…>, 2 years ago (diff)

Improved bayes documentation.

Line 
1.. automodule:: Orange.classification.bayes
2
3.. index:: naive Bayes classifier
4
5.. index::
6   single: classification; naive Bayes classifier
7
8**********************************
9Naive Bayes classifier (``bayes``)
10**********************************
11
12A `Naive Bayes classifier
13<http://en.wikipedia.org/wiki/Naive_Bayes_classifier>`_ is a
14probabilistic classifier that estimates conditional probabilities of the
15dependant variable from training data and uses them for classification
16of new data instances. The algorithm is very fast for discrete features, but
17runs slower for continuous features.
18
19The following example demonstrates a straightforward invocation of
20this algorithm:
21
22.. literalinclude:: code/bayes-run.py
23   :lines: 7-
24
25.. index:: Naive Bayesian Learner
26.. autoclass:: Orange.classification.bayes.NaiveLearner
27   :members:
28   :show-inheritance:
29
30.. autoclass:: Orange.classification.bayes.NaiveClassifier
31   :members:
32   :show-inheritance:
33
34
35Examples
36========
37
38:obj:`NaiveLearner` can estimate probabilities using relative frequencies or
39m-estimate:
40
41.. literalinclude:: code/bayes-mestimate.py
42    :lines: 7-
43
44Conditional probabilities in an m-estimate based classifier show a
45shift towards the second class - as compared to probabilities above, where
46relative frequencies were used. The change in error estimation did
47not have any effect on apriori probabilities:
48
49.. literalinclude:: code/bayes-thresholdAdjustment.py
50    :lines: 7-
51
52Setting :obj:`~NaiveLearner.adjust_threshold` can improve the results.
53The classification accuracies of 10-fold cross-validation of a normal naive
54bayesian classifier, and one with an adjusted threshold::
55
56    [0.7901746265516516, 0.8280138859667578]
57
58Probability distributions for continuous features are estimated with \
59:class:`~Orange.statistics.estimate.Loess`.
60
61.. literalinclude:: code/bayes-plot-iris.py
62    :lines: 4-
63
64.. image:: files/bayes-iris.png
65   :scale: 50 %
66
67If petal lengths are shorter, the most probable class is "setosa". Irises with
68middle petal lengths belong to "versicolor", while longer petal lengths indicate
69for "virginica". Critical values where the decision would change are at about
705.4 and 6.3.
Note: See TracBrowser for help on using the repository browser.