source: orange/Orange/classification/majority.py @ 9671:a7b056375472

Revision 9671:a7b056375472, 2.5 KB checked in by anze <anze.staric@…>, 2 years ago (diff)

Moved orange to Orange (part 2)

Line 
1"""
2***********************
3Majority (``majority``)
4***********************
5
6.. index:: majority classifier
7   pair: classification; majority classifier
8
9Accuracy of classifiers is often compared to the "default accuracy",
10that is, the accuracy of a classifier which classifies all instances
11to the majority class. To fit into the standard schema, even this
12algorithm is provided in form of the usual learner-classifier pair.
13Learning is done by :obj:`MajorityLearner` and the classifier it
14constructs is an instance of :obj:`ConstantClassifier`.
15
16.. class:: MajorityLearner
17
18    MajorityLearner will most often be used as is, without setting any
19    parameters. Nevertheless, it has two.
20
21    .. attribute:: estimator_constructor
22   
23        An estimator constructor that can be used for estimation of
24        class probabilities. If left None, probability of each class is
25        estimated as the relative frequency of instances belonging to
26        this class.
27       
28    .. attribute:: apriori_distribution
29   
30        Apriori class distribution that is passed to estimator
31        constructor if one is given.
32
33.. class:: ConstantClassifier
34
35    ConstantClassifier always classifies to the same class and reports the
36    same class probabilities.
37
38    Its constructor can be called without arguments, with a variable (for
39    :obj:`class_var`), value (for :obj:`default_val`) or both. If the value
40    is given and is of type :obj:`Orange.data.Value` (alternatives are an
41    integer index of a discrete value or a continuous value), its attribute
42    :obj:`Orange.data.Value.variable` will either be used for initializing
43    :obj:`class_var` if variable is not given as an argument, or checked
44    against the variable argument, if it is given.
45   
46    .. attribute:: default_val
47   
48        Value that is returned by the classifier.
49   
50    .. attribute:: default_distribution
51
52        Class probabilities returned by the classifier.
53   
54    .. attribute:: class_var
55   
56        Class variable that the classifier predicts.
57
58
59Examples
60========
61
62This "learning algorithm" will most often be used as a baseline,
63that is, to determine if some other learning algorithm provides
64any information about the class (:download:`majority-classification.py <code/majority-classification.py>`,
65uses: :download:`monks-1.tab <code/monks-1.tab>`):
66
67.. literalinclude:: code/majority-classification.py
68    :lines: 7-
69
70"""
71
72from Orange.core import MajorityLearner
73from Orange.core import DefaultClassifier as ConstantClassifier
Note: See TracBrowser for help on using the repository browser.