source: orange/docs/reference/rst/Orange.classification.rst @ 10347:566f380f0bc5

Revision 10347:566f380f0bc5, 4.2 KB checked in by janezd <janez.demsar@…>, 2 years ago (diff)

Dedostoyevskied documentation on lookup learners, changed the order of classifiers in the index

Line 
1.. automodule:: Orange.classification
2
3###################################
4Classification (``classification``)
5###################################
6
7Induction of models in Orange is implemented through a two-class
8schema. A learning algorithm is represented as an instance of a class
9derived from :obj:`Orange.classification.Learner`. The learner stores
10all parameters of the learning algorithm. When a learner is called
11with some data, it fits a model of the kind specific to the learning
12algorithm and returns it as a (new) instance of a class derived
13:obj:`Orange.classification.Classifier` that holds parameters of the model.
14
15.. literalinclude:: code/bayes-run.py
16   :lines: 7-
17
18Orange implements various classifiers that are described in detail on
19separate pages.
20
21.. toctree::
22   :maxdepth: 1
23
24   Orange.classification.bayes
25   Orange.classification.knn
26   Orange.classification.rules
27   Orange.classification.svm
28   Orange.classification.tree
29   Orange.classification.logreg
30   Orange.classification.majority
31   Orange.classification.lookup
32   Orange.classification.classfromvar
33   
34Base classes
35------------
36
37All learning algorithms and prediction models are derived from the following two clases.
38
39.. class:: Learner()
40
41    Abstract base class for learning algorithms.
42
43    .. method:: __call__(data)
44
45        An abstract method that fits a model and returns it as an
46        instance of :class:`Classifier`.
47
48
49.. class:: Classifier()
50
51    Abstract base class for prediction models (both classifiers and regressors).
52
53    .. method:: __call__(instance, return_type=GetValue)
54
55        Classify a new instance using this model. Results depends upon
56        the second parameter that must be one of the following.
57
58    :obj:`Orange.classification.Classifier.GetValue`
59
60        Return value of the target class when performing prediction.
61
62    :obj:`Orange.classification.Classifier.GetProbabilities`
63
64        Return probability of each target class when performing prediction.
65
66    :obj:`Orange.classification.Classifier.GetBoth`
67
68        Return a tuple of target class value and probabilities for each class.
69
70       
71        :param instance: data instance to be classified.
72        :type instance: :class:`~Orange.data.Instance`
73
74        :param return_type: what needs to be predicted
75        :type return_type: :obj:`GetBoth`,
76                           :obj:`GetValue`,
77                           :obj:`GetProbabilities`
78
79        :rtype: :class:`~Orange.data.Value`,
80              :class:`~Orange.statistics.distribution.Distribution` or a
81              tuple with both
82
83
84Constant Classifier
85-------------------
86
87The classification module also contains a classifier that always
88predicts the same value. This classifier is constructed by different
89learners such as
90:obj:`~Orange.classification.majority.MajorityLearner`, and also by
91some other methods.
92
93.. class:: ConstantClassifier
94
95    Predict the specified ``default_val`` or ``default_distribution``
96    for any instance.
97
98    .. attribute:: class_var
99
100        Class variable that the classifier predicts.
101
102    .. attribute:: default_val
103
104        The value returned by the classifier.
105
106    .. attribute:: default_distribution
107
108        Class probabilities returned by the classifier.
109   
110    .. method:: __init__(variable, value, distribution)
111
112        Constructor can be called without arguments, with a
113        variable, value or both. If the value is given and is of type
114        :obj:`Orange.data.Value`, its attribute
115        :obj:`Orange.data.Value.variable` will either be used for
116        initializing
117        :obj:`~Orange.classification.ConstantClassifier.variable` or
118        checked against it, if :obj:`variable` is given as an
119        argument.
120       
121        :param variable: Class variable that the classifier predicts.
122        :type variable: :obj:`Orange.feature.Descriptor`
123        :param value: Value returned by the classifier.
124        :type value: :obj:`Orange.data.Value` or int (index) or float
125        :param distribution: Class probabilities returned by the classifier.
126        :type dstribution: :obj:`Orange.statistics.distribution.Distribution`
127       
128    .. method:: __call__(instance, return_type)
129       
130        Return :obj:`default_val` and/or :obj:`default_distribution`
131        (depending upon :obj:`return_type`) disregarding the
132        :obj:`instance`.
133
134
135
Note: See TracBrowser for help on using the repository browser.