Default Classifier

Accuracy of classifiers is often compared to the "default accuracy", that is, the accuracy of a classifier which classifies all examples to the majority class. To fit into the standard schema, even this algorithm is provided in form of the usual learner-classifier pair. Learning is done by orange.MajorityLearner and the classifier it construct is an instance of orange.DefaultClassifier.

Learning

MajorityLearner will most often be used as is, without setting any features. Nevertheless, it has two.

Attributes

estimatorConstructor
An estimator constructor that can be used for estimation of class probabilities. If left None, probability of each class is estimated as the relative frequency of examples belonging to this class.
aprioriDistribution
Apriori class distribution that is passed to estimator constructor if one is given.

Classification

DefaultClassifier always classifies to the same class and reports same class probabilities.

Attributes

defaultVal
Value that is returned by the classifier.
defaultDistribution
Class probabilities returned by the classifier.

The DefaultClassifier's constructor can be called without arguments, with value (for defaultVal), variable (for classVar). If the value is given and is of type orange.Value (alternatives are an integer index of a discrete value or a continuous value), its field variable is will either be used for initializing classVar if variable is not given as an argument, or checked against the variable argument, if it is given.


Example

This "learning algorithm" will most often be used to establish whether some other learning algorithm is better than "nothing". Here's a simple example.

majority.py (uses monk1.tab)

import orange, orngTest, orngStat data = orange.ExampleTable("monk1") treeLearner = orange.TreeLearner() bayesLearner = orange.BayesLearner() majorityLearner = orange.MajorityLearner() learners = [treeLearner, bayesLearner, majorityLearner] res = orngTest.crossValidation(learners, data) CAs = orngStat.CA(res, reportSE = 1) print "Tree: %5.3f+-%5.3f" % CAs[0] print "Bayes: %5.3f+-%5.3f" % CAs[1] print "Default: %5.3f+-%5.3f" % CAs[2]