source: orange/orange/doc/reference/majority.htm @ 6538:a5f65d7f0b2c

Revision 6538:a5f65d7f0b2c, 2.9 KB checked in by Mitar <Mitar@…>, 4 years ago (diff)

Made XPM version of the icon 32x32.

Line 
1<html> <HEAD>
2<LINK REL=StyleSheet HREF="../style.css" TYPE="text/css">
3<LINK REL=StyleSheet HREF="style-print.css" TYPE="text/css" MEDIA=print>
4</HEAD> <body>
5
6<h1>Default Classifier</h1>
7<index name="classifiers+majority classifier">
8<index name="default classifier">
9
10<P>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 <CODE>orange.<INDEX name="classes/MajorityLearner">MajorityLearner</CODE> and the classifier it construct is an instance of <CODE>orange.<INDEX name="classes/DefaultClassifier">DefaultClassifier</CODE>.</P>
11
12<H2>Learning</H2>
13
14<P><CODE>MajorityLearner</CODE> will most often be used as is, without setting any features. Nevertheless, it has two.</P>
15
16<P class=section>Attributes</P>
17<DL class=attributes>
18<DT>estimatorConstructor</DT>
19<DD>An estimator constructor that can be used for estimation of class probabilities. If left <CODE>None</CODE>, probability of each class is estimated as the relative frequency of examples belonging to this class.</DD>
20
21<DT>aprioriDistribution</DT>
22<DD>Apriori class distribution that is passed to estimator constructor if one is given.</DD>
23</DL>
24
25
26<H2>Classification</H2>
27
28<P><CODE>DefaultClassifier</CODE> always classifies to the same class and reports same class probabilities.</P>
29
30<P class=section>Attributes</P>
31<DL class=attributes>
32<DT>defaultVal</DT>
33<DD>Value that is returned by the classifier.</DD>
34
35<DT>defaultDistribution</DT>
36<DD>Class probabilities returned by the classifier.</DD>
37</DL>
38
39<P>The <CODE>DefaultClassifier</CODE>'s constructor can be called without arguments, with value (for <CODE>defaultVal</CODE>), variable (for <CODE>classVar</CODE>). If the value is given and is of type <CODE>orange.Value</CODE> (alternatives are an integer index of a discrete value or a continuous value), its field <CODE>variable</CODE> is will either be used for initializing <CODE>classVar</CODE> if variable is not given as an argument, or checked against the variable argument, if it is given.
40
41<HR>
42
43<H2>Example</H2>
44
45<P>This "learning algorithm" will most often be used to establish whether some other learning algorithm is better than "nothing". Here's a simple example.</P>
46
47<p class="header"><a href="majority.py">majority.py</a>
48(uses <a href="monk1.tab">monk1.tab</a>)</p>
49<XMP class=code>import orange, orngTest, orngStat
50
51data = orange.ExampleTable("monk1")
52
53treeLearner = orange.TreeLearner()
54bayesLearner = orange.BayesLearner()
55majorityLearner = orange.MajorityLearner()
56learners = [treeLearner, bayesLearner, majorityLearner]
57
58res = orngTest.crossValidation(learners, data)
59CAs = orngStat.CA(res, reportSE = 1)
60
61print "Tree:    %5.3f+-%5.3f" % CAs[0]
62print "Bayes:   %5.3f+-%5.3f" % CAs[1]
63print "Default: %5.3f+-%5.3f" % CAs[2]
64</XMP>
65
66</BODY></HTML>
Note: See TracBrowser for help on using the repository browser.