source: orange/source/orange/lib_learner.cpp @ 10377:2b8ddbb0e27c

Revision 10377:2b8ddbb0e27c, 96.3 KB checked in by janezd <janez.demsar@…>, 2 years ago (diff)

Fixed problems due to refactoring of classification.rules

Line 
1/*
2    This file is part of Orange.
3   
4    Copyright 1996-2010 Faculty of Computer and Information Science, University of Ljubljana
5    Contact: janez.demsar@fri.uni-lj.si
6
7    Orange is free software: you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation, either version 3 of the License, or
10    (at your option) any later version.
11
12    Orange is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with Orange.  If not, see <http://www.gnu.org/licenses/>.
19*/
20
21
22#ifdef _MSC_VER
23  #pragma warning (disable : 4786 4114 4018 4267 4244)
24#endif
25
26#include <iostream>
27#include <sstream>
28
29#include "vars.hpp"
30#include "domain.hpp"
31#include "examples.hpp"
32#include "examplegen.hpp"
33#include "nearest.hpp"
34#include "estimateprob.hpp"
35#include "induce.hpp"
36#include "cost.hpp"
37#include "measures.hpp"
38#include "distance.hpp"
39#include "contingency.hpp"
40
41#include "callback.hpp"
42
43#include "cls_orange.hpp"
44#include "cls_value.hpp"
45#include "cls_example.hpp"
46#include "lib_kernel.hpp"
47
48#include "converts.hpp"
49
50#include "vectortemplates.hpp"
51#include "slist.hpp"
52
53#include "externs.px"
54
55/* ************ SIMPLE TREE LEARNER ************ */
56
57#include "tdidt_simple.hpp"
58C_CALL(SimpleTreeLearner - Orange.classification.tree.SimpleTreeLearner, Learner, "([examples], [maxMajority=, minExamples=, maxDepth=])")
59C_NAMED(SimpleTreeClassifier - Orange.classification.tree.SimpleTreeClassifier, Classifier, "()")
60
61PyObject *SimpleTreeClassifier__reduce__(PyObject *self)
62{
63    PyTRY
64    ostringstream ss;
65
66    CAST_TO(TSimpleTreeClassifier, classifier);
67    classifier->save_model(ss);
68    return Py_BuildValue("O(s)N", getExportedFunction("__pickleLoaderSimpleTreeClassifier"), 
69        ss.str().c_str(), packOrangeDictionary(self));
70    PyCATCH
71}
72
73PyObject *__pickleLoaderSimpleTreeClassifier(PyObject *self, PyObject *args) PYARGS(METH_VARARGS, "(buffer)")
74{
75    PyTRY
76    char *cbuf;
77    istringstream ss;
78
79    int buffer_size = 0;
80    if (!PyArg_ParseTuple(args, "s:__pickleLoaderSimpleTreeClassifier", &cbuf))
81        return NULL;
82    ss.str(string(cbuf));
83    PSimpleTreeClassifier classifier = mlnew TSimpleTreeClassifier();
84    classifier->load_model(ss);
85    return WrapOrange(classifier);
86    PyCATCH
87}
88
89
90/* ************ MAJORITY AND COST ************ */
91
92#include "majority.hpp"
93C_CALL(MajorityLearner - Orange.classification.majority.MajorityLearner, Learner, "([examples] [, weight=, estimate=]) -/-> Classifier")
94C_CALL(CostLearner - Orange.wrappers.CostLearner, Learner, "([examples] [, weight=, estimate=, costs=]) -/-> Classifier")
95
96
97#include "costwrapper.hpp"
98C_CALL(CostWrapperLearner - Orange.wrappers.CostWrapperLearner, Learner, "([examples] [, weight=, costs=]) -/-> Classifier")
99C_NAMED(CostWrapperClassifier - Orange.wrappers.CostWrapperClassifier, Classifier, "([classifier=, costs=])")
100
101
102/************* ASSOCIATION RULES ************/
103
104#include "assoc.hpp"
105C_CALL(AssociationLearner, Learner, "([examples] [, weight=, conf=, supp=, voteWeight=]) -/-> Classifier")
106C_NAMED(AssociationClassifier, ClassifierFD, "([rules=, voteWeight=])")
107C_CALL3(AssociationRulesInducer - Orange.associate.AssociationRulesInducer, AssociationRulesInducer, Orange, "([examples[, weightID]], confidence=, support=]) -/-> AssociationRules")
108C_CALL3(AssociationRulesSparseInducer - Orange.associate.AssociationRulesSparseInducer, AssociationRulesSparseInducer, Orange, "([examples[, weightID]], confidence=, support=]) -/-> AssociationRules")
109C_CALL3(ItemsetsSparseInducer - Orange.associate.ItemsetsSparseInducer, ItemsetsSparseInducer, Orange, "([examples[, weightID]], support=]) -/-> AssociationRules")
110
111BASED_ON(ItemsetNodeProxy - Orange.associate.ItemsetNodeProxy, Orange)
112
113bool operator < (const TAssociationRule &, const TAssociationRule &) { return false; }
114bool operator > (const TAssociationRule &, const TAssociationRule &) { return false; }
115
116PyObject *AssociationRulesInducer_call(PyObject *self, PyObject *args, PyObject *keywords) PYDOC("(examples[, weightID]) -> AssociationRules")
117{
118  PyTRY
119    NO_KEYWORDS
120
121    int weightID;
122    PExampleGenerator egen = exampleGenFromArgs(args, weightID);
123    if (!egen)
124      return PYNULL;
125
126    return WrapOrange(SELF_AS(TAssociationRulesInducer)(egen, weightID));
127  PyCATCH
128}
129
130void gatherRules(TItemSetNode *node, vector<pair<int, int> > &itemsSoFar, PyObject *listOfItems, bool storeExamples)
131{
132  for(; node; node = node->nextAttribute) {
133    itemsSoFar.push_back(make_pair(node->attrIndex, (int)0));
134    ITERATE(vector<TItemSetValue>, isi, node->values) {
135      itemsSoFar.back().second = (*isi).value;
136
137      PyObject *itemset = PyTuple_New(itemsSoFar.size());
138      int el = 0;
139      vector<pair<int, int> >::const_iterator sfi(itemsSoFar.begin()), sfe(itemsSoFar.end());
140      for(; sfi != sfe; sfi++, el++) {
141        PyObject *vp = PyTuple_New(2);
142        PyTuple_SET_ITEM(vp, 0, PyInt_FromLong((*sfi).first));
143        PyTuple_SET_ITEM(vp, 1, PyInt_FromLong((*sfi).second));
144        PyTuple_SET_ITEM(itemset, el, vp);
145      }
146
147      PyObject *examples;
148      if (storeExamples) {
149        examples = PyList_New((*isi).examples.size());
150        Py_ssize_t ele = 0;
151        ITERATE(TExampleSet, ei, (*isi).examples)
152          PyList_SetItem(examples, ele++, PyInt_FromLong((*ei).example));
153      }
154      else {
155        examples = Py_None;
156        Py_INCREF(Py_None);
157      }
158
159      PyObject *rr = PyTuple_New(2);
160      PyTuple_SET_ITEM(rr, 0, itemset);
161      PyTuple_SET_ITEM(rr, 1, examples);
162
163      PyList_Append(listOfItems, rr);
164      Py_DECREF(rr);
165
166      gatherRules((*isi).branch, itemsSoFar, listOfItems, storeExamples);
167    }
168    itemsSoFar.pop_back();
169  }
170}
171
172PyObject *AssociationRulesInducer_getItemsets(PyObject *self, PyObject *args, PyObject *keywords) PYARGS(METH_VARARGS, "(examples[, weightID]) -> list-of-itemsets")
173{
174  PyTRY
175    int weightID;
176    PExampleGenerator egen = exampleGenFromArgs(args, weightID);
177    if (!egen)
178      return PYNULL;
179
180    if (egen->domain->hasContinuousAttributes(true))
181      PYERROR(PyExc_TypeError, "cannot induce rules with non-discrete attributes", NULL);
182
183    TItemSetNode *tree = NULL;
184    PyObject *listOfItemsets = NULL;
185    try {
186        int depth, nOfExamples;
187        TDiscDistribution classDist;
188        CAST_TO(TAssociationRulesInducer, inducer);
189        inducer->buildTrees(egen, weightID, tree, depth, nOfExamples, classDist);
190
191        listOfItemsets = PyList_New(0);
192        vector<pair<int, int> > itemsSoFar;
193        gatherRules(tree, itemsSoFar, listOfItemsets, inducer->storeExamples);
194    }
195    catch (...) {
196        if (tree)
197            delete tree;
198        throw;
199    }
200
201    delete tree;
202    return listOfItemsets;
203  PyCATCH
204}
205
206
207void gatherRules(TSparseItemsetNode *node, vector<int> &itemsSoFar, PyObject *listOfItems, bool storeExamples)
208{
209    if (itemsSoFar.size()) {
210        PyObject *itemset = PyTuple_New(itemsSoFar.size());
211        Py_ssize_t el = 0;
212        vector<int>::const_iterator sfi(itemsSoFar.begin()), sfe(itemsSoFar.end());
213        for(; sfi != sfe; sfi++, el++)
214            PyTuple_SET_ITEM(itemset, el, PyInt_FromLong(*sfi));
215
216        PyObject *examples;
217        if (storeExamples) {
218          examples = PyList_New(node->exampleIds.size());
219          Py_ssize_t ele = 0;
220          ITERATE(vector<int>, ei, node->exampleIds)
221            PyList_SetItem(examples, ele++, PyInt_FromLong(*ei));
222        }
223        else {
224          examples = Py_None;
225          Py_INCREF(Py_None);
226        }
227
228      PyObject *rr = PyTuple_New(2);
229      PyTuple_SET_ITEM(rr, 0, itemset);
230      PyTuple_SET_ITEM(rr, 1, examples);
231
232      PyList_Append(listOfItems, rr);
233      Py_DECREF(rr);
234    }
235
236    itemsSoFar.push_back(0);
237    ITERATE(TSparseISubNodes, isi, node->subNode) {
238        itemsSoFar.back() = (*isi).first;
239        gatherRules((*isi).second, itemsSoFar, listOfItems, storeExamples);
240    }
241    itemsSoFar.pop_back();
242}
243
244
245PyObject *AssociationRulesSparseInducer_getItemsets(PyObject *self, PyObject *args, PyObject *keywords) PYARGS(METH_VARARGS, "(examples[, weightID]) -> list-of-itemsets")
246{
247  PyTRY
248    int weightID;
249    PExampleGenerator egen = exampleGenFromArgs(args, weightID);
250    if (!egen)
251      return PYNULL;
252
253    CAST_TO(TAssociationRulesSparseInducer, inducer);
254    long i;
255    float fullWeight;
256    TSparseItemsetTree *tree = NULL;
257    PyObject *listOfItemsets = NULL;
258
259    try {
260          tree = inducer->buildTree(egen, weightID, i, fullWeight);
261        listOfItemsets = PyList_New(0);
262        vector<int> itemsSoFar;
263        gatherRules(tree->root, itemsSoFar, listOfItemsets, inducer->storeExamples);
264    }
265    catch (...) {
266        if (tree)
267            delete tree;
268        throw;
269    }
270
271    delete tree;
272    return listOfItemsets;
273  PyCATCH
274}
275
276PyObject *AssociationRulesSparseInducer_call(PyObject *self, PyObject *args, PyObject *keywords) PYDOC("(examples[, weightID]) -> AssociationRules")
277{
278  PyTRY
279    NO_KEYWORDS
280
281    int weightID = 0;
282    PExampleGenerator egen =  exampleGenFromArgs(args, weightID);
283    if (!egen)
284      return PYNULL;
285
286    return WrapOrange(SELF_AS(TAssociationRulesSparseInducer)(egen, weightID));
287  PyCATCH
288}
289
290class TItemsetNodeProxy : public TOrange {
291public:
292    const TSparseItemsetNode *node;
293    PSparseItemsetTree tree;
294
295    TItemsetNodeProxy(const TSparseItemsetNode *n, PSparseItemsetTree t)
296    : node(n),
297    tree(t)
298    {}
299};
300
301
302PyObject *ItemsetsSparseInducer_call(PyObject *self, PyObject *args, PyObject *keywords) PYDOC("(examples[, weightID]) -> AssociationRules")
303{
304  PyTRY
305    NO_KEYWORDS
306
307    int weightID = 0;
308    PExampleGenerator egen =  exampleGenFromArgs(args, weightID);
309    if (!egen)
310      return PYNULL;
311
312    PSparseItemsetTree tree = SELF_AS(TItemsetsSparseInducer)(egen, weightID);
313    return WrapOrange(POrange(new TItemsetNodeProxy(tree->root, tree)));
314  PyCATCH
315}
316
317PYXTRACT_IGNORE int Orange_traverse(TPyOrange *, visitproc, void *);
318PYXTRACT_IGNORE int Orange_clear(TPyOrange *);
319
320int ItemsetNodeProxy_traverse(PyObject *self, visitproc visit, void *arg)
321{
322    int err = Orange_traverse((TPyOrange *)self, visit, arg);
323    if (err)
324        return err;
325
326    CAST_TO_err(TItemsetNodeProxy, node, -1);
327    PVISIT(node->tree);
328  PVISIT(node->tree->domain);
329    return 0;
330}
331
332int ItemsetNodeProxy_clear(PyObject *self)
333{
334  SELF_AS(TItemsetNodeProxy).tree = PSparseItemsetTree();
335    return Orange_clear((TPyOrange *)self);
336}
337
338PyObject *ItemsetNodeProxy_get_children(PyObject *self)
339{
340  PyTRY
341    CAST_TO(TItemsetNodeProxy, nodeProxy);
342    const TSparseItemsetNode *me = nodeProxy->node;
343    PyObject *children = PyDict_New();
344    const_ITERATE(TSparseISubNodes, ci, me->subNode)
345      PyDict_SetItem(children, PyInt_FromLong(ci->first), WrapOrange(POrange(new TItemsetNodeProxy(ci->second, nodeProxy->tree))));
346    return children;
347  PyCATCH
348}
349
350PyObject *ItemsetNodeProxy_get_examples(PyObject *self)
351{
352  PyTRY
353    const TSparseItemsetNode *me = SELF_AS(TItemsetNodeProxy).node;
354    PyObject *examples = PyList_New(me->exampleIds.size());
355    Py_ssize_t i = 0;
356    const_ITERATE(vector<int>, ci, me->exampleIds)
357      PyList_SetItem(examples, i++, PyInt_FromLong(*ci));
358    return examples;
359  PyCATCH
360}
361
362PyObject *ItemsetNodeProxy_get_support(PyObject *self)
363{
364  PyTRY
365    return PyFloat_FromDouble(SELF_AS(TItemsetNodeProxy).node->weiSupp);
366  PyCATCH
367}
368
369PyObject *ItemsetNodeProxy_get_itemId(PyObject *self)
370{
371  PyTRY
372    return PyInt_FromLong(SELF_AS(TItemsetNodeProxy).node->value);
373  PyCATCH
374}
375
376
377
378bool convertFromPython(PyObject *, PAssociationRule &);
379
380PyObject *AssociationRule_new(PyTypeObject *type, PyObject *args, PyObject *) BASED_ON(Orange - Orange.associate.AssociationRule, "(left, right, support, confidence)")
381{ PyTRY
382    PAssociationRule rule;
383    return  convertFromPython(args, rule) ? WrapOrange(rule) : PYNULL;
384  PyCATCH
385}
386
387PyObject *AssociationRule__reduce__(PyObject *self)
388{
389  PyTRY
390    CAST_TO(TAssociationRule, arule);
391    return Py_BuildValue("O(NN)N", self->ob_type,
392                                   Example_FromWrappedExample(arule->left),
393                                   Example_FromWrappedExample(arule->right),
394                                   packOrangeDictionary(self));
395  PyCATCH
396}
397
398
399PyObject *AssociationRule_appliesLeft(PyObject *self, PyObject *arg, PyObject *) PYARGS(METH_O, "(example) -> bool")
400{ PyTRY
401    if (!PyOrExample_Check(arg))
402      PYERROR(PyExc_TypeError, "attribute error (example expected)", PYNULL);
403
404    CAST_TO(TAssociationRule, rule)
405    return PyInt_FromLong(rule->appliesLeft(PyExample_AS_ExampleReference(arg)) ? 1 : 0);
406  PyCATCH
407}
408
409
410PyObject *AssociationRule_appliesRight(PyObject *self, PyObject *arg, PyObject *) PYARGS(METH_O, "(example) -> bool")
411{ PyTRY
412    if (!PyOrExample_Check(arg))
413      PYERROR(PyExc_TypeError, "attribute error (example expected)", PYNULL);
414
415    CAST_TO(TAssociationRule, rule)
416    return PyInt_FromLong(rule->appliesRight(PyExample_AS_ExampleReference(arg)) ? 1 : 0);
417  PyCATCH
418}
419
420
421PyObject *AssociationRule_appliesBoth(PyObject *self, PyObject *arg, PyObject *) PYARGS(METH_O, "(example) -> bool")
422{ PyTRY
423    if (!PyOrExample_Check(arg))
424      PYERROR(PyExc_TypeError, "attribute error (example expected)", PYNULL);
425
426    CAST_TO(TAssociationRule, rule)
427    return PyInt_FromLong(rule->appliesBoth(PyExample_AS_ExampleReference(arg)) ? 1 : 0);
428  PyCATCH
429}
430
431
432PyObject *AssociationRule_native(PyObject *self)
433{ PyTRY
434    CAST_TO(TAssociationRule, rule)
435    return Py_BuildValue("NNff", Example_FromWrappedExample(rule->left), Example_FromWrappedExample(rule->right), rule->support, rule->confidence);
436  PyCATCH
437}
438
439bool convertFromPython(PyObject *obj, PAssociationRule &rule)
440{ if (PyOrOrange_Check(obj))
441    if (!PyOrange_AS_Orange(obj)) {
442      rule = PAssociationRule();
443      return true;
444    }
445    else if (PyOrAssociationRule_Check(obj)) {
446      rule = PyOrange_AsAssociationRule(obj);
447      return true;
448    }
449
450  TExample *le, *re;
451
452  switch (PyTuple_Size(obj)) {
453    case 6:
454      float nAppliesLeft, nAppliesRight, nAppliesBoth, nExamples;
455      if (PyArg_ParseTuple(obj, "O&O&ffff:convertFromPython(AssociationRule)", ptr_Example, &le, ptr_Example, &re, &nAppliesLeft, &nAppliesRight, &nAppliesBoth, &nExamples)) {
456        PExample nle = mlnew TExample(*le);
457        PExample nre = mlnew TExample(*re);
458        rule = mlnew TAssociationRule(nle, nre, nAppliesLeft, nAppliesRight, nAppliesBoth, nExamples);
459        return true;
460      }
461      else
462        break;
463
464    case 2:
465    case 3:
466    case 4: {
467      float support = -1, confidence = -1;
468      if (PyArg_ParseTuple(obj, "O&O&|ff:convertFromPython(AssociationRule)", ptr_Example, &le, ptr_Example, &re, &support, &confidence)) {
469        PExample nle = mlnew TExample(*le);
470        PExample nre = mlnew TExample(*re);
471        rule = mlnew TAssociationRule(nle, nre);
472        rule->support = support;
473        rule->confidence = confidence;
474        return true;
475      }
476      else
477        break;
478    }
479
480    case 1:
481      if (PyArg_ParseTuple(obj, "O&:convertFromPython(AssociationRule)", cc_AssociationRule, &rule))
482        return true;
483      else
484        break;
485  }
486
487  PYERROR(PyExc_TypeError, "invalid arguments", false);
488}
489
490
491string side2string(PExample ex)
492{ string res;
493
494  if (ex->domain->variables->empty())
495    ITERATE(TMetaValues, mi, ex->meta) {
496      if (res.length())
497        res += " ";
498      res += ex->domain->getMetaVar((*mi).first)->get_name();
499    }
500
501  else {
502    string val;
503
504    TVarList::const_iterator vi(ex->domain->variables->begin());
505    for(TExample::const_iterator ei(ex->begin()), ee(ex->end()); ei!=ee; ei++, vi++)
506      if (!(*ei).isSpecial()) {
507        if (res.length())
508          res += " ";
509        (*vi)->val2str(*ei, val);
510        res += (*vi)->get_name() + "=" + val;
511      }
512  }
513
514  return res;
515}
516
517PyObject *AssociationRule_str(TPyOrange *self)
518{
519  PyObject *result = callbackOutput((PyObject *)self, NULL, NULL, "str", "repr");
520  if (result)
521    return result;
522
523  CAST_TO(TAssociationRule, rule);
524  return PyString_FromFormat("%s -> %s", side2string(rule->left).c_str(), side2string(rule->right).c_str());
525}
526
527
528PyObject *AssociationRule_repr(TPyOrange *self)
529{
530  PyObject *result = callbackOutput((PyObject *)self, NULL, NULL, "repr", "str");
531  if (result)
532    return result;
533
534  CAST_TO(TAssociationRule, rule);
535  return PyString_FromFormat("%s -> %s", side2string(rule->left).c_str(), side2string(rule->right).c_str());
536}
537
538
539PAssociationRules PAssociationRules_FromArguments(PyObject *arg) { return ListOfWrappedMethods<PAssociationRules, TAssociationRules, PAssociationRule, &PyOrAssociationRule_Type>::P_FromArguments(arg); }
540PyObject *AssociationRules_FromArguments(PyTypeObject *type, PyObject *arg) { return ListOfWrappedMethods<PAssociationRules, TAssociationRules, PAssociationRule, &PyOrAssociationRule_Type>::_FromArguments(type, arg); }
541PyObject *AssociationRules_new(PyTypeObject *type, PyObject *arg, PyObject *kwds) BASED_ON(Orange - Orange.associate.AssociationRules, "(<list of AssociationRule>)")  ALLOWS_EMPTY { return ListOfWrappedMethods<PAssociationRules, TAssociationRules, PAssociationRule, &PyOrAssociationRule_Type>::_new(type, arg, kwds); }
542PyObject *AssociationRules_getitem_sq(TPyOrange *self, Py_ssize_t index) { return ListOfWrappedMethods<PAssociationRules, TAssociationRules, PAssociationRule, &PyOrAssociationRule_Type>::_getitem(self, index); }
543int       AssociationRules_setitem_sq(TPyOrange *self, Py_ssize_t index, PyObject *item) { return ListOfWrappedMethods<PAssociationRules, TAssociationRules, PAssociationRule, &PyOrAssociationRule_Type>::_setitem(self, index, item); }
544PyObject *AssociationRules_getslice(TPyOrange *self, Py_ssize_t start, Py_ssize_t stop) { return ListOfWrappedMethods<PAssociationRules, TAssociationRules, PAssociationRule, &PyOrAssociationRule_Type>::_getslice(self, start, stop); }
545int       AssociationRules_setslice(TPyOrange *self, Py_ssize_t start, Py_ssize_t stop, PyObject *item) { return ListOfWrappedMethods<PAssociationRules, TAssociationRules, PAssociationRule, &PyOrAssociationRule_Type>::_setslice(self, start, stop, item); }
546Py_ssize_t       AssociationRules_len_sq(TPyOrange *self) { return ListOfWrappedMethods<PAssociationRules, TAssociationRules, PAssociationRule, &PyOrAssociationRule_Type>::_len(self); }
547PyObject *AssociationRules_richcmp(TPyOrange *self, PyObject *object, int op) { return ListOfWrappedMethods<PAssociationRules, TAssociationRules, PAssociationRule, &PyOrAssociationRule_Type>::_richcmp(self, object, op); }
548PyObject *AssociationRules_concat(TPyOrange *self, PyObject *obj) { return ListOfWrappedMethods<PAssociationRules, TAssociationRules, PAssociationRule, &PyOrAssociationRule_Type>::_concat(self, obj); }
549PyObject *AssociationRules_repeat(TPyOrange *self, Py_ssize_t times) { return ListOfWrappedMethods<PAssociationRules, TAssociationRules, PAssociationRule, &PyOrAssociationRule_Type>::_repeat(self, times); }
550PyObject *AssociationRules_str(TPyOrange *self) { return ListOfWrappedMethods<PAssociationRules, TAssociationRules, PAssociationRule, &PyOrAssociationRule_Type>::_str(self); }
551PyObject *AssociationRules_repr(TPyOrange *self) { return ListOfWrappedMethods<PAssociationRules, TAssociationRules, PAssociationRule, &PyOrAssociationRule_Type>::_str(self); }
552int       AssociationRules_contains(TPyOrange *self, PyObject *obj) { return ListOfWrappedMethods<PAssociationRules, TAssociationRules, PAssociationRule, &PyOrAssociationRule_Type>::_contains(self, obj); }
553PyObject *AssociationRules_append(TPyOrange *self, PyObject *item) PYARGS(METH_O, "(AssociationRule) -> None") { return ListOfWrappedMethods<PAssociationRules, TAssociationRules, PAssociationRule, &PyOrAssociationRule_Type>::_append(self, item); }
554PyObject *AssociationRules_extend(TPyOrange *self, PyObject *obj) PYARGS(METH_O, "(sequence) -> None") { return ListOfWrappedMethods<PAssociationRules, TAssociationRules, PAssociationRule, &PyOrAssociationRule_Type>::_extend(self, obj); }
555PyObject *AssociationRules_count(TPyOrange *self, PyObject *obj) PYARGS(METH_O, "(AssociationRule) -> int") { return ListOfWrappedMethods<PAssociationRules, TAssociationRules, PAssociationRule, &PyOrAssociationRule_Type>::_count(self, obj); }
556PyObject *AssociationRules_filter(TPyOrange *self, PyObject *args) PYARGS(METH_VARARGS, "([filter-function]) -> AssociationRules") { return ListOfWrappedMethods<PAssociationRules, TAssociationRules, PAssociationRule, &PyOrAssociationRule_Type>::_filter(self, args); }
557PyObject *AssociationRules_index(TPyOrange *self, PyObject *obj) PYARGS(METH_O, "(AssociationRule) -> int") { return ListOfWrappedMethods<PAssociationRules, TAssociationRules, PAssociationRule, &PyOrAssociationRule_Type>::_index(self, obj); }
558PyObject *AssociationRules_insert(TPyOrange *self, PyObject *args) PYARGS(METH_VARARGS, "(index, item) -> None") { return ListOfWrappedMethods<PAssociationRules, TAssociationRules, PAssociationRule, &PyOrAssociationRule_Type>::_insert(self, args); }
559PyObject *AssociationRules_native(TPyOrange *self) PYARGS(METH_NOARGS, "() -> list") { return ListOfWrappedMethods<PAssociationRules, TAssociationRules, PAssociationRule, &PyOrAssociationRule_Type>::_native(self); }
560PyObject *AssociationRules_pop(TPyOrange *self, PyObject *args) PYARGS(METH_VARARGS, "() -> AssociationRule") { return ListOfWrappedMethods<PAssociationRules, TAssociationRules, PAssociationRule, &PyOrAssociationRule_Type>::_pop(self, args); }
561PyObject *AssociationRules_remove(TPyOrange *self, PyObject *obj) PYARGS(METH_O, "(AssociationRule) -> None") { return ListOfWrappedMethods<PAssociationRules, TAssociationRules, PAssociationRule, &PyOrAssociationRule_Type>::_remove(self, obj); }
562PyObject *AssociationRules_reverse(TPyOrange *self) PYARGS(METH_NOARGS, "() -> None") { return ListOfWrappedMethods<PAssociationRules, TAssociationRules, PAssociationRule, &PyOrAssociationRule_Type>::_reverse(self); }
563PyObject *AssociationRules_sort(TPyOrange *self, PyObject *args) PYARGS(METH_VARARGS, "([cmp-func]) -> None") { return ListOfWrappedMethods<PAssociationRules, TAssociationRules, PAssociationRule, &PyOrAssociationRule_Type>::_sort(self, args); }
564PyObject *AssociationRules__reduce__(TPyOrange *self, PyObject *) { return ListOfWrappedMethods<PAssociationRules, TAssociationRules, PAssociationRule, &PyOrAssociationRule_Type>::_reduce(self); }
565
566/************* CLASSIFICATION TREES ************/
567
568#include "tdidt.hpp"
569#include "tdidt_split.hpp"
570#include "tdidt_stop.hpp"
571#include "callback.hpp"
572
573C_CALL(TreeLearner - Orange.classification.tree._TreeLearner, Learner, "([examples] [, weight=, split=, stop=, nodeLearner=, lookDownOnUnknown=]) -/-> Classifier")
574
575C_NAMED(TreeNode - Orange.classification.tree.Node, Orange, "([lookDownOnUnknown=, branchSelector=, nodeClassifier=, branches=, contingency=])")
576C_NAMED(TreeClassifier - Orange.classification.tree._TreeClassifier, ClassifierFD, "([domain=, tree=, descender=])")
577
578C_NAMED(TreeStopCriteria_common - Orange.classification.tree.StopCriteria_common, TreeStopCriteria, "([maxMajority=, minExamples=])")
579HIDDEN(TreeStopCriteria_Python - Orange.classification.tree.StopCriteria_Python, TreeStopCriteria)
580NO_PICKLE(TreeStopCriteria_Python)
581
582C_CALL(TreeSplitConstructor_Combined - Orange.classification.tree.SplitConstructor_Combined, TreeSplitConstructor, "([examples, [weight, domainContingency, apriorClass, candidates] [discreteTreeSplitConstructor=, continuousTreeSplitConstructor=]) -/-> (Classifier, descriptions, sizes, quality)")
583
584ABSTRACT(TreeSplitConstructor_Measure - Orange.classification.tree.SplitConstructor_Score, TreeSplitConstructor)
585C_CALL(TreeSplitConstructor_Attribute - Orange.classification.tree.SplitConstructor_Feature, TreeSplitConstructor_Measure, "([measure=, worstAcceptable=, minSubset=])")
586C_CALL(TreeSplitConstructor_ExhaustiveBinary - Orange.classification.tree.SplitConstructor_ExhaustiveBinary, TreeSplitConstructor_Measure, "([measure=, worstAcceptable=, minSubset=])")
587C_CALL(TreeSplitConstructor_OneAgainstOthers - Orange.classification.tree.SplitConstructor_OneAgainstOthers, TreeSplitConstructor_Measure, "([measure=, worstAcceptable=, minSubset=])")
588C_CALL(TreeSplitConstructor_Threshold - Orange.classification.tree.SplitConstructor_Threshold, TreeSplitConstructor_Measure, "([measure=, worstAcceptable=, minSubset=])")
589PYXTRACT_IGNORE C_CALL(TreeSplitConstructor_LR - Orange.classification.tree.SplitConstructor_LR, TreeSplitConstructor, "([minSubset=])")
590
591BASED_ON(TreeExampleSplitter - Orange.classification.tree.Splitter, Orange)
592
593C_CALL(TreeExampleSplitter_IgnoreUnknowns - Orange.classification.tree.Splitter_IgnoreUnknowns, TreeExampleSplitter, "([node, examples[, weight]]) -/-> (ExampleGeneratorList, [list of weight ID's])")
594C_CALL(TreeExampleSplitter_UnknownsToCommon - Orange.classification.tree.Splitter_UnknownsToCommon, TreeExampleSplitter, "([node, examples[, weight]]) -/-> (ExampleGeneratorList, [list of weight ID's])")
595C_CALL(TreeExampleSplitter_UnknownsToAll - Orange.classification.tree.Splitter_UnknownsToAll, TreeExampleSplitter, "([node, examples[, weight]]) -/-> (ExampleGeneratorList, [list of weight ID's])")
596C_CALL(TreeExampleSplitter_UnknownsToRandom - Orange.classification.tree.Splitter_UnknownsToRandom, TreeExampleSplitter, "([node, examples[, weight]]) -/-> (ExampleGeneratorList, [list of weight ID's])")
597C_CALL(TreeExampleSplitter_UnknownsToBranch - Orange.classification.tree.Splitter_UnknownsToBranch, TreeExampleSplitter, "([node, examples[, weight]]) -/-> (ExampleGeneratorList, [list of weight ID's])")
598
599C_CALL(TreeExampleSplitter_UnknownsAsBranchSizes - Orange.classification.tree.Splitter_UnknownsAsBranchSizes, TreeExampleSplitter, "([branchIndex, node, examples[, weight]]) -/-> (ExampleGenerator, [list of weight ID's])")
600C_CALL(TreeExampleSplitter_UnknownsAsSelector - Orange.classification.tree.Splitter_UnknownsAsSelector, TreeExampleSplitter, "([branchIndex, node, examples[, weight]]) -/-> (ExampleGenerator, [list of weight ID's])")
601
602C_CALL(TreeDescender_UnknownToBranch - Orange.classification.tree.Descender_UnknownToBranch, TreeDescender, "(node, example) -/-> (node, {distribution | None})")
603C_CALL(TreeDescender_UnknownToCommonBranch - Orange.classification.tree.Descender_UnknownToCommonBranch, TreeDescender, "(node, example) -/-> (node, {distribution | None})")
604C_CALL(TreeDescender_UnknownToCommonSelector - Orange.classification.tree.Descender_UnknownToCommonSelector, TreeDescender, "(node, example) -/-> (node, {distribution | None})")
605C_CALL(TreeDescender_UnknownMergeAsBranchSizes - Orange.classification.tree.Descender_UnknownMergeAsBranchSizes, TreeDescender, "(node, example) -/-> (node, {distribution | None})")
606C_CALL(TreeDescender_UnknownMergeAsSelector - Orange.classification.tree.Descender_UnknownMergeAsSelector, TreeDescender, "(node, example) -/-> (node, {distribution | None})")
607
608ABSTRACT(TreePruner - Orange.classification.tree.Pruner, Orange)
609C_CALL (TreePruner_SameMajority - Orange.classification.tree.Pruner_SameMajority, TreePruner, "([tree]) -/-> tree")
610C_CALL (TreePruner_m - Orange.classification.tree.Pruner_m, TreePruner, "([tree]) -/-> tree")
611
612
613PyObject *TreeNode_tree_size(PyObject *self, PyObject *, PyObject *) PYARGS(METH_NOARGS, "() -> int")
614{ PyTRY
615    return PyInt_FromLong(PyOrange_AsTreeNode(self)->treeSize());
616  PyCATCH
617}
618
619
620PyObject *TreeNode_remove_stored_info(PyObject *self, PyObject *, PyObject *) PYARGS(METH_NOARGS, "() -> None")
621{ PyTRY
622    PyOrange_AsTreeNode(self)->removeStoredInfo();
623    RETURN_NONE;
624  PyCATCH
625}
626
627
628PyObject *TreeStopCriteria_new(PyTypeObject *type, PyObject *args, PyObject *keywords)  BASED_ON(Orange - Orange.classification.tree.StopCriteria, "()")
629{ if (type == (PyTypeObject *)&PyOrTreeStopCriteria_Type) {
630      PyObject *name=NULL;
631      if (args && !PyArg_ParseTuple(args, "|O", &name))
632        PYERROR(PyExc_TypeError, "TreeStopCriteria: invalid arguments - name or callback function expected", PYNULL);
633
634      if (!args || !name || name && PyString_Check(name)) {
635          PyObject *self = WrapNewOrange(mlnew TTreeStopCriteria(), type);
636          if (name)
637            PyObject_SetAttrString(self, "name", name);
638          return self;
639      }
640      // (args && name && !PyStringString_Check(name)
641
642      return setCallbackFunction(WrapNewOrange(mlnew TTreeStopCriteria_Python(), type), args);
643  }
644
645  return WrapNewOrange(mlnew TTreeStopCriteria_Python(), type);
646}
647
648
649/* This is all twisted: Python classes are derived from TreeStopCriteria;
650   although the underlying C++ structure is TreeStopCriteria_Python,
651   the Python base is always TreeStopCritera. We must therefore define
652   TreeStopCriteria__reduce__ to handle both C++ objects, and need not
653   define TreeStopCriteria_Python__reduce__
654*/
655
656PyObject *TreeStopCriteria__reduce__(PyObject *self)
657{
658  POrange orself = PyOrange_AS_Orange(self);
659
660  if (orself.is_derived_from(TTreeStopCriteria_Python) && PyObject_HasAttrString(self, "__callback")) {
661    PyObject *packed = packOrangeDictionary(self);
662    PyObject *callback = PyDict_GetItemString(packed, "__callback");
663    PyDict_DelItemString(packed, "__callback");
664    return Py_BuildValue("O(O)N", self->ob_type, callback, packed);
665  }
666
667  /* This works for ordinary (not overloaded) TreeStopCriteria
668     and for Python classes derived from TreeStopCriteria.
669     The latter have different self->ob_type, so TreeStopCriteria_new will construct
670     an instance of TreeStopCriteria_Python */
671  return Py_BuildValue("O()N", self->ob_type, packOrangeDictionary(self));
672}
673
674
675PyObject *TreeStopCriteria_lowcall(PyObject *self, PyObject *args, PyObject *keywords, bool allowPython)
676{
677  static TTreeStopCriteria _cbdefaultStop;
678  PyTRY
679    NO_KEYWORDS
680
681    CAST_TO(TTreeStopCriteria, stop);
682    if (!stop)
683      PYERROR(PyExc_SystemError, "attribute error", PYNULL);
684
685    PExampleGenerator egen;
686    PDomainContingency dcont;
687    int weight = 0;
688    if (!PyArg_ParseTuple(args, "O&|O&O&:TreeStopCriteria.__call__", pt_ExampleGenerator, &egen, pt_weightByGen(egen), &weight, ptn_DomainContingency, &dcont))
689      return PYNULL;
690
691    bool res;
692
693    if (allowPython || (stop->classDescription() != &TTreeStopCriteria_Python::st_classDescription))
694      res = (*stop)(egen, weight, dcont);
695    else
696      res = _cbdefaultStop(egen, weight, dcont);
697
698    return PyInt_FromLong(res ? 1 : 0);
699  PyCATCH
700}
701
702
703PyObject *TreeStopCriteria_call(PyObject *self, PyObject *args, PyObject *keywords) PYDOC("([examples, [weight, domainContingency]) -> bool")
704{  return TreeStopCriteria_lowcall(self, args, keywords, false); }
705
706
707PyObject *TreeStopCriteria_Python_call(PyObject *self, PyObject *args, PyObject *keywords) PYDOC("([examples, [weight, domainContingency, apriorClass, candidates]) -/-> (Classifier, descriptions, sizes, quality)")
708{ return TreeStopCriteria_lowcall(self, args, keywords, false); }
709
710
711
712PyObject *TreeSplitConstructor_new(PyTypeObject *type, PyObject *args, PyObject *keywords)  BASED_ON(Orange - Orange.classification.tree.SplitConstructor, "<abstract>")
713{ if (type == (PyTypeObject *)&PyOrTreeSplitConstructor_Type)
714    return setCallbackFunction(WrapNewOrange(mlnew TTreeSplitConstructor_Python(), type), args);
715  else
716    return WrapNewOrange(mlnew TTreeSplitConstructor_Python(), type);
717}
718
719
720PyObject *TreeSplitConstructor__reduce__(PyObject *self)
721{
722  return callbackReduce(self, PyOrTreeSplitConstructor_Type);
723}
724
725
726PyObject *TreeSplitConstructor_call(PyObject *self, PyObject *args, PyObject *keywords) PYDOC("(examples[, weight, contingency, apriori class distribution, candidates, nodeClassifier]) -> (Classifier, descriptions, sizes, quality)")
727{ PyTRY
728    NO_KEYWORDS
729
730    if (PyOrange_OrangeBaseClass(self->ob_type) == &PyOrTreeSplitConstructor_Type) {
731      PyErr_Format(PyExc_SystemError, "TreeSplitConstructor.call called for '%s': this may lead to stack overflow", self->ob_type->tp_name);
732      return PYNULL;
733    }
734
735    PExampleGenerator gen;
736    int weightID = 0;
737    PDomainContingency dcont;
738    PDistribution apriori;
739    PyObject *pycandidates = PYNULL;
740    PClassifier nodeClassifier;
741
742    if (!PyArg_ParseTuple(args, "O&|O&O&O&OO&:TreeSplitConstructor.call", pt_ExampleGenerator, &gen, pt_weightByGen(gen), &weightID, ccn_DomainContingency, &dcont, ccn_Distribution, &apriori, &pycandidates, ccn_Classifier, &nodeClassifier))
743      return PYNULL;
744
745    vector<bool> candidates;
746    if (pycandidates) {
747      PyObject *iterator = PyObject_GetIter(pycandidates);
748      if (!iterator)
749        PYERROR(PyExc_SystemError, "TreeSplitConstructor.call: cannot iterate through candidates; a list exected", PYNULL);
750      for(PyObject *item = PyIter_Next(iterator); item; item = PyIter_Next(iterator)) {
751        candidates.push_back(PyObject_IsTrue(item) != 0);
752        Py_DECREF(item);
753      }
754
755      Py_DECREF(iterator);
756      if (PyErr_Occurred())
757        return PYNULL;
758    }
759
760    PClassifier branchSelector;
761    PStringList descriptions;
762    PDiscDistribution subsetSizes;
763    float quality;
764    int spentAttribute;
765
766    branchSelector = SELF_AS(TTreeSplitConstructor)(descriptions, subsetSizes, quality, spentAttribute,
767                                                    gen, weightID, dcont, apriori, candidates, nodeClassifier);
768
769    return Py_BuildValue("NNNfi", WrapOrange(branchSelector), WrapOrange(descriptions), WrapOrange(subsetSizes), quality, spentAttribute);
770  PyCATCH
771}
772
773
774PyObject *TreeExampleSplitter_new(PyTypeObject *type, PyObject *args, PyObject *keywords)  BASED_ON(Orange - Orange.classification.tree.Splitter, "<abstract>")
775{ if (type == (PyTypeObject *)&PyOrTreeExampleSplitter_Type)
776    return setCallbackFunction(WrapNewOrange(mlnew TTreeExampleSplitter_Python(), type), args);
777  else
778    return WrapNewOrange(mlnew TTreeExampleSplitter_Python(), type);
779}
780
781
782PyObject *TreeExampleSplitter__reduce__(PyObject *self)
783{
784  return callbackReduce(self, PyOrTreeExampleSplitter_Type);
785}
786
787
788PyObject *TreeExampleSplitter_call(PyObject *self, PyObject *args, PyObject *keywords) PYDOC("(node, examples[, weight]) -/-> (ExampleGeneratorList, list of weight ID's")
789{ PyTRY
790    NO_KEYWORDS
791
792    if (PyOrange_OrangeBaseClass(self->ob_type) == &PyOrTreeExampleSplitter_Type) {
793      PyErr_Format(PyExc_SystemError, "TreeExampleSplitter.call called for '%s': this may lead to stack overflow", self->ob_type->tp_name);
794      return PYNULL;
795    }
796
797    PTreeNode node;
798    PExampleGenerator gen;
799    int weightID = 0;
800
801    if (!PyArg_ParseTuple(args, "O&O&|O&:TreeExampleSplitter.call", cc_TreeNode, &node, pt_ExampleGenerator, &gen, pt_weightByGen(gen), &weightID))
802      return PYNULL;
803
804    vector<int> newWeights;
805    PExampleGeneratorList egl = SELF_AS(TTreeExampleSplitter)(node, gen, weightID, newWeights);
806
807    if (newWeights.size()) {
808      PyObject *pyweights = PyList_New(newWeights.size());
809      Py_ssize_t i = 0;
810      ITERATE(vector<int>, li, newWeights)
811        PyList_SetItem(pyweights, i++, PyInt_FromLong(*li));
812
813      return Py_BuildValue("NN", WrapOrange(egl), pyweights);
814    }
815
816    else {
817      return Py_BuildValue("NO", WrapOrange(egl), Py_None);
818    }
819
820  PyCATCH
821}
822
823
824
825PyObject *TreeDescender_new(PyTypeObject *type, PyObject *args, PyObject *keywords)  BASED_ON(Orange - Orange.classification.tree.Descender, "<abstract>")
826{ if (type == (PyTypeObject *)&PyOrTreeDescender_Type)
827    return setCallbackFunction(WrapNewOrange(mlnew TMeasureAttribute_Python(), type), args);
828  else
829    return WrapNewOrange(mlnew TTreeDescender_Python(), type);
830}
831
832
833PyObject *TreeDescender__reduce__(PyObject *self)
834{
835  return callbackReduce(self, PyOrTreeDescender_Type);
836}
837
838
839PyObject *TreeDescender_call(PyObject *self, PyObject *args, PyObject *keywords) PYDOC("(node, example) -/-> (node, {distribution | None})")
840{ PyTRY
841    NO_KEYWORDS
842
843    if (PyOrange_OrangeBaseClass(self->ob_type) == &PyOrTreeDescender_Type) {
844      PyErr_Format(PyExc_SystemError, "TreeDescender.call called for '%s': this may lead to stack overflow", self->ob_type->tp_name);
845      return PYNULL;
846    }
847
848    PTreeNode onode;
849    TExample *example;
850    if (!PyArg_ParseTuple(args, "O&O&", cc_TreeNode, &onode, ptr_Example, &example))
851      PYERROR(PyExc_TypeError, "invalid parameters", PYNULL);
852
853    PDiscDistribution distr;
854    PTreeNode node = SELF_AS(TTreeDescender)(onode, *example, distr);
855    return Py_BuildValue("NN", WrapOrange(node), WrapOrange(distr));
856  PyCATCH
857}
858
859
860PyObject *TreePruner_call(PyObject *self, PyObject *args, PyObject *keywords) PYDOC("(tree) -> tree")
861{
862  PyTRY
863    NO_KEYWORDS
864
865    PyObject *obj;
866    PTreeNode node;
867    PTreeClassifier classifier;
868    if (PyArg_ParseTuple(args, "O", &obj))
869      if (PyOrTreeClassifier_Check(obj)) {
870        classifier = PyOrange_AsClassifier(obj);
871        node = classifier->tree;
872      }
873      else if (PyOrTreeNode_Check(obj))
874        node = PyOrange_AsTreeNode(obj);
875
876    if (!node)
877      PYERROR(PyExc_TypeError, "invalid arguments (a classifier expected)", PYNULL);
878
879    PTreeNode newRoot = SELF_AS(TTreePruner)(node);
880
881    if (classifier) {
882      PTreeClassifier newClassifier = CLONE(TTreeClassifier, classifier);
883      newClassifier->tree = newRoot;
884      return WrapOrange(newClassifier);
885    }
886    else
887      return WrapOrange(newRoot);
888  PyCATCH
889}
890
891
892PyObject *TreeClassifier_treesize(PyObject *self, PyObject *, PyObject *) PYARGS(METH_NOARGS, "() -> size")
893{ PyTRY
894    CAST_TO(TTreeClassifier, me);
895    if (!me->tree)
896      PYERROR(PyExc_SystemError, "TreeClassifier: 'tree' not defined", PYNULL);
897
898    return PyInt_FromLong(long(me->tree->treeSize()));
899  PyCATCH
900}
901
902
903PTreeNodeList PTreeNodeList_FromArguments(PyObject *arg) { return ListOfWrappedMethods<PTreeNodeList, TTreeNodeList, PTreeNode, &PyOrTreeNode_Type>::P_FromArguments(arg); }
904PyObject *TreeNodeList_FromArguments(PyTypeObject *type, PyObject *arg) { return ListOfWrappedMethods<PTreeNodeList, TTreeNodeList, PTreeNode, &PyOrTreeNode_Type>::_FromArguments(type, arg); }
905PyObject *TreeNodeList_new(PyTypeObject *type, PyObject *arg, PyObject *kwds) BASED_ON(Orange - Orange.classification.tree.NodeList, "(<list of TreeNode>)")  ALLOWS_EMPTY { return ListOfWrappedMethods<PTreeNodeList, TTreeNodeList, PTreeNode, &PyOrTreeNode_Type>::_new(type, arg, kwds); }
906PyObject *TreeNodeList_getitem_sq(TPyOrange *self, Py_ssize_t index) { return ListOfWrappedMethods<PTreeNodeList, TTreeNodeList, PTreeNode, &PyOrTreeNode_Type>::_getitem(self, index); }
907int       TreeNodeList_setitem_sq(TPyOrange *self, Py_ssize_t index, PyObject *item) { return ListOfWrappedMethods<PTreeNodeList, TTreeNodeList, PTreeNode, &PyOrTreeNode_Type>::_setitem(self, index, item); }
908PyObject *TreeNodeList_getslice(TPyOrange *self, Py_ssize_t start, Py_ssize_t stop) { return ListOfWrappedMethods<PTreeNodeList, TTreeNodeList, PTreeNode, &PyOrTreeNode_Type>::_getslice(self, start, stop); }
909int       TreeNodeList_setslice(TPyOrange *self, Py_ssize_t start, Py_ssize_t stop, PyObject *item) { return ListOfWrappedMethods<PTreeNodeList, TTreeNodeList, PTreeNode, &PyOrTreeNode_Type>::_setslice(self, start, stop, item); }
910Py_ssize_t       TreeNodeList_len_sq(TPyOrange *self) { return ListOfWrappedMethods<PTreeNodeList, TTreeNodeList, PTreeNode, &PyOrTreeNode_Type>::_len(self); }
911PyObject *TreeNodeList_richcmp(TPyOrange *self, PyObject *object, int op) { return ListOfWrappedMethods<PTreeNodeList, TTreeNodeList, PTreeNode, &PyOrTreeNode_Type>::_richcmp(self, object, op); }
912PyObject *TreeNodeList_concat(TPyOrange *self, PyObject *obj) { return ListOfWrappedMethods<PTreeNodeList, TTreeNodeList, PTreeNode, &PyOrTreeNode_Type>::_concat(self, obj); }
913PyObject *TreeNodeList_repeat(TPyOrange *self, Py_ssize_t times) { return ListOfWrappedMethods<PTreeNodeList, TTreeNodeList, PTreeNode, &PyOrTreeNode_Type>::_repeat(self, times); }
914PyObject *TreeNodeList_str(TPyOrange *self) { return ListOfWrappedMethods<PTreeNodeList, TTreeNodeList, PTreeNode, &PyOrTreeNode_Type>::_str(self); }
915PyObject *TreeNodeList_repr(TPyOrange *self) { return ListOfWrappedMethods<PTreeNodeList, TTreeNodeList, PTreeNode, &PyOrTreeNode_Type>::_str(self); }
916int       TreeNodeList_contains(TPyOrange *self, PyObject *obj) { return ListOfWrappedMethods<PTreeNodeList, TTreeNodeList, PTreeNode, &PyOrTreeNode_Type>::_contains(self, obj); }
917PyObject *TreeNodeList_append(TPyOrange *self, PyObject *item) PYARGS(METH_O, "(TreeNode) -> None") { return ListOfWrappedMethods<PTreeNodeList, TTreeNodeList, PTreeNode, &PyOrTreeNode_Type>::_append(self, item); }
918PyObject *TreeNodeList_extend(TPyOrange *self, PyObject *obj) PYARGS(METH_O, "(sequence) -> None") { return ListOfWrappedMethods<PTreeNodeList, TTreeNodeList, PTreeNode, &PyOrTreeNode_Type>::_extend(self, obj); }
919PyObject *TreeNodeList_count(TPyOrange *self, PyObject *obj) PYARGS(METH_O, "(TreeNode) -> int") { return ListOfWrappedMethods<PTreeNodeList, TTreeNodeList, PTreeNode, &PyOrTreeNode_Type>::_count(self, obj); }
920PyObject *TreeNodeList_filter(TPyOrange *self, PyObject *args) PYARGS(METH_VARARGS, "([filter-function]) -> TreeNodeList") { return ListOfWrappedMethods<PTreeNodeList, TTreeNodeList, PTreeNode, &PyOrTreeNode_Type>::_filter(self, args); }
921PyObject *TreeNodeList_index(TPyOrange *self, PyObject *obj) PYARGS(METH_O, "(TreeNode) -> int") { return ListOfWrappedMethods<PTreeNodeList, TTreeNodeList, PTreeNode, &PyOrTreeNode_Type>::_index(self, obj); }
922PyObject *TreeNodeList_insert(TPyOrange *self, PyObject *args) PYARGS(METH_VARARGS, "(index, item) -> None") { return ListOfWrappedMethods<PTreeNodeList, TTreeNodeList, PTreeNode, &PyOrTreeNode_Type>::_insert(self, args); }
923PyObject *TreeNodeList_native(TPyOrange *self) PYARGS(METH_NOARGS, "() -> list") { return ListOfWrappedMethods<PTreeNodeList, TTreeNodeList, PTreeNode, &PyOrTreeNode_Type>::_native(self); }
924PyObject *TreeNodeList_pop(TPyOrange *self, PyObject *args) PYARGS(METH_VARARGS, "() -> TreeNode") { return ListOfWrappedMethods<PTreeNodeList, TTreeNodeList, PTreeNode, &PyOrTreeNode_Type>::_pop(self, args); }
925PyObject *TreeNodeList_remove(TPyOrange *self, PyObject *obj) PYARGS(METH_O, "(TreeNode) -> None") { return ListOfWrappedMethods<PTreeNodeList, TTreeNodeList, PTreeNode, &PyOrTreeNode_Type>::_remove(self, obj); }
926PyObject *TreeNodeList_reverse(TPyOrange *self) PYARGS(METH_NOARGS, "() -> None") { return ListOfWrappedMethods<PTreeNodeList, TTreeNodeList, PTreeNode, &PyOrTreeNode_Type>::_reverse(self); }
927PyObject *TreeNodeList_sort(TPyOrange *self, PyObject *args) PYARGS(METH_VARARGS, "([cmp-func]) -> None") { return ListOfWrappedMethods<PTreeNodeList, TTreeNodeList, PTreeNode, &PyOrTreeNode_Type>::_sort(self, args); }
928PyObject *TreeNodeList__reduce__(TPyOrange *self, PyObject *) { return ListOfWrappedMethods<PTreeNodeList, TTreeNodeList, PTreeNode, &PyOrTreeNode_Type>::_reduce(self); }
929
930
931/************* C45 ************/
932
933#include "c4.5.hpp"
934
935C_CALL(C45Learner - Orange.classification.tree._C45Learner, Learner, "([examples] [, weight=, gainRatio=, subset=, batch=, probThresh=, minObjs=, window=, increment=, cf=, trials=]) -/-> Classifier")
936C_NAMED(C45Classifier - Orange.classification.tree._C45Classifier, Classifier, "()")
937
938PyObject *C45Learner_command_line(PyObject *self, PyObject *args) PYARGS(METH_VARARGS, "(line) -> None")
939{ PyTRY
940    char *line;
941    if (!PyArg_ParseTuple(args, "s", &line))
942      PYERROR(PyExc_TypeError, "C45Learner.commandline: string argument expected", NULL);
943
944    SELF_AS(TC45Learner).parseCommandLine(string(line));
945    RETURN_NONE;
946  PyCATCH
947}
948
949C_NAMED(C45TreeNode - Orange.classification.tree.C45Node, Orange, "")
950
951PC45TreeNodeList PC45TreeNodeList_FromArguments(PyObject *arg) { return ListOfWrappedMethods<PC45TreeNodeList, TC45TreeNodeList, PC45TreeNode, &PyOrC45TreeNode_Type>::P_FromArguments(arg); }
952PyObject *C45TreeNodeList_FromArguments(PyTypeObject *type, PyObject *arg) { return ListOfWrappedMethods<PC45TreeNodeList, TC45TreeNodeList, PC45TreeNode, &PyOrC45TreeNode_Type>::_FromArguments(type, arg); }
953PyObject *C45TreeNodeList_new(PyTypeObject *type, PyObject *arg, PyObject *kwds) BASED_ON(Orange - Orange.classification.tree.C45NodeList, "(<list of C45TreeNode>)") ALLOWS_EMPTY { return ListOfWrappedMethods<PC45TreeNodeList, TC45TreeNodeList, PC45TreeNode, &PyOrC45TreeNode_Type>::_new(type, arg, kwds); }
954PyObject *C45TreeNodeList_getitem_sq(TPyOrange *self, Py_ssize_t index) { return ListOfWrappedMethods<PC45TreeNodeList, TC45TreeNodeList, PC45TreeNode, &PyOrC45TreeNode_Type>::_getitem(self, index); }
955int       C45TreeNodeList_setitem_sq(TPyOrange *self, Py_ssize_t index, PyObject *item) { return ListOfWrappedMethods<PC45TreeNodeList, TC45TreeNodeList, PC45TreeNode, &PyOrC45TreeNode_Type>::_setitem(self, index, item); }
956PyObject *C45TreeNodeList_getslice(TPyOrange *self, Py_ssize_t start, Py_ssize_t stop) { return ListOfWrappedMethods<PC45TreeNodeList, TC45TreeNodeList, PC45TreeNode, &PyOrC45TreeNode_Type>::_getslice(self, start, stop); }
957int       C45TreeNodeList_setslice(TPyOrange *self, Py_ssize_t start, Py_ssize_t stop, PyObject *item) { return ListOfWrappedMethods<PC45TreeNodeList, TC45TreeNodeList, PC45TreeNode, &PyOrC45TreeNode_Type>::_setslice(self, start, stop, item); }
958Py_ssize_t       C45TreeNodeList_len_sq(TPyOrange *self) { return ListOfWrappedMethods<PC45TreeNodeList, TC45TreeNodeList, PC45TreeNode, &PyOrC45TreeNode_Type>::_len(self); }
959PyObject *C45TreeNodeList_richcmp(TPyOrange *self, PyObject *object, int op) { return ListOfWrappedMethods<PC45TreeNodeList, TC45TreeNodeList, PC45TreeNode, &PyOrC45TreeNode_Type>::_richcmp(self, object, op); }
960PyObject *C45TreeNodeList_concat(TPyOrange *self, PyObject *obj) { return ListOfWrappedMethods<PC45TreeNodeList, TC45TreeNodeList, PC45TreeNode, &PyOrC45TreeNode_Type>::_concat(self, obj); }
961PyObject *C45TreeNodeList_repeat(TPyOrange *self, Py_ssize_t times) { return ListOfWrappedMethods<PC45TreeNodeList, TC45TreeNodeList, PC45TreeNode, &PyOrC45TreeNode_Type>::_repeat(self, times); }
962PyObject *C45TreeNodeList_str(TPyOrange *self) { return ListOfWrappedMethods<PC45TreeNodeList, TC45TreeNodeList, PC45TreeNode, &PyOrC45TreeNode_Type>::_str(self); }
963PyObject *C45TreeNodeList_repr(TPyOrange *self) { return ListOfWrappedMethods<PC45TreeNodeList, TC45TreeNodeList, PC45TreeNode, &PyOrC45TreeNode_Type>::_str(self); }
964int       C45TreeNodeList_contains(TPyOrange *self, PyObject *obj) { return ListOfWrappedMethods<PC45TreeNodeList, TC45TreeNodeList, PC45TreeNode, &PyOrC45TreeNode_Type>::_contains(self, obj); }
965PyObject *C45TreeNodeList_append(TPyOrange *self, PyObject *item) PYARGS(METH_O, "(C45TreeNode) -> None") { return ListOfWrappedMethods<PC45TreeNodeList, TC45TreeNodeList, PC45TreeNode, &PyOrC45TreeNode_Type>::_append(self, item); }
966PyObject *C45TreeNodeList_extend(TPyOrange *self, PyObject *obj) PYARGS(METH_O, "(sequence) -> None") { return ListOfWrappedMethods<PC45TreeNodeList, TC45TreeNodeList, PC45TreeNode, &PyOrC45TreeNode_Type>::_extend(self, obj); }
967PyObject *C45TreeNodeList_count(TPyOrange *self, PyObject *obj) PYARGS(METH_O, "(C45TreeNode) -> int") { return ListOfWrappedMethods<PC45TreeNodeList, TC45TreeNodeList, PC45TreeNode, &PyOrC45TreeNode_Type>::_count(self, obj); }
968PyObject *C45TreeNodeList_filter(TPyOrange *self, PyObject *args) PYARGS(METH_VARARGS, "([filter-function]) -> C45TreeNodeList") { return ListOfWrappedMethods<PC45TreeNodeList, TC45TreeNodeList, PC45TreeNode, &PyOrC45TreeNode_Type>::_filter(self, args); }
969PyObject *C45TreeNodeList_index(TPyOrange *self, PyObject *obj) PYARGS(METH_O, "(C45TreeNode) -> int") { return ListOfWrappedMethods<PC45TreeNodeList, TC45TreeNodeList, PC45TreeNode, &PyOrC45TreeNode_Type>::_index(self, obj); }
970PyObject *C45TreeNodeList_insert(TPyOrange *self, PyObject *args) PYARGS(METH_VARARGS, "(index, item) -> None") { return ListOfWrappedMethods<PC45TreeNodeList, TC45TreeNodeList, PC45TreeNode, &PyOrC45TreeNode_Type>::_insert(self, args); }
971PyObject *C45TreeNodeList_native(TPyOrange *self) PYARGS(METH_NOARGS, "() -> list") { return ListOfWrappedMethods<PC45TreeNodeList, TC45TreeNodeList, PC45TreeNode, &PyOrC45TreeNode_Type>::_native(self); }
972PyObject *C45TreeNodeList_pop(TPyOrange *self, PyObject *args) PYARGS(METH_VARARGS, "() -> C45TreeNode") { return ListOfWrappedMethods<PC45TreeNodeList, TC45TreeNodeList, PC45TreeNode, &PyOrC45TreeNode_Type>::_pop(self, args); }
973PyObject *C45TreeNodeList_remove(TPyOrange *self, PyObject *obj) PYARGS(METH_O, "(C45TreeNode) -> None") { return ListOfWrappedMethods<PC45TreeNodeList, TC45TreeNodeList, PC45TreeNode, &PyOrC45TreeNode_Type>::_remove(self, obj); }
974PyObject *C45TreeNodeList_reverse(TPyOrange *self) PYARGS(METH_NOARGS, "() -> None") { return ListOfWrappedMethods<PC45TreeNodeList, TC45TreeNodeList, PC45TreeNode, &PyOrC45TreeNode_Type>::_reverse(self); }
975PyObject *C45TreeNodeList_sort(TPyOrange *self, PyObject *args) PYARGS(METH_VARARGS, "([cmp-func]) -> None") { return ListOfWrappedMethods<PC45TreeNodeList, TC45TreeNodeList, PC45TreeNode, &PyOrC45TreeNode_Type>::_sort(self, args); }
976PyObject *C45TreeNodeList__reduce__(TPyOrange *self, PyObject *) { return ListOfWrappedMethods<PC45TreeNodeList, TC45TreeNodeList, PC45TreeNode, &PyOrC45TreeNode_Type>::_reduce(self); }
977
978
979/************* kNN ************/
980
981#include "knn.hpp"
982C_CALL(kNNLearner - Orange.classification.knn.kNNLearner, Learner, "([examples] [k=, weightID=, findNearest=] -/-> Classifier")
983C_NAMED(kNNClassifier - Orange.classification.knn.kNNClassifier, ClassifierFD, "(example[, returnWhat]) -> prediction")
984
985
986/************* PNN ************/
987
988#include "numeric_interface.hpp"
989
990#include "pnn.hpp"
991
992PyObject *P2NN_new(PyTypeObject *type, PyObject *args, PyObject *keywords) BASED_ON(ClassifierFD - Orange.classification.knn.P2NN, "(examples, anchors[, domain]) -> PNN")
993{
994  PyTRY
995    PDomain domain;
996    PExampleGenerator examples;
997    PyObject *pybases;
998    int normalizeExamples = 1;
999    if (PyArg_ParseTuple(args, "O&O|iO&:P2NN", pt_ExampleGenerator, &examples, &pybases, &normalizeExamples, cc_Domain, &domain)) {
1000      if (!domain)
1001        domain = examples->domain;
1002
1003      if (!PyList_Check(pybases))
1004        PYERROR(PyExc_AttributeError, "the anchors should be given as a list", PYNULL);
1005
1006      const Py_ssize_t nAnchors = PyList_Size(pybases);
1007      if (nAnchors != domain->attributes->size())
1008        PYERROR(PyExc_AttributeError, "the number of attributes does not match the number of anchors", PYNULL);
1009
1010      TFloatList *basesX = mlnew TFloatList(nAnchors);
1011      TFloatList *basesY = mlnew TFloatList(nAnchors);
1012      PFloatList wbasesX = basesX, wbasesY = basesY;
1013
1014      TFloatList::iterator xi(basesX->begin());
1015      TFloatList::iterator yi(basesY->begin());
1016      PyObject *foo;
1017
1018      for(Py_ssize_t i = 0; i < nAnchors; i++)
1019        if (!PyArg_ParseTuple(PyList_GetItem(pybases, i), "ff|O", &*xi++, &*yi++, &foo)) {
1020          PyErr_Format(PyExc_TypeError, "anchor #%i is not a tuple of (at least) two elements", i);
1021          return PYNULL;
1022        }
1023
1024      return WrapNewOrange(mlnew TP2NN(domain, examples, wbasesX, wbasesY, -1.0, normalizeExamples != 0), type);
1025    }
1026
1027      PyErr_Clear();
1028      PyObject *matrix;
1029      PyObject *pyoffsets, *pynormalizers, *pyaverages;
1030      if (PyArg_ParseTuple(args, "O&OOOOO|i", cc_Domain, &domain, &matrix, &pybases, &pyoffsets, &pynormalizers, &pyaverages, &normalizeExamples)) {
1031        prepareNumeric();
1032  //      if (!PyArray_Check(matrix))
1033  //        PYERROR(PyExc_AttributeError, "the second argument (projection matrix) must a Numeric.array", PYNULL);
1034
1035        const int nAttrs = domain->attributes->size();
1036
1037        PyArrayObject *array = (PyArrayObject *)(matrix);
1038        if (array->nd != 2)
1039          PYERROR(PyExc_AttributeError, "two-dimensional array expected for matrix of projections", PYNULL);
1040        if (array->dimensions[1] != 3)
1041          PYERROR(PyExc_AttributeError, "the matrix of projections must have three columns", PYNULL);
1042
1043        const char arrayType = getArrayType(array);
1044        if ((arrayType != 'f') && (arrayType != 'd'))
1045          PYERROR(PyExc_AttributeError, "elements of matrix of projections must be doubles or floats", PYNULL);
1046
1047        const int nExamples = array->dimensions[0];
1048
1049        double *projections = new double[3*nExamples];
1050
1051        char *rowPtr = array->data;
1052        double *pi = projections;
1053        const int &strideRow = array->strides[0];
1054        const int &strideCol = array->strides[1];
1055
1056        if (arrayType == 'f') {
1057          for(int row = 0, rowe = nExamples; row < rowe; row++, rowPtr += strideRow) {
1058            *pi++ = double(*(float *)(rowPtr));
1059            *pi++ = double(*(float *)(rowPtr+strideCol));
1060            *pi++ = double(*(float *)(rowPtr+2*strideCol));
1061          }
1062        }
1063        else {
1064          for(int row = 0, rowe = nExamples; row < rowe; row++, rowPtr += strideRow) {
1065            *pi++ = *(double *)(rowPtr);
1066            *pi++ = *(double *)(rowPtr+strideCol);
1067            *pi++ = *(double *)(rowPtr+2*strideCol);
1068          }
1069        }
1070
1071
1072        double *bases = NULL;
1073        PFloatList offsets, normalizers, averages;
1074
1075        if (pybases == Py_None) {
1076          if ((pyoffsets != Py_None) || (pynormalizers != Py_None) || (pyaverages != Py_None))
1077            PYERROR(PyExc_AttributeError, "anchors, offsets, normalizers and averages must be either all given or all None", PYNULL);
1078        }
1079
1080        else {
1081          if (!PyList_Check(pybases) || ((pybases != Py_None) && (PyList_Size(pybases) != nAttrs)))
1082            PYERROR(PyExc_AttributeError, "the third argument must be a list of anchors with length equal the number of attributes", PYNULL);
1083
1084
1085          #define LOADLIST(x) \
1086          x = ListOfUnwrappedMethods<PAttributedFloatList, TAttributedFloatList, float>::P_FromArguments(py##x); \
1087          if (!x) return PYNULL; \
1088          if (x->size() != nAttrs) PYERROR(PyExc_TypeError, "invalid size of "#x" list", PYNULL);
1089
1090          LOADLIST(offsets)
1091          LOADLIST(normalizers)
1092          LOADLIST(averages)
1093          #undef LOADLIST
1094
1095          bases = new double[2*nAttrs];
1096          double *bi = bases;
1097          PyObject *foo;
1098
1099          for(int i = 0; i < nAttrs; i++, bi+=2)
1100            if (!PyArg_ParseTuple(PyList_GetItem(pybases, i), "dd|O", bi, bi+1, &foo)) {
1101              PyErr_Format(PyExc_TypeError, "anchor #%i is not a tuple of (at least) two elements", i);
1102              delete bases;
1103              return PYNULL;
1104            }
1105        }
1106
1107        return WrapNewOrange(mlnew TP2NN(domain, projections, nExamples, bases, offsets, normalizers, averages, TP2NN::InverseSquare, normalizeExamples != 0), type);
1108      }
1109
1110    PyErr_Clear();
1111    PYERROR(PyExc_TypeError, "P2NN.invalid arguments", PYNULL);
1112
1113  PyCATCH;
1114}
1115
1116
1117PyObject *P2NN__reduce__(PyObject *self)
1118{
1119  PyTRY
1120    CAST_TO(TP2NN, p2nn);
1121
1122    if (!p2nn->offsets)
1123      PYERROR(PyExc_SystemError, "cannot pickle an invalid instance of P2NN (no offsets)", NULL);
1124
1125    const int nAttrs = p2nn->offsets->size();
1126    const int nExamples = p2nn->nExamples;
1127
1128    TCharBuffer buf(3 + 2 * sizeof(int) + (4 * nAttrs + 3 * nExamples + 2) * sizeof(double));
1129
1130    buf.writeInt(nAttrs);
1131    buf.writeInt(nExamples);
1132
1133    if (p2nn->bases) {
1134      buf.writeChar(1);
1135      buf.writeBuf(p2nn->bases, 2 * nAttrs * sizeof(double));
1136    }
1137    else
1138      buf.writeChar(0);
1139
1140    if (p2nn->radii) {
1141      buf.writeChar(1);
1142      buf.writeBuf(p2nn->radii, 2 * nAttrs * sizeof(double));
1143    }
1144    else
1145      buf.writeChar(0);
1146
1147    if (p2nn->projections) {
1148      buf.writeChar(1);
1149      buf.writeBuf(p2nn->projections, 3 * nExamples * sizeof(double));
1150    }
1151    else
1152      buf.writeChar(0);
1153
1154    buf.writeDouble(p2nn->minClass);
1155    buf.writeDouble(p2nn->maxClass);
1156
1157    return Py_BuildValue("O(Os#)N", getExportedFunction("__pickleLoaderP2NN"),
1158                                    self->ob_type,
1159                                    buf.buf, buf.length(),
1160                                    packOrangeDictionary(self));
1161  PyCATCH
1162}
1163
1164
1165PyObject *__pickleLoaderP2NN(PyObject *, PyObject *args) PYARGS(METH_VARARGS, "(type, packed_data)")
1166{
1167  PyTRY
1168    PyTypeObject *type;
1169    char *pbuf;
1170    int bufSize;
1171    if (!PyArg_ParseTuple(args, "Os#:__pickleLoaderP2NN", &type, &pbuf, &bufSize))
1172      return NULL;
1173
1174    TCharBuffer buf(pbuf);
1175
1176    const int nAttrs = buf.readInt();
1177    const int nExamples = buf.readInt();
1178
1179    TP2NN *p2nn = new TP2NN(nAttrs, nExamples);
1180    if (buf.readChar()) {
1181      buf.readBuf(p2nn->bases, 2 * nAttrs * sizeof(double));
1182    }
1183    else {
1184      delete p2nn->bases;
1185      p2nn->bases = NULL;
1186    }
1187
1188    if (buf.readChar()) {
1189      buf.readBuf(p2nn->radii, 2 * nAttrs * sizeof(double));
1190    }
1191    else {
1192      delete p2nn->radii;
1193      p2nn->radii = NULL;
1194    }
1195
1196    if (buf.readChar()) {
1197      buf.readBuf(p2nn->projections, 3 * nExamples * sizeof(double));
1198    }
1199    else {
1200      delete p2nn->projections;
1201      p2nn->projections = NULL;
1202    }
1203
1204    p2nn->minClass = buf.readDouble();
1205    p2nn->maxClass = buf.readDouble();
1206
1207    return WrapNewOrange(p2nn, type);
1208  PyCATCH
1209}
1210
1211
1212C_CALL(kNNLearner, Learner, "([examples] [, weight=, k=] -/-> Classifier")
1213C_NAMED(kNNClassifier, ClassifierFD, "([k=, weightID=, findNearest=])")
1214
1215
1216/************* Logistic Regression ************/
1217
1218#include "logistic.hpp"
1219C_CALL(LogRegLearner, Learner, "([examples[, weight=]]) -/-> Classifier")
1220C_NAMED(LogRegClassifier - Orange.classification.logreg.LogRegClassifier, ClassifierFD, "([probabilities=])")
1221
1222
1223PyObject *LogRegFitter_new(PyTypeObject *type, PyObject *args, PyObject *keywords)  BASED_ON(Orange - Orange.classification.logreg.LogRegFitter, "<abstract>")
1224{ if (type == (PyTypeObject *)&PyOrLogRegFitter_Type)
1225    return setCallbackFunction(WrapNewOrange(mlnew TLogRegFitter_Python(), type), args);
1226  else
1227    return WrapNewOrange(mlnew TLogRegFitter_Python(), type);
1228}
1229
1230PyObject *LogRegFitter__reduce__(PyObject *self)
1231{
1232  return callbackReduce(self, PyOrLogRegFitter_Type);
1233}
1234
1235
1236C_CALL(LogRegFitter_Cholesky - Orange.classification.logreg.LogRegFitter_Cholesky, LogRegFitter, "([example[, weightID]]) -/-> (status, beta, beta_se, likelihood) | (status, attribute)")
1237
1238PyObject *LogRegLearner_fitModel(PyObject *self, PyObject *args) PYARGS(METH_VARARGS, "(examples[, weight])")
1239{
1240  PyTRY
1241      PExampleGenerator egen;
1242      int weight = 0;
1243      if (!PyArg_ParseTuple(args, "O&|O&:LogRegLearner", pt_ExampleGenerator, &egen, pt_weightByGen(egen), &weight))
1244        return PYNULL;
1245
1246      CAST_TO(TLogRegLearner, loglearn)
1247
1248      int error;
1249      PVariable variable;
1250      PClassifier classifier;
1251
1252      classifier = loglearn->fitModel(egen, weight, error, variable);
1253      if (error <= TLogRegFitter::Divergence)
1254          return Py_BuildValue("N", WrapOrange(classifier));
1255      else
1256          return Py_BuildValue("N", WrapOrange(variable));
1257  PyCATCH
1258}
1259
1260
1261PyObject *PyLogRegFitter_ErrorCode_FromLong(long);
1262
1263PyObject *LogRegFitter_call(PyObject *self, PyObject *args, PyObject *keywords) PYDOC("(examples[, weightID]) -/-> (status, beta, beta_se, likelihood) | (status, attribute)")
1264{
1265  PyTRY
1266    NO_KEYWORDS
1267
1268    int weight;
1269    PExampleGenerator egen = exampleGenFromArgs(args, weight);
1270    if (!egen)
1271      return PYNULL;
1272
1273    CAST_TO(TLogRegFitter, fitter)
1274
1275    PAttributedFloatList beta, beta_se;
1276    float likelihood;
1277    int error;
1278    PVariable attribute;
1279
1280    beta = (*fitter)(egen, weight, beta_se, likelihood, error, attribute);
1281
1282    if (error <= TLogRegFitter::Divergence)
1283      return Py_BuildValue("NNNf", PyLogRegFitter_ErrorCode_FromLong(error), WrapOrange(beta), WrapOrange(beta_se), likelihood);
1284    else
1285      return Py_BuildValue("NN", PyLogRegFitter_ErrorCode_FromLong(error), WrapOrange(attribute));
1286
1287  PyCATCH
1288}
1289
1290/************ Linear **********/
1291#include "liblinear_interface.hpp"
1292C_CALL(LinearLearner, Learner, "([examples] -/-> Classifier)")
1293C_NAMED(LinearClassifier - Orange.classification.svm.LinearClassifier, ClassifierFD, " ")
1294
1295
1296
1297PyObject *LinearClassifier__reduce__(PyObject *self){
1298  PyTRY
1299    CAST_TO(TLinearClassifier, classifier);
1300    string buff;
1301    if (linear_save_model_alt(buff, classifier->getModel()) != 0)
1302        raiseError("Could not save the model");
1303    return Py_BuildValue("O(OOOs)N", getExportedFunction("__pickleLoaderLinearClassifier"),
1304                                    self->ob_type,
1305                                    WrapOrange(classifier->classVar),
1306                                    WrapOrange(classifier->examples),
1307                                    buff.c_str(),
1308                                    packOrangeDictionary(self));
1309  PyCATCH
1310}
1311
1312PyObject *__pickleLoaderLinearClassifier(PyObject *, PyObject *args) PYARGS(METH_VARARGS, "(type, packed_data)")
1313{
1314  PyTRY
1315    PyTypeObject* type;
1316    PVariable var;
1317    PExampleTable examples;
1318    char *pBuff;
1319    if (!PyArg_ParseTuple(args, "OO&O&s", &type, cc_Variable, &var, cc_ExampleTable, &examples, &pBuff))
1320        return NULL;
1321    string buff(pBuff);
1322    model *model = linear_load_model_alt(buff);
1323    if (!model)
1324        raiseError("Could not load the model");
1325    return WrapNewOrange(mlnew TLinearClassifier(var, examples, model), (PyTypeObject*)&PyOrLinearClassifier_Type);
1326  PyCATCH
1327}
1328
1329/************* LIBSVM ************/
1330
1331#include "libsvm_interface.hpp"
1332C_CALL(SVMLearner - Orange.classification.svm._SVMLearner, Learner, "([examples] -/-> Classifier)")
1333C_CALL(SVMLearnerSparse - Orange.classification.svm._SVMLearnerSparse, SVMLearner, "([examples] -/-> Classifier)")
1334C_NAMED(SVMClassifier - Orange.classification.svm.SVMClassifier, ClassifierFD," ")
1335C_NAMED(SVMClassifierSparse - Orange.classification.svm.SVMClassifierSparse, SVMClassifier," ")
1336
1337PyObject *SVMLearner_setWeights(PyObject *self, PyObject* args, PyObject *keywords) PYARGS(METH_VARARGS, "['list of tuple pairs'] -> None")
1338{
1339    PyTRY
1340
1341    PyObject *pyWeights;
1342    if (!PyArg_ParseTuple(args, "O:SVMLearner.setWeights", &pyWeights)) {
1343        //PyErr_Format(PyExc_TypeError, "SVMLearner.setWeights: an instance of Python List expected got '%s'", pyWeights->ob_type->tp_name);
1344        PYERROR(PyExc_TypeError, "SVMLearner.setWeights: Python List of attribute weights expected", PYNULL);
1345        return PYNULL;
1346    }
1347
1348    CAST_TO(TSVMLearner, learner);
1349
1350    Py_ssize_t size = PyList_Size(pyWeights);
1351    //cout << "n weights: " << size << endl;
1352    Py_ssize_t i;
1353
1354    free(learner->weight_label);
1355    free(learner->weight);
1356
1357    learner->nr_weight = size;
1358    learner->weight_label = NULL;
1359    learner->weight = NULL;
1360
1361    if (size > 0) {
1362        learner->weight_label = (int *)malloc((size)*sizeof(int));
1363        learner->weight = (double *)malloc((size)*sizeof(double));
1364    }
1365
1366    for (i = 0; i < size; i++) {
1367        int l;
1368        double w;
1369        PyArg_ParseTuple(PyList_GetItem(pyWeights, i), "id:SVMLearner.setWeights", &l, &w);
1370        learner->weight[i] = w;
1371        learner->weight_label[i] = l;
1372        //cout << "class: " << l << ", w: " << w << endl;
1373    }
1374
1375    RETURN_NONE;
1376    PyCATCH
1377}
1378
1379PyObject *KernelFunc_new(PyTypeObject *type, PyObject *args, PyObject *keywords)  BASED_ON(Orange - Orange.classification.svm.kernels.KernelFunc, "<abstract>")
1380{ if (type == (PyTypeObject *)&PyOrKernelFunc_Type)
1381    return setCallbackFunction(WrapNewOrange(mlnew TKernelFunc_Python(), type), args);
1382  else
1383    return WrapNewOrange(mlnew TKernelFunc_Python(), type);
1384}
1385
1386
1387PyObject *KernelFunc__reduce__(PyObject *self)
1388{
1389  return callbackReduce(self, PyOrKernelFunc_Type);
1390}
1391
1392
1393PyObject *KernelFunc_call(PyObject *self, PyObject *args, PyObject *keywords) PYDOC("(Example, Example) -> float")
1394{
1395  PyTRY
1396    NO_KEYWORDS
1397
1398    if (PyOrange_OrangeBaseClass(self->ob_type) == &PyOrKernelFunc_Type) {
1399      PyErr_Format(PyExc_SystemError, "KernelFunc.call called for '%s': this may lead to stack overflow", self->ob_type->tp_name);
1400      return PYNULL;
1401    }
1402
1403    float f;
1404    PExample e1,e2;
1405    if (!PyArg_ParseTuple(args, "O&O&", cc_Example, &e1, cc_Example, &e2))
1406        return NULL;
1407    f=SELF_AS(TKernelFunc)(e1.getReference(),e2.getReference());
1408    return Py_BuildValue("f", f);
1409  PyCATCH
1410}
1411
1412PyObject *SVMClassifier__reduce__(PyObject* self)
1413{
1414  PyTRY
1415    CAST_TO(TSVMClassifier, svm);
1416    string buf;
1417    if (svm_save_model_alt(buf, svm->getModel())){
1418        raiseError("Error saving SVM model");
1419    }
1420    if(svm->kernelFunc)
1421        return Py_BuildValue("O(OOOsO)N", self->ob_type,
1422                                    WrapOrange(svm->classVar),
1423                                    WrapOrange(svm->examples),
1424                                    WrapOrange(svm->supportVectors),
1425                                    buf.c_str(),
1426                                    WrapOrange(svm->kernelFunc),
1427                                    packOrangeDictionary(self));
1428    else
1429        return Py_BuildValue("O(OOOs)N", self->ob_type,
1430                                    WrapOrange(svm->classVar),
1431                                    WrapOrange(svm->examples),
1432                                    WrapOrange(svm->supportVectors),
1433                                    buf.c_str(),
1434                                    packOrangeDictionary(self));
1435  PyCATCH
1436}
1437
1438
1439PyObject *SVMClassifierSparse__reduce__(PyObject* self)
1440{
1441  PyTRY
1442    CAST_TO(TSVMClassifierSparse, svm);
1443    string buf;
1444    if (svm_save_model_alt(buf, svm->getModel())){
1445        raiseError("Error saving SVM model.");
1446    }
1447    if(svm->kernelFunc)
1448        return Py_BuildValue("O(OOOsbO)N", self->ob_type,
1449                                    WrapOrange(svm->classVar),
1450                                    WrapOrange(svm->examples),
1451                                    WrapOrange(svm->supportVectors),
1452                                    buf.c_str(),
1453                                    (char)(svm->useNonMeta? 1: 0),
1454                                    WrapOrange(svm->kernelFunc),
1455                                    packOrangeDictionary(self));
1456    else
1457        return Py_BuildValue("O(OOOsb)N", self->ob_type,
1458                                    WrapOrange(svm->classVar),
1459                                    WrapOrange(svm->examples),
1460                                    WrapOrange(svm->supportVectors),
1461                                    buf.c_str(),
1462                                    (char)(svm->useNonMeta? 1: 0),
1463                                    packOrangeDictionary(self));
1464  PyCATCH
1465}
1466
1467
1468PyObject *SVMClassifier_getDecisionValues(PyObject *self, PyObject* args, PyObject *keywords) PYARGS(METH_VARARGS, "(Example) -> list of floats")
1469{PyTRY
1470    PExample example;
1471    if (!PyArg_ParseTuple(args, "O&", cc_Example, &example))
1472        return NULL;
1473    PFloatList f=SELF_AS(TSVMClassifier).getDecisionValues(example.getReference());
1474    return WrapOrange(f);
1475PyCATCH
1476}
1477
1478PyObject *SVMClassifier_getModel(PyObject *self, PyObject* args, PyObject *keywords) PYARGS(METH_VARARGS, "() -> string")
1479{PyTRY
1480    string buf;
1481    svm_model* model = SELF_AS(TSVMClassifier).getModel();
1482    if (!model)
1483        raiseError("No model.");
1484    svm_save_model_alt(buf, model);
1485    return Py_BuildValue("s", buf.c_str());
1486PyCATCH
1487}
1488
1489
1490PyObject * SVMClassifier_new(PyTypeObject* type, PyObject* args, PyObject* kwargs) BASED_ON(ClassifierFD, "(Variable, Examples, Examples, string, [kernelFunc]) -> SVMClassifier")
1491{PyTRY
1492    PVariable classVar;
1493    PExampleTable examples;
1494    PExampleTable supportVectors;
1495    char*  model_string;
1496    PKernelFunc kernel;
1497    if (PyArg_ParseTuple(args, ""))
1498        return WrapNewOrange(mlnew TSVMClassifier(), type);
1499    PyErr_Clear();
1500   
1501    if (!PyArg_ParseTuple(args, "O&O&O&s|O&:__new__", cc_Variable, &classVar, cc_ExampleTable, &examples, cc_ExampleTable, &supportVectors, &model_string, cc_KernelFunc, &kernel))
1502        return NULL;
1503
1504    string buffer(model_string);
1505    svm_model* model = svm_load_model_alt(buffer);
1506    if (!model)
1507        raiseError("Error building LibSVM Model");
1508//  model->param.learner = NULL;
1509    PSVMClassifier svm = mlnew TSVMClassifier(classVar, examples, model, NULL, kernel);
1510//  svm->kernelFunc = kernel;
1511    svm->supportVectors = supportVectors;
1512    return WrapOrange(svm);
1513PyCATCH
1514}
1515
1516PyObject * SVMClassifierSparse_new(PyTypeObject* type, PyObject* args, PyObject* kwargs) BASED_ON(SVMClassifier, "(Variable, Examples, Examples, string, [useNonMeta, kernelFunc]) -> SVMClassifierSparse")
1517{PyTRY
1518    PVariable classVar;
1519    PExampleTable examples;
1520    PExampleTable supportVectors;
1521    char*  model_string;
1522    char useNonMeta;
1523    PKernelFunc kernel;
1524    if (PyArg_ParseTuple(args, ""))
1525        return WrapNewOrange(mlnew TSVMClassifierSparse(), type);
1526    PyErr_Clear();
1527   
1528    if (!PyArg_ParseTuple(args, "O&O&O&s|bO&:__new__", cc_Variable, &classVar, cc_ExampleTable, &examples, cc_ExampleTable, &supportVectors, &model_string, &useNonMeta, cc_KernelFunc, &kernel))
1529        return NULL;
1530   
1531    string buffer(model_string);
1532    svm_model* model = svm_load_model_alt(buffer);
1533    if (!model)
1534        raiseError("Error building LibSVM Model");
1535//  model->param.learner = NULL;
1536    PSVMClassifier svm = mlnew TSVMClassifierSparse(classVar, examples, model, NULL, useNonMeta != 0, kernel);
1537//  svm->kernelFunc = kernel;
1538    svm->supportVectors = supportVectors;
1539    return WrapOrange(svm);
1540    PyCATCH
1541}
1542
1543
1544/************ EARTH (MARS) ******/
1545#include "earth.hpp"
1546
1547C_CALL(EarthLearner, Learner, "([examples], [weight=] -/-> Classifier)")
1548C_NAMED(EarthClassifier, ClassifierFD, " ")
1549
1550PyObject *EarthClassifier_formatEarth(PyObject *self, PyObject *args) PYARGS(METH_VARARGS, "() -> None")
1551{
1552    PyTRY
1553    CAST_TO(TEarthClassifier, classifier);
1554    classifier->format_earth();
1555    RETURN_NONE;
1556    PyCATCH
1557}
1558
1559PyObject *EarthClassifier__reduce__(PyObject *self) PYARGS(METH_VARARGS, "")
1560{
1561    PyTRY
1562    CAST_TO(TEarthClassifier, classifier);
1563    TCharBuffer buffer(1024);
1564    classifier->save_model(buffer);
1565    return Py_BuildValue("O(s#)N", getExportedFunction("__pickleLoaderEarthClassifier"),
1566                                    buffer.buf, buffer.length(),
1567                                    packOrangeDictionary(self));
1568    PyCATCH
1569}
1570
1571PyObject *__pickleLoaderEarthClassifier(PyObject *self, PyObject *args) PYARGS(METH_VARARGS, "(buffer)")
1572{
1573    PyTRY
1574    char * cbuf = NULL;
1575    int buffer_size = 0;
1576    if (!PyArg_ParseTuple(args, "s#:__pickleLoaderEarthClassifier", &cbuf, &buffer_size))
1577        return NULL;
1578    TCharBuffer buffer(cbuf);
1579    PEarthClassifier classifier = mlnew TEarthClassifier();
1580    classifier->load_model(buffer);
1581    return WrapOrange(classifier);
1582    PyCATCH
1583}
1584
1585
1586   
1587/************* BAYES ************/
1588
1589#include "bayes.hpp"
1590C_CALL(BayesLearner - Orange.classification.bayes._BayesLearner, Learner, "([examples], [weight=, estimate=] -/-> Classifier")
1591C_NAMED(BayesClassifier - Orange.classification.bayes._BayesClassifier, ClassifierFD, "([probabilities=])")
1592
1593PyObject *BayesClassifier_p(PyObject *self, PyObject *args) PYARGS(METH_VARARGS, "(class, example) -> float")
1594{ PyTRY
1595    CAST_TO(TBayesClassifier, me);
1596
1597    PyObject *pyvalue;
1598    TValue value;
1599    TExample *ex;
1600    if (   !PyArg_ParseTuple(args, "OO&:BayesClassifier.p", &pyvalue, ptr_Example, &ex)
1601        || !convertFromPython(pyvalue, value, me->domain->classVar))
1602      return PYNULL;
1603
1604    return PyFloat_FromDouble((double)SELF_AS(TBayesClassifier).p(value, *ex));
1605
1606  PyCATCH
1607}
1608
1609
1610
1611/************* RULES ************/
1612
1613#include "rulelearner.hpp"
1614
1615C_NAMED(Rule - Orange.classification.rules.Rule, Orange, "()")
1616
1617C_NAMED(RuleValidator_LRS - Orange.classification.rules.Validator_LRS, RuleValidator, "([alpha=0.05,min_coverage=0,max_rule_complexity=0,min_quality=numeric_limits<float>::min()])")
1618
1619C_NAMED(RuleEvaluator_Entropy - Orange.classification.rules.Evaluator_Entropy, RuleEvaluator, "()")
1620C_NAMED(RuleEvaluator_Laplace - Orange.classification.rules.Evaluator_Laplace, RuleEvaluator, "()")
1621C_NAMED(RuleEvaluator_LRS - Orange.classification.rules.Evaluator_LRS, RuleEvaluator, "()")
1622C_NAMED(RuleEvaluator_mEVC - Orange.classification.rules.Evaluator_mEVC, RuleEvaluator, "(ruleAlpha=1.0,attributeAlpha=1.0)")
1623
1624C_NAMED(EVDist, Orange, "()")
1625C_NAMED(EVDistGetter_Standard, EVDistGetter, "()")
1626
1627C_NAMED(RuleBeamFinder - Orange.classification.rules.BeamFinder, RuleFinder, "([validator=, evaluator=, initializer=, refiner=, candidateSelector=, ruleFilter=])")
1628
1629C_NAMED(RuleBeamInitializer_Default - Orange.classification.rules.BeamInitializer_Default, RuleBeamInitializer, "()")
1630
1631C_NAMED(RuleBeamRefiner_Selector - Orange.classification.rules.BeamRefiner_Selector, RuleBeamRefiner, "([discretization=])")
1632
1633C_NAMED(RuleBeamCandidateSelector_TakeAll - Orange.classification.rules.BeamCandidateSelector_TakeAll, RuleBeamCandidateSelector, "()")
1634
1635C_NAMED(RuleBeamFilter_Width - Orange.classification.rules.BeamFilter_Width, RuleBeamFilter, "([width=5])")
1636
1637C_NAMED(RuleDataStoppingCriteria_NoPositives - Orange.classification.rules.DataStoppingCriteria_NoPositives, RuleDataStoppingCriteria, "()")
1638
1639C_NAMED(RuleCovererAndRemover_Default - Orange.classification.rules.CovererAndRemover_Default, RuleCovererAndRemover, "()")
1640
1641C_NAMED(RuleStoppingCriteria_NegativeDistribution - Orange.classification.rules.StoppingCriteria_NegativeDistribution, RuleStoppingCriteria, "()")
1642C_CALL(RuleLearner - Orange.classification.rules.RuleLearner, Learner, "([examples[, weightID]]) -/-> Classifier")
1643
1644ABSTRACT(RuleClassifier - Orange.classification.rules.RuleClassifier, Classifier)
1645C_NAMED(RuleClassifier_firstRule - Orange.classification.rules.RuleClassifier_firstRule, RuleClassifier, "([rules,examples[,weightID]])")
1646C_NAMED(RuleClassifier_logit - Orange.classification.rules.RuleClassifier_logit, RuleClassifier, "([rules,minSig,minBeta,examples[,weightID]])")
1647
1648PyObject *Rule_call(PyObject *self, PyObject *args, PyObject *keywords)
1649{
1650  PyTRY
1651    NO_KEYWORDS
1652
1653    if (PyTuple_Size(args)==1) {
1654      PyObject *pyex = PyTuple_GET_ITEM(args, 0);
1655      if (PyOrExample_Check(pyex))
1656        return PyInt_FromLong(PyOrange_AsRule(self)->call(PyExample_AS_ExampleReference(pyex)) ? 1 : 0);
1657    }
1658
1659    PExampleGenerator egen;
1660    int references = 1;
1661    int negate = 0;
1662    if (!PyArg_ParseTuple(args, "O&|ii:Rule.__call__", &pt_ExampleGenerator, &egen, &references, &negate))
1663      return PYNULL;
1664
1665    CAST_TO(TRule, rule)
1666    PExampleTable res = (*rule)(egen,(references?true:false),(negate?true:false));
1667    return WrapOrange(res);
1668  PyCATCH
1669}
1670
1671PyObject *Rule_filterAndStore(PyObject *self, PyObject *args) PYARGS(METH_VARARGS, "(examples, weightID, targetClass)")
1672{
1673  PyTRY
1674    PExampleGenerator gen;
1675    int weightID = 0;
1676    int targetClass = -1;
1677
1678    if (!PyArg_ParseTuple(args, "O&O&i:RuleEvaluator.call",  pt_ExampleGenerator, &gen, pt_weightByGen(gen), &weightID, &targetClass))
1679      return PYNULL;
1680
1681    CAST_TO(TRule, rule);
1682    rule->filterAndStore(gen,weightID,targetClass);
1683    RETURN_NONE;
1684 PyCATCH
1685}
1686
1687PyObject *RuleEvaluator_new(PyTypeObject *type, PyObject *args, PyObject *keywords)  BASED_ON(Orange - Orange.classification.rules.Evaluator, "<abstract>")
1688{ if (type == (PyTypeObject *)&PyOrRuleEvaluator_Type)
1689    return setCallbackFunction(WrapNewOrange(mlnew TRuleEvaluator_Python(), type), args);
1690  else
1691    return WrapNewOrange(mlnew TRuleEvaluator_Python(), type);
1692}
1693
1694PyObject *RuleEvaluator__reduce__(PyObject *self)
1695{
1696  return callbackReduce(self, PyOrRuleEvaluator_Type);
1697}
1698
1699
1700PyObject *RuleEvaluator_call(PyObject *self, PyObject *args, PyObject *keywords) PYDOC("(rule, table, weightID, targetClass, apriori) -/-> (quality)")
1701{
1702  PyTRY
1703    NO_KEYWORDS
1704
1705    PRule rule;
1706    PExampleGenerator gen;
1707    int weightID = 0;
1708    int targetClass = -1;
1709    PDistribution apriori;
1710
1711    if (!PyArg_ParseTuple(args, "O&O&O&iO&:RuleEvaluator.call", cc_Rule, &rule, pt_ExampleGenerator, &gen, pt_weightByGen(gen), &weightID, &targetClass, cc_Distribution, &apriori))
1712      return PYNULL;
1713    CAST_TO(TRuleEvaluator, evaluator)
1714    float quality;
1715
1716    quality = (*evaluator)(rule, gen, weightID, targetClass, apriori);
1717    return PyFloat_FromDouble(quality);
1718  PyCATCH
1719}
1720
1721PyObject *EVDistGetter_new(PyTypeObject *type, PyObject *args, PyObject *keywords)  BASED_ON(Orange, "<abstract>")
1722{ if (type == (PyTypeObject *)&PyOrEVDistGetter_Type)
1723    return setCallbackFunction(WrapNewOrange(mlnew TEVDistGetter_Python(), type), args);
1724  else
1725    return WrapNewOrange(mlnew TEVDistGetter_Python(), type);
1726}
1727
1728PyObject *EVDistGetter__reduce__(PyObject *self)
1729{
1730  return callbackReduce(self, PyOrEVDistGetter_Type);
1731}
1732
1733
1734PyObject *EVDistGetter_call(PyObject *self, PyObject *args, PyObject *keywords) PYDOC("(rule, length) -/-> (EVdist)")
1735{
1736  PyTRY
1737    NO_KEYWORDS
1738
1739    PRule rule;
1740    int parentLength, rLength;
1741
1742    if (!PyArg_ParseTuple(args, "O&ii:EVDistGetter.call", cc_Rule, &rule, &parentLength, &rLength))
1743      return PYNULL;
1744    CAST_TO(TEVDistGetter, getter)
1745    PEVDist dist = (*getter)(rule, parentLength, rLength);
1746
1747    return WrapOrange(dist);
1748  PyCATCH
1749}
1750
1751PyObject *RuleValidator_new(PyTypeObject *type, PyObject *args, PyObject *keywords)  BASED_ON(Orange - Orange.classification.rules.Validator, "<abstract>")
1752{ if (type == (PyTypeObject *)&PyOrRuleValidator_Type)
1753    return setCallbackFunction(WrapNewOrange(mlnew TRuleValidator_Python(), type), args);
1754  else
1755    return WrapNewOrange(mlnew TRuleValidator_Python(), type);
1756}
1757
1758PyObject *RuleValidator__reduce__(PyObject *self)
1759{
1760  return callbackReduce(self, PyOrRuleValidator_Type);
1761}
1762
1763
1764PyObject *RuleValidator_call(PyObject *self, PyObject *args, PyObject *keywords) PYDOC("(rule, table, weightID, targetClass, apriori) -/-> (quality)")
1765{
1766
1767  PyTRY
1768    NO_KEYWORDS
1769
1770    PRule rule;
1771    PExampleGenerator gen;
1772    int weightID = 0;
1773    int targetClass = -1;
1774    PDistribution apriori;
1775
1776    if (!PyArg_ParseTuple(args, "O&O&O&iO&:RuleValidator.call", cc_Rule, &rule, pt_ExampleGenerator, &gen, pt_weightByGen(gen), &weightID, &targetClass, cc_Distribution, &apriori))
1777      return PYNULL;
1778    CAST_TO(TRuleValidator, validator)
1779
1780    bool valid;
1781    valid = (*validator)(rule, gen, weightID, targetClass, apriori);
1782    return PyInt_FromLong(valid?1:0);
1783  PyCATCH
1784}
1785
1786PyObject *RuleCovererAndRemover_new(PyTypeObject *type, PyObject *args, PyObject *keywords)  BASED_ON(Orange - Orange.classification.rules.CovererAndRemover, "<abstract>")
1787{ if (type == (PyTypeObject *)&PyOrRuleCovererAndRemover_Type)
1788    return setCallbackFunction(WrapNewOrange(mlnew TRuleCovererAndRemover_Python(), type), args);
1789  else
1790    return WrapNewOrange(mlnew TRuleCovererAndRemover_Python(), type);
1791}
1792
1793PyObject *RuleCovererAndRemover__reduce__(PyObject *self)
1794{
1795  return callbackReduce(self, PyOrRuleCovererAndRemover_Type);
1796}
1797
1798
1799PyObject *RuleCovererAndRemover_call(PyObject *self, PyObject *args, PyObject *keywords) PYDOC("(rule, table, weightID, targetClass) -/-> (table,newWeight)")
1800{
1801  PyTRY
1802    NO_KEYWORDS
1803
1804    PRule rule;
1805    PExampleGenerator gen;
1806    int weightID = 0;
1807    int newWeightID = 0;
1808    int targetClass = -1;
1809
1810    if (!PyArg_ParseTuple(args, "O&O&O&i:RuleCovererAndRemover.call", cc_Rule, &rule, pt_ExampleGenerator, &gen, pt_weightByGen(gen), &weightID,&targetClass))
1811      return PYNULL;
1812    CAST_TO(TRuleCovererAndRemover, covererAndRemover)
1813
1814    PExampleTable res = (*covererAndRemover)(rule, gen, weightID, newWeightID, targetClass);
1815    return Py_BuildValue("Ni", WrapOrange(res),newWeightID);
1816  PyCATCH
1817}
1818
1819PyObject *RuleStoppingCriteria_new(PyTypeObject *type, PyObject *args, PyObject *keywords)  BASED_ON(Orange - Orange.classification.rules.StoppingCriteria, "<abstract>")
1820{ if (type == (PyTypeObject *)&PyOrRuleStoppingCriteria_Type)
1821    return setCallbackFunction(WrapNewOrange(mlnew TRuleStoppingCriteria_Python(), type), args);
1822  else
1823    return WrapNewOrange(mlnew TRuleStoppingCriteria_Python(), type);
1824}
1825
1826PyObject *RuleStoppingCriteria__reduce__(PyObject *self)
1827{
1828  return callbackReduce(self, PyOrRuleStoppingCriteria_Type);
1829}
1830
1831
1832PyObject *RuleStoppingCriteria_call(PyObject *self, PyObject *args, PyObject *keywords) PYDOC("(rulelist, rule, table, weightID) -/-> (table)")
1833{
1834  PyTRY
1835    NO_KEYWORDS
1836
1837    PRuleList ruleList;
1838    PRule rule;
1839    PExampleGenerator gen;
1840    int weightID = 0;
1841
1842    if (!PyArg_ParseTuple(args, "O&O&O&O&:RuleStoppingCriteria.call", cc_RuleList, &ruleList, cc_Rule, &rule, pt_ExampleGenerator, &gen, pt_weightByGen(gen), &weightID))
1843      return PYNULL;
1844    CAST_TO(TRuleStoppingCriteria, ruleStopping)
1845
1846    bool stop = (*ruleStopping)(ruleList, rule, gen, weightID);
1847    return PyInt_FromLong(stop?1:0);
1848  PyCATCH
1849}
1850
1851PyObject *RuleDataStoppingCriteria_new(PyTypeObject *type, PyObject *args, PyObject *keywords)  BASED_ON(Orange - Orange.classification.rules.DataStoppingCriteria, "<abstract>")
1852{ if (type == (PyTypeObject *)&PyOrRuleDataStoppingCriteria_Type)
1853    return setCallbackFunction(WrapNewOrange(mlnew TRuleDataStoppingCriteria_Python(), type), args);
1854  else
1855    return WrapNewOrange(mlnew TRuleDataStoppingCriteria_Python(), type);
1856}
1857
1858PyObject *RuleDataStoppingCriteria__reduce__(PyObject *self)
1859{
1860  return callbackReduce(self, PyOrRuleDataStoppingCriteria_Type);
1861}
1862
1863
1864PyObject *RuleDataStoppingCriteria_call(PyObject *self, PyObject *args, PyObject *keywords) PYDOC("(table, weightID, targetClass) -/-> (table)")
1865{
1866  PyTRY
1867    NO_KEYWORDS
1868
1869    PExampleGenerator gen;
1870    int weightID = 0;
1871    int targetClass = -1;
1872
1873    if (!PyArg_ParseTuple(args, "O&O&i:RuleDataStoppingCriteria.call", pt_ExampleGenerator, &gen, pt_weightByGen(gen), &weightID, &targetClass))
1874      return PYNULL;
1875    CAST_TO(TRuleDataStoppingCriteria, dataStopping)
1876
1877    bool stop = (*dataStopping)(gen, weightID, targetClass);
1878    return PyInt_FromLong(stop?1:0);
1879  PyCATCH
1880}
1881
1882PyObject *RuleFinder_new(PyTypeObject *type, PyObject *args, PyObject *keywords)  BASED_ON(Orange - Orange.classification.rules.Finder, "<abstract>")
1883{ if (type == (PyTypeObject *)&PyOrRuleFinder_Type)
1884    return setCallbackFunction(WrapNewOrange(mlnew TRuleFinder_Python(), type), args);
1885  else
1886    return WrapNewOrange(mlnew TRuleFinder_Python(), type);
1887}
1888
1889PyObject *RuleFinder__reduce__(PyObject *self)
1890{
1891  return callbackReduce(self, PyOrRuleFinder_Type);
1892}
1893
1894
1895PyObject *RuleFinder_call(PyObject *self, PyObject *args, PyObject *keywords) PYDOC("(table, weightID, targetClass, baseRules) -/-> (rule)")
1896{
1897  PyTRY
1898    NO_KEYWORDS
1899
1900    PExampleGenerator gen;
1901    int weightID = 0;
1902    int targetClass = -1;
1903    PRuleList baseRules;
1904
1905    if (!PyArg_ParseTuple(args, "O&O&iO&:RuleFinder.call", pt_ExampleGenerator, &gen, pt_weightByGen(gen), &weightID, &targetClass, ccn_RuleList, &baseRules))
1906      return PYNULL;
1907    CAST_TO(TRuleFinder, finder)
1908
1909    PRule res = (*finder)(gen, weightID, targetClass, baseRules);
1910    return WrapOrange(res);
1911  PyCATCH
1912}
1913
1914PyObject *RuleBeamRefiner_new(PyTypeObject *type, PyObject *args, PyObject *keywords)  BASED_ON(Orange - Orange.classification.rules.BeamRefiner, "<abstract>")
1915{ if (type == (PyTypeObject *)&PyOrRuleBeamRefiner_Type)
1916    return setCallbackFunction(WrapNewOrange(mlnew TRuleBeamRefiner_Python(), type), args);
1917  else
1918    return WrapNewOrange(mlnew TRuleBeamRefiner_Python(), type);
1919}
1920
1921PyObject *RuleBeamRefiner__reduce__(PyObject *self)
1922{
1923  return callbackReduce(self, PyOrRuleBeamRefiner_Type);
1924}
1925
1926
1927PyObject *RuleBeamRefiner_call(PyObject *self, PyObject *args, PyObject *keywords) PYDOC("(rule, table, weightID, targetClass) -/-> (rules)")
1928{
1929  PyTRY
1930    NO_KEYWORDS
1931
1932    PExampleGenerator gen;
1933    int weightID = 0;
1934    int targetClass = -1;
1935    PRule rule;
1936
1937    if (!PyArg_ParseTuple(args, "O&O&O&i:RuleBeamRefiner.call", cc_Rule, &rule, pt_ExampleGenerator, &gen, pt_weightByGen(gen), &weightID, &targetClass))
1938      return PYNULL;
1939    CAST_TO(TRuleBeamRefiner, refiner)
1940
1941    PRuleList res = (*refiner)(rule, gen, weightID, targetClass);
1942    return WrapOrange(res);
1943  PyCATCH
1944}
1945
1946PyObject *RuleBeamInitializer_new(PyTypeObject *type, PyObject *args, PyObject *keywords)  BASED_ON(Orange - Orange.classification.rules.BeamInitializer, "<abstract>")
1947{ if (type == (PyTypeObject *)&PyOrRuleBeamInitializer_Type)
1948    return setCallbackFunction(WrapNewOrange(mlnew TRuleBeamInitializer_Python(), type), args);
1949  else
1950    return WrapNewOrange(mlnew TRuleBeamInitializer_Python(), type);
1951}
1952
1953PyObject *RuleBeamInitializer__reduce__(PyObject *self)
1954{
1955  return callbackReduce(self, PyOrRuleBeamInitializer_Type);
1956}
1957
1958
1959PyObject *RuleBeamInitializer_call(PyObject *self, PyObject *args, PyObject *keywords) PYDOC("(table, weightID, targetClass, baseRules, evaluator, prior) -/-> (rules, bestRule)")
1960{
1961  PyTRY
1962     NO_KEYWORDS
1963
1964    PExampleGenerator gen;
1965    PRuleList baseRules;
1966    PRuleEvaluator evaluator;
1967    PDistribution prior;
1968    PRule bestRule;
1969    int weightID = 0;
1970    int targetClass = -1;
1971    PRule rule;
1972
1973    if (!PyArg_ParseTuple(args, "O&O&iO&O&O&:RuleBeamInitializer.call", pt_ExampleGenerator, &gen, pt_weightByGen(gen), &weightID, &targetClass, ccn_RuleList, &baseRules, cc_RuleEvaluator, &evaluator, cc_Distribution, &prior))
1974      return PYNULL;
1975    CAST_TO(TRuleBeamInitializer, initializer)
1976
1977    PRuleList res = (*initializer)(gen, weightID, targetClass, baseRules, evaluator, prior, bestRule);
1978    return Py_BuildValue("NN", WrapOrange(res), WrapOrange(bestRule));
1979  PyCATCH
1980}
1981
1982PyObject *RuleBeamCandidateSelector_new(PyTypeObject *type, PyObject *args, PyObject *keywords)  BASED_ON(Orange - Orange.classification.rules.BeamCandidateSelector, "<abstract>")
1983{ if (type == (PyTypeObject *)&PyOrRuleBeamCandidateSelector_Type)
1984    return setCallbackFunction(WrapNewOrange(mlnew TRuleBeamCandidateSelector_Python(), type), args);
1985  else
1986    return WrapNewOrange(mlnew TRuleBeamCandidateSelector_Python(), type);
1987}
1988
1989PyObject *RuleBeamCandidateSelector__reduce__(PyObject *self)
1990{
1991  return callbackReduce(self, PyOrRuleBeamCandidateSelector_Type);
1992}
1993
1994
1995PyObject *RuleBeamCandidateSelector_call(PyObject *self, PyObject *args, PyObject *keywords) PYDOC("(existingRules, table, weightID) -/-> (candidates, remainingRules)")
1996{
1997  PyTRY
1998    NO_KEYWORDS
1999
2000    PExampleGenerator gen;
2001    PRuleList existingRules;
2002    int weightID = 0;
2003    PRuleList candidates;
2004
2005    if (!PyArg_ParseTuple(args, "O&O&O&:RuleBeamCandidateSelector.call", cc_RuleList, &existingRules, pt_ExampleGenerator, &gen, pt_weightByGen(gen), &weightID))
2006      return PYNULL;
2007    CAST_TO(TRuleBeamCandidateSelector, selector)
2008
2009    PRuleList res = (*selector)(existingRules, gen, weightID);
2010    return Py_BuildValue("NN", WrapOrange(res), WrapOrange(existingRules));
2011  PyCATCH
2012}
2013
2014PyObject *RuleBeamFilter_new(PyTypeObject *type, PyObject *args, PyObject *keywords)  BASED_ON(Orange - Orange.classification.rules.BeamFilter, "<abstract>")
2015{ if (type == (PyTypeObject *)&PyOrRuleBeamFilter_Type)
2016    return setCallbackFunction(WrapNewOrange(mlnew TRuleBeamFilter_Python(), type), args);
2017  else
2018    return WrapNewOrange(mlnew TRuleBeamFilter_Python(), type);
2019}
2020
2021PyObject *RuleBeamFilter__reduce__(PyObject *self)
2022{
2023  return callbackReduce(self, PyOrRuleBeamFilter_Type);
2024}
2025
2026
2027PyObject *RuleBeamFilter_call(PyObject *self, PyObject *args, PyObject *keywords) PYDOC("(rules, table, weightID) -/-> (rules)")
2028{
2029  PyTRY
2030    NO_KEYWORDS
2031
2032    PExampleGenerator gen;
2033    PRuleList rules;
2034    int weightID = 0;
2035
2036    if (!PyArg_ParseTuple(args, "O&O&O&:RuleBeamFilter.call", cc_RuleList, &rules, pt_ExampleGenerator, &gen, pt_weightByGen(gen), &weightID))
2037      return PYNULL;
2038    CAST_TO(TRuleBeamFilter, filter)
2039
2040    (*filter)(rules, gen, weightID);
2041    return WrapOrange(rules);
2042  PyCATCH
2043}
2044
2045PyObject *RuleClassifierConstructor_new(PyTypeObject *type, PyObject *args, PyObject *keywords)  BASED_ON(Orange - Orange.classification.rules.ClassifierConstructor, "<abstract>")
2046{ if (type == (PyTypeObject *)&PyOrRuleClassifierConstructor_Type)
2047    return setCallbackFunction(WrapNewOrange(mlnew TRuleClassifierConstructor_Python(), type), args);
2048  else
2049    return WrapNewOrange(mlnew TRuleClassifierConstructor_Python(), type);
2050}
2051
2052
2053PyObject *RuleClassifierConstructor__reduce__(PyObject *self)
2054{
2055  return callbackReduce(self, PyOrRuleClassifierConstructor_Type);
2056}
2057
2058
2059PyObject *RuleClassifierConstructor_call(PyObject *self, PyObject *args, PyObject *keywords) PYDOC("(rules, examples[, weight]) -> (RuleClassifier)")
2060{
2061  PyTRY
2062    NO_KEYWORDS
2063
2064    if (PyOrange_OrangeBaseClass(self->ob_type) == &PyOrRuleClassifierConstructor_Type) {
2065      PyErr_Format(PyExc_SystemError, "RuleClassifierConstructor.call called for '%s': this may lead to stack overflow", self->ob_type->tp_name);
2066      return PYNULL;
2067    }
2068
2069    PExampleGenerator gen;
2070    int weightID = 0;
2071    PRuleList rules;
2072
2073    if (!PyArg_ParseTuple(args, "O&O&|O&:RuleClassifierConstructor.call", cc_RuleList, &rules, pt_ExampleGenerator, &gen, pt_weightByGen(gen), &weightID))
2074      return PYNULL;
2075
2076    PRuleClassifier ruleClassifier;
2077    ruleClassifier = SELF_AS(TRuleClassifierConstructor)(rules, gen, weightID);
2078    return WrapOrange(ruleClassifier);
2079  PyCATCH
2080}
2081
2082PyObject *RuleClassifier_logit_new(PyObject *self, PyObject *args, PyObject *keywords) PYDOC("(rules, min_beta, examples[, weight])")
2083{
2084  PyTRY
2085    NO_KEYWORDS
2086
2087    if (PyOrange_OrangeBaseClass(self->ob_type) == &PyOrRuleClassifier_Type) {
2088      PyErr_Format(PyExc_SystemError, "RuleClassifier.call called for '%s': this may lead to stack overflow", self->ob_type->tp_name);
2089      return PYNULL;
2090    }
2091
2092    PExampleGenerator gen;
2093    int weightID = 0;
2094    float minSignificance = 0.5;
2095    float minBeta = 0.0;
2096    PRuleList rules;
2097    PDistributionList probList;
2098    PClassifier classifier;
2099    bool setPrefixRules;
2100    bool optimizeBetasFlag;
2101
2102    if (!PyArg_ParseTuple(args, "O&ffO&|O&iiO&O&:RuleClassifier.call", cc_RuleList, &rules, &minSignificance, &minBeta, pt_ExampleGenerator, &gen, pt_weightByGen(gen), &weightID, &setPrefixRules, &optimizeBetasFlag, cc_Classifier, &classifier, cc_DistributionList, &probList))
2103      return PYNULL;
2104
2105    TRuleClassifier *rc = new TRuleClassifier_logit(rules, minSignificance, minBeta, gen, weightID, classifier, probList,setPrefixRules, optimizeBetasFlag);
2106    PRuleClassifier ruleClassifier = rc;
2107//    ruleClassifier = new SELF_AS(TRuleClassifier)(rules, gen, weightID);
2108    return WrapOrange(ruleClassifier);
2109  PyCATCH
2110}
2111
2112PRuleList PRuleList_FromArguments(PyObject *arg) { return ListOfWrappedMethods<PRuleList, TRuleList, PRule, &PyOrRule_Type>::P_FromArguments(arg); }
2113PyObject *RuleList_FromArguments(PyTypeObject *type, PyObject *arg) { return ListOfWrappedMethods<PRuleList, TRuleList, PRule, &PyOrRule_Type>::_FromArguments(type, arg); }
2114PyObject *RuleList_new(PyTypeObject *type, PyObject *arg, PyObject *kwds) BASED_ON(Orange, "(<list of Rule>)") ALLOWS_EMPTY { return ListOfWrappedMethods<PRuleList, TRuleList, PRule, &PyOrRule_Type>::_new(type, arg, kwds); }
2115PyObject *RuleList_getitem_sq(TPyOrange *self, Py_ssize_t index) { return ListOfWrappedMethods<PRuleList, TRuleList, PRule, &PyOrRule_Type>::_getitem(self, index); }
2116int       RuleList_setitem_sq(TPyOrange *self, Py_ssize_t index, PyObject *item) { return ListOfWrappedMethods<PRuleList, TRuleList, PRule, &PyOrRule_Type>::_setitem(self, index, item); }
2117PyObject *RuleList_getslice(TPyOrange *self, Py_ssize_t start, Py_ssize_t stop) { return ListOfWrappedMethods<PRuleList, TRuleList, PRule, &PyOrRule_Type>::_getslice(self, start, stop); }
2118int       RuleList_setslice(TPyOrange *self, Py_ssize_t start, Py_ssize_t stop, PyObject *item) { return ListOfWrappedMethods<PRuleList, TRuleList, PRule, &PyOrRule_Type>::_setslice(self, start, stop, item); }
2119Py_ssize_t       RuleList_len_sq(TPyOrange *self) { return ListOfWrappedMethods<PRuleList, TRuleList, PRule, &PyOrRule_Type>::_len(self); }
2120PyObject *RuleList_richcmp(TPyOrange *self, PyObject *object, int op) { return ListOfWrappedMethods<PRuleList, TRuleList, PRule, &PyOrRule_Type>::_richcmp(self, object, op); }
2121PyObject *RuleList_concat(TPyOrange *self, PyObject *obj) { return ListOfWrappedMethods<PRuleList, TRuleList, PRule, &PyOrRule_Type>::_concat(self, obj); }
2122PyObject *RuleList_repeat(TPyOrange *self, Py_ssize_t times) { return ListOfWrappedMethods<PRuleList, TRuleList, PRule, &PyOrRule_Type>::_repeat(self, times); }
2123PyObject *RuleList_str(TPyOrange *self) { return ListOfWrappedMethods<PRuleList, TRuleList, PRule, &PyOrRule_Type>::_str(self); }
2124PyObject *RuleList_repr(TPyOrange *self) { return ListOfWrappedMethods<PRuleList, TRuleList, PRule, &PyOrRule_Type>::_str(self); }
2125int       RuleList_contains(TPyOrange *self, PyObject *obj) { return ListOfWrappedMethods<PRuleList, TRuleList, PRule, &PyOrRule_Type>::_contains(self, obj); }
2126PyObject *RuleList_append(TPyOrange *self, PyObject *item) PYARGS(METH_O, "(Rule) -> None") { return ListOfWrappedMethods<PRuleList, TRuleList, PRule, &PyOrRule_Type>::_append(self, item); }
2127PyObject *RuleList_extend(TPyOrange *self, PyObject *obj) PYARGS(METH_O, "(sequence) -> None") { return ListOfWrappedMethods<PRuleList, TRuleList, PRule, &PyOrRule_Type>::_extend(self, obj); }
2128PyObject *RuleList_count(TPyOrange *self, PyObject *obj) PYARGS(METH_O, "(Rule) -> int") { return ListOfWrappedMethods<PRuleList, TRuleList, PRule, &PyOrRule_Type>::_count(self, obj); }
2129PyObject *RuleList_filter(TPyOrange *self, PyObject *args) PYARGS(METH_VARARGS, "([filter-function]) -> RuleList") { return ListOfWrappedMethods<PRuleList, TRuleList, PRule, &PyOrRule_Type>::_filter(self, args); }
2130PyObject *RuleList_index(TPyOrange *self, PyObject *obj) PYARGS(METH_O, "(Rule) -> int") { return ListOfWrappedMethods<PRuleList, TRuleList, PRule, &PyOrRule_Type>::_index(self, obj); }
2131PyObject *RuleList_insert(TPyOrange *self, PyObject *args) PYARGS(METH_VARARGS, "(index, item) -> None") { return ListOfWrappedMethods<PRuleList, TRuleList, PRule, &PyOrRule_Type>::_insert(self, args); }
2132PyObject *RuleList_native(TPyOrange *self) PYARGS(METH_NOARGS, "() -> list") { return ListOfWrappedMethods<PRuleList, TRuleList, PRule, &PyOrRule_Type>::_native(self); }
2133PyObject *RuleList_pop(TPyOrange *self, PyObject *args) PYARGS(METH_VARARGS, "() -> Rule") { return ListOfWrappedMethods<PRuleList, TRuleList, PRule, &PyOrRule_Type>::_pop(self, args); }
2134PyObject *RuleList_remove(TPyOrange *self, PyObject *obj) PYARGS(METH_O, "(Rule) -> None") { return ListOfWrappedMethods<PRuleList, TRuleList, PRule, &PyOrRule_Type>::_remove(self, obj); }
2135PyObject *RuleList_reverse(TPyOrange *self) PYARGS(METH_NOARGS, "() -> None") { return ListOfWrappedMethods<PRuleList, TRuleList, PRule, &PyOrRule_Type>::_reverse(self); }
2136PyObject *RuleList_sort(TPyOrange *self, PyObject *args) PYARGS(METH_VARARGS, "([cmp-func]) -> None") { return ListOfWrappedMethods<PRuleList, TRuleList, PRule, &PyOrRule_Type>::_sort(self, args); }
2137PyObject *RuleList__reduce__(TPyOrange *self, PyObject *) { return ListOfWrappedMethods<PRuleList, TRuleList, PRule, &PyOrRule_Type>::_reduce(self); }
2138
2139PEVDistList PEVDistList_FromArguments(PyObject *arg) { return ListOfWrappedMethods<PEVDistList, TEVDistList, PEVDist, &PyOrEVDist_Type>::P_FromArguments(arg); }
2140PyObject *EVDistList_FromArguments(PyTypeObject *type, PyObject *arg) { return ListOfWrappedMethods<PEVDistList, TEVDistList, PEVDist, &PyOrEVDist_Type>::_FromArguments(type, arg); }
2141PyObject *EVDistList_new(PyTypeObject *type, PyObject *arg, PyObject *kwds) BASED_ON(Orange, "(<list of EVDist>)") ALLOWS_EMPTY { return ListOfWrappedMethods<PEVDistList, TEVDistList, PEVDist, &PyOrEVDist_Type>::_new(type, arg, kwds); }
2142PyObject *EVDistList_getitem_sq(TPyOrange *self, Py_ssize_t index) { return ListOfWrappedMethods<PEVDistList, TEVDistList, PEVDist, &PyOrEVDist_Type>::_getitem(self, index); }
2143int       EVDistList_setitem_sq(TPyOrange *self, Py_ssize_t index, PyObject *item) { return ListOfWrappedMethods<PEVDistList, TEVDistList, PEVDist, &PyOrEVDist_Type>::_setitem(self, index, item); }
2144PyObject *EVDistList_getslice(TPyOrange *self, Py_ssize_t start, Py_ssize_t stop) { return ListOfWrappedMethods<PEVDistList, TEVDistList, PEVDist, &PyOrEVDist_Type>::_getslice(self, start, stop); }
2145int       EVDistList_setslice(TPyOrange *self, Py_ssize_t start, Py_ssize_t stop, PyObject *item) { return ListOfWrappedMethods<PEVDistList, TEVDistList, PEVDist, &PyOrEVDist_Type>::_setslice(self, start, stop, item); }
2146Py_ssize_t       EVDistList_len_sq(TPyOrange *self) { return ListOfWrappedMethods<PEVDistList, TEVDistList, PEVDist, &PyOrEVDist_Type>::_len(self); }
2147PyObject *EVDistList_richcmp(TPyOrange *self, PyObject *object, int op) { return ListOfWrappedMethods<PEVDistList, TEVDistList, PEVDist, &PyOrEVDist_Type>::_richcmp(self, object, op); }
2148PyObject *EVDistList_concat(TPyOrange *self, PyObject *obj) { return ListOfWrappedMethods<PEVDistList, TEVDistList, PEVDist, &PyOrEVDist_Type>::_concat(self, obj); }
2149PyObject *EVDistList_repeat(TPyOrange *self, Py_ssize_t times) { return ListOfWrappedMethods<PEVDistList, TEVDistList, PEVDist, &PyOrEVDist_Type>::_repeat(self, times); }
2150PyObject *EVDistList_str(TPyOrange *self) { return ListOfWrappedMethods<PEVDistList, TEVDistList, PEVDist, &PyOrEVDist_Type>::_str(self); }
2151PyObject *EVDistList_repr(TPyOrange *self) { return ListOfWrappedMethods<PEVDistList, TEVDistList, PEVDist, &PyOrEVDist_Type>::_str(self); }
2152int       EVDistList_contains(TPyOrange *self, PyObject *obj) { return ListOfWrappedMethods<PEVDistList, TEVDistList, PEVDist, &PyOrEVDist_Type>::_contains(self, obj); }
2153PyObject *EVDistList_append(TPyOrange *self, PyObject *item) PYARGS(METH_O, "(EVDist) -> None") { return ListOfWrappedMethods<PEVDistList, TEVDistList, PEVDist, &PyOrEVDist_Type>::_append(self, item); }
2154PyObject *EVDistList_extend(TPyOrange *self, PyObject *obj) PYARGS(METH_O, "(sequence) -> None") { return ListOfWrappedMethods<PEVDistList, TEVDistList, PEVDist, &PyOrEVDist_Type>::_extend(self, obj); }
2155PyObject *EVDistList_count(TPyOrange *self, PyObject *obj) PYARGS(METH_O, "(EVDist) -> int") { return ListOfWrappedMethods<PEVDistList, TEVDistList, PEVDist, &PyOrEVDist_Type>::_count(self, obj); }
2156PyObject *EVDistList_filter(TPyOrange *self, PyObject *args) PYARGS(METH_VARARGS, "([filter-function]) -> EVDistList") { return ListOfWrappedMethods<PEVDistList, TEVDistList, PEVDist, &PyOrEVDist_Type>::_filter(self, args); }
2157PyObject *EVDistList_index(TPyOrange *self, PyObject *obj) PYARGS(METH_O, "(EVDist) -> int") { return ListOfWrappedMethods<PEVDistList, TEVDistList, PEVDist, &PyOrEVDist_Type>::_index(self, obj); }
2158PyObject *EVDistList_insert(TPyOrange *self, PyObject *args) PYARGS(METH_VARARGS, "(index, item) -> None") { return ListOfWrappedMethods<PEVDistList, TEVDistList, PEVDist, &PyOrEVDist_Type>::_insert(self, args); }
2159PyObject *EVDistList_native(TPyOrange *self) PYARGS(METH_NOARGS, "() -> list") { return ListOfWrappedMethods<PEVDistList, TEVDistList, PEVDist, &PyOrEVDist_Type>::_native(self); }
2160PyObject *EVDistList_pop(TPyOrange *self, PyObject *args) PYARGS(METH_VARARGS, "() -> EVDist") { return ListOfWrappedMethods<PEVDistList, TEVDistList, PEVDist, &PyOrEVDist_Type>::_pop(self, args); }
2161PyObject *EVDistList_remove(TPyOrange *self, PyObject *obj) PYARGS(METH_O, "(EVDist) -> None") { return ListOfWrappedMethods<PEVDistList, TEVDistList, PEVDist, &PyOrEVDist_Type>::_remove(self, obj); }
2162PyObject *EVDistList_reverse(TPyOrange *self) PYARGS(METH_NOARGS, "() -> None") { return ListOfWrappedMethods<PEVDistList, TEVDistList, PEVDist, &PyOrEVDist_Type>::_reverse(self); }
2163PyObject *EVDistList_sort(TPyOrange *self, PyObject *args) PYARGS(METH_VARARGS, "([cmp-func]) -> None") { return ListOfWrappedMethods<PEVDistList, TEVDistList, PEVDist, &PyOrEVDist_Type>::_sort(self, args); }
2164PyObject *EVDistList__reduce__(TPyOrange *self, PyObject *) { return ListOfWrappedMethods<PEVDistList, TEVDistList, PEVDist, &PyOrEVDist_Type>::_reduce(self); }
2165
2166#include "lib_learner.px"
2167
Note: See TracBrowser for help on using the repository browser.