Changeset 10375:e29f566e9513 in orange


Ignore:
Timestamp:
02/25/12 22:45:45 (2 years ago)
Author:
janezd <janez.demsar@…>
Branch:
default
Message:

Moved documentation about ConstantClassifier to a separate page

Location:
docs/reference/rst
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • docs/reference/rst/Orange.classification.rst

    r10347 r10375  
    66 
    77Induction of models in Orange is implemented through a two-class 
    8 schema. A learning algorithm is represented as an instance of a class 
     8schema. A learning algorithm is represented by an instance of a class 
    99derived from :obj:`Orange.classification.Learner`. The learner stores 
    10 all parameters of the learning algorithm. When a learner is called 
    11 with some data, it fits a model of the kind specific to the learning 
    12 algorithm and returns it as a (new) instance of a class derived 
    13 :obj:`Orange.classification.Classifier` that holds parameters of the model. 
     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. 
    1420 
    1521.. literalinclude:: code/bayes-run.py 
    1622   :lines: 7- 
    1723 
    18 Orange implements various classifiers that are described in detail on 
     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 
    1932separate pages. 
    2033 
     
    3144   Orange.classification.lookup 
    3245   Orange.classification.classfromvar 
     46   Orange.classification.constant 
    3347    
    34 Base classes 
    35 ------------ 
    3648 
    3749All learning algorithms and prediction models are derived from the following two clases. 
     
    4153    Abstract base class for learning algorithms. 
    4254 
    43     .. method:: __call__(data) 
     55    .. method:: __call__(data[, weightID]) 
    4456 
    4557        An abstract method that fits a model and returns it as an 
    46         instance of :class:`Classifier`. 
     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. 
    4762 
    4863 
     
    8095              :class:`~Orange.statistics.distribution.Distribution` or a 
    8196              tuple with both 
    82  
    83  
    84 Constant Classifier 
    85 ------------------- 
    86  
    87 The classification module also contains a classifier that always 
    88 predicts the same value. This classifier is constructed by different 
    89 learners such as 
    90 :obj:`~Orange.classification.majority.MajorityLearner`, and also by 
    91 some 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 TracChangeset for help on using the changeset viewer.