source: orange/source/orange/lib_learner.cpp @ 7715:1b96a16d0b01

Revision 7715:1b96a16d0b01, 94.0 KB checked in by janezd <janez.demsar@…>, 3 years ago (diff)

Most C++ classes which are exported through the new modules now show the "correct" names.

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