Changes in [9821:6cc715432fa7:9822:14677303b55b] in orange
r9754 r9820 5 5 ################################### 6 6 7 All classifiers in Orange consist of two parts, a Learner and a Classifier. A 8 learner is constructed with all parameters that will be used for learning. 9 When a data table is passed to its __call__ method, a model is fitted to the 10 data and return in a form of a Classifier, which is then used for predicting 11 the dependent variable(s) of new instances. 7 To facilitate correct evaluation, all classifiers in Orange consist of two 8 parts, a Learner and a Classifier. A learner is constructed with all 9 parameters that will be used for learning. When a data table is passed to its 10 __call__ method, a model is fitted to the data and return in a form of a 11 Classifier, which is then used for predicting the dependent variable(s) of 12 new instances. 12 13 13 14 .. class:: Learner() … … 56 57 tuple with both 57 58 58 You can often program learners and classifiers as classes or functions written 59 entirely in Python and independent from Orange. Such classes can participate, 60 for instance, in the common evaluation functions like those available in 61 modules :obj:`Orange.evaluation.testing` and :obj:`Orange.evaluation.scoring`. 62 59 63 On the other hand, these classes can't be used as components for pure C++ 64 classes. For instance, :obj:`Orange.classification.tree.TreeLearner`'s 65 attribute nodeLearner should contain a (wrapped) C++ object derived from 66 :obj:`Learner`, such as :obj:`Orange.classification.majority.MajorityLearner` 67 or :obj:`Orange.classification.bayes.NaiveLearner`. They cannot accommodate 68 Python's classes or even functions. 60 When developing new prediction models, one should extend :obj:`Learner` and 61 :obj:`Classifier`\. Code that infers the model from the data should be placed 62 in Learners's :obj:`~Learner.__call__` method. This method should 63 return a :obj:`Classifier`. Classifiers' :obj:`~Classifier.__call__` method 64 should return the predicition; :class:`~Orange.data.Value`, 65 :class:`~Orange.statistics.distribution.Distribution` or a tuple with both 66 based on the value of the parameter :obj:`return_type`. 69 67 70 There's a workaround, though. You can subtype Orange classes :obj:`Learner` or 71 :obj:`Classifier` as if the two classes were defined in Python, but later use your 72 derived Python classes as if they were written in Orange's core. That is, you 73 can define your class in a Python script like this:: 74 75 class MyLearner(Orange.classifier.Learner): 76 def __call__(self, examples, weightID = 0): 77 <do something smart here> 78 79 Such a learner can then be used as any regular learner written in 80 Orange. You can, for instance, construct a tree learner and use your 81 learner to learn node classifier:: 82 83 treeLearner = Orange.classification.tree.TreeLearner() 84 treeLearner.nodeLearner = MyLearner() 85 86 ----- 87 88 Orange contains implementations of various classifiers that are described in 89 detail on separate pages. 68 Orange implements various classifiers that are described in detail on 69 separate pages. 90 70 91 71 .. toctree::
Note: See TracChangeset for help on using the changeset viewer.