Module orngBayes contains a Bayesian learner which uses the one from Orange, with the only difference that using the m-estimate is much simpler than with the learner built in Orange. Besides, the module has a function for printing out the classifier in a textual form.
Class orngBayes.BayesLearner
is similar to orange.BayesLearner
(the former in fact uses the latter) except that for estimating the probabilities with m-estimates you don't need to set a bunch of probability estimators, you can simply specify the value of m. To show how, let's compare a naive Bayesian classifier with m-estimate (m=2) with one that uses relative frequencies to estimate probabilities.
part of bayes.py
Attributes
All the attributes listed here are optional in the sense that they appear and are used only if you set them.
orange.ProbabilityEstimatorConstructor_m
). This attribute is ignored if you also set estimatorConstructor
.orange.ProbabilityEstimatorConstructor
. Setting this attribute disable the above described attribute m
.If none of these attributes is given, relative frequencies are used for a priori class probabilities and conditional probabilities of discrete attributes, and loess is used for continuous attributes.
Methods
orngBayes.BayesLearner
. Or it can be given learning examples (and possibly a weight meta attribute), it will construct and return a classifier (an instance of orange.BayesClassifier
).orange.BayesClassifier
, module orngBayes
doesn't provide a special classifier.orange.BayesLearner
with the components set as defined by the attributes. Actually, when you call orngBayes.BayesLearner
it calls createInstance
to construct an appropriate orange.BayesLearner
and forwards the call to it.To print out the model in form of contingency matrices, call function orngBayes.printModel(model)
, like the code below:
part of bayes.py
The output will start with
This function is unable to print out the model if it contains continuous attributes or advanced probability estimators which wouldn't store the pre-computed probabilities (we have none like this at the moment).