#
source:
orange/docs/reference/rst/Orange.classification.bayes.rst
@
9372:aef193695ea9

Revision 9372:aef193695ea9, 2.1 KB checked in by mitar, 2 years ago (diff) |
---|

Line | |
---|---|

1 | .. automodule:: Orange.classification.bayes |

2 | |

3 | .. index:: naive Bayes classifier |

4 | |

5 | .. index:: |

6 | single: classification; naive Bayes classifier |

7 | |

8 | ********************************** |

9 | Naive Bayes classifier (``bayes``) |

10 | ********************************** |

11 | |

12 | A `Naive Bayes classifier |

13 | <http://en.wikipedia.org/wiki/Naive_Bayes_classifier>`_ is a simple |

14 | probabilistic classifier that estimates conditional probabilities of the |

15 | dependant variable from training data and uses them for classification |

16 | of new data instances. The algorithm is very fast for discrete features, but |

17 | runs slower for continuous features. |

18 | |

19 | The following example demonstrates a straightforward invocation of |

20 | this 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 | |

35 | Examples |

36 | ======== |

37 | |

38 | :obj:`NaiveLearner` can estimate probabilities using relative frequencies or |

39 | m-estimate: |

40 | |

41 | .. literalinclude:: code/bayes-mestimate.py |

42 | :lines: 7- |

43 | |

44 | Conditional probabilities in an m-estimate based classifier show a |

45 | shift towards the second class - as compared to probabilities above, where |

46 | relative frequencies were used. The change in error estimation did |

47 | not have any effect on apriori probabilities: |

48 | |

49 | .. literalinclude:: code/bayes-thresholdAdjustment.py |

50 | :lines: 7- |

51 | |

52 | Setting :obj:`~NaiveLearner.adjust_threshold` can improve the results. |

53 | The classification accuracies of 10-fold cross-validation of a normal naive |

54 | bayesian classifier, and one with an adjusted threshold:: |

55 | |

56 | [0.7901746265516516, 0.8280138859667578] |

57 | |

58 | Probability 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:: code/bayes-iris.png |

65 | :scale: 50 % |

66 | |

67 | If petal lengths are shorter, the most probable class is "setosa". Irises with |

68 | middle petal lengths belong to "versicolor", while longer petal lengths indicate |

69 | for "virginica". Critical values where the decision would change are at about |

70 | 5.4 and 6.3. |

**Note:**See TracBrowser for help on using the repository browser.