Orange Forum • View topic - How to use Orange.classification.bayes.NaiveClassifier

How to use Orange.classification.bayes.NaiveClassifier

A place to ask questions about methods in Orange and how they are used and other general support.

How to use Orange.classification.bayes.NaiveClassifier

Postby lonicolefeb13 » Sun Feb 26, 2012 9:44


I'm having trouble understanding the use of NaiveLearner and NaiveClassifier. A post here says that the Learner is for training and the Classifier is for predicting. However, I still have no idea on how to use them.

Should the NaiveClassifier base its predictions from the Learner? If yes, how is it done? Should there be a classification model? Is the Learner the Classification Model?

I want to know this since I am trying to make a classifying system. I have a labeled dataset and an unlabeled dataset, and I want the system to label the unlabeled dataset using the labeled dataset as training set.


P.S. If you have sample codes I would greatly appreciate it. Thanks

Re: How to use Orange.classification.bayes.NaiveClassifier

Postby Ales » Mon Feb 27, 2012 11:40

The 'Learner' classes in orange by convention don't hold any trained model details, and are nothing more then a placeholder for the corresponding algorithm function and the parameters. For instance:
Code: Select all
import Orange
# Load data and split it in train and test subsets
iris ="")
indices =
train =, 1)
test =, 0)

# Construct the learner class
learner = Orange.classification.bayes.NaiveLearner(m=10)

# Train a classifier using learner on the train subset
classifier = learner(train)
# Here the learner is unchanged, it could be modified (set a different 'm', ...) or even used
# to train new classifiers on completely different datasets and that would not change the
# already trained classifier.

# Predict class values on test subset
for instance in test:
    print "True:", instance.get_class(),"Predicted:", classifier(instance)

Re: How to use Orange.classification.bayes.NaiveClassifier

Postby lonicolefeb13 » Tue Feb 28, 2012 6:12

Thanks Ales,

But what's the use of the Classifier?

Re: How to use Orange.classification.bayes.NaiveClassifier

Postby Ales » Tue Feb 28, 2012 15:41

The classifier is then used for classification of new data instances. It therefore holds all of the trained model details. For instance the NaiveClassifier stores the class distributions and conditional distributions needed for classification of new instances.

Return to Questions & Support