source: orange/docs/reference/rst/Orange.classification.rst @ 10375:e29f566e9513

Revision 10375:e29f566e9513, 3.2 KB checked in by janezd <janez.demsar@…>, 2 years ago (diff)

Moved documentation about ConstantClassifier to a separate page

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 by an instance of a class
9derived from :obj:`Orange.classification.Learner`. The learner stores
10all parameters of the learning algorithm. Induced models are
11represented by instances of classes derived from
12:obj:`Orange.classification.Classifier`.
13
14Therefore, to induce models from data, one first needs to construct
15the instance representing a learning algorithm
16(e.g. :obj:`~Orange.classification.tree.TreeLearner`) and set its
17parameters. Calling the learner with some training data returns a
18classifier (e.g. :obj:`~Orange.classification.tree.TreeClassifier`). The
19learner does not "learn" to classify but constructs classifiers.
20
21.. literalinclude:: code/bayes-run.py
22   :lines: 7-
23
24To simplify the procedure, the learner's constructor can also be given
25training data, in which case it fits and returns a model (an instance
26of :obj:`~Orange.classification.Classifier`) instead of a learner::
27
28    classifier = Orange.classification.bayes.NaiveLearner(titanic)
29
30
31Orange contains a number of learning algorithms described in detail on
32separate pages.
33
34.. toctree::
35   :maxdepth: 1
36
37   Orange.classification.bayes
38   Orange.classification.knn
39   Orange.classification.rules
40   Orange.classification.svm
41   Orange.classification.tree
42   Orange.classification.logreg
43   Orange.classification.majority
44   Orange.classification.lookup
45   Orange.classification.classfromvar
46   Orange.classification.constant
47   
48
49All learning algorithms and prediction models are derived from the following two clases.
50
51.. class:: Learner()
52
53    Abstract base class for learning algorithms.
54
55    .. method:: __call__(data[, weightID])
56
57        An abstract method that fits a model and returns it as an
58        instance of :class:`Classifier`. The first argument gives the
59        data (as :obj:`Orange.data.Table` and the optional second
60        argument gives the id of the meta attribute with instance
61        weights.
62
63
64.. class:: Classifier()
65
66    Abstract base class for prediction models (both classifiers and regressors).
67
68    .. method:: __call__(instance, return_type=GetValue)
69
70        Classify a new instance using this model. Results depends upon
71        the second parameter that must be one of the following.
72
73    :obj:`Orange.classification.Classifier.GetValue`
74
75        Return value of the target class when performing prediction.
76
77    :obj:`Orange.classification.Classifier.GetProbabilities`
78
79        Return probability of each target class when performing prediction.
80
81    :obj:`Orange.classification.Classifier.GetBoth`
82
83        Return a tuple of target class value and probabilities for each class.
84
85       
86        :param instance: data instance to be classified.
87        :type instance: :class:`~Orange.data.Instance`
88
89        :param return_type: what needs to be predicted
90        :type return_type: :obj:`GetBoth`,
91                           :obj:`GetValue`,
92                           :obj:`GetProbabilities`
93
94        :rtype: :class:`~Orange.data.Value`,
95              :class:`~Orange.statistics.distribution.Distribution` or a
96              tuple with both
Note: See TracBrowser for help on using the repository browser.