source: orange/source/orange/lib_learner.cpp @ 11606:f27665aa9f40

Revision 11606:f27665aa9f40, 97.3 KB checked in by Ales Erjavec <ales.erjavec@…>, 10 months ago (diff)

Changed TSVMClassifier constructor interface.

It no longer requires "examples" table unless using a custom kernel
and no longer keeps the training "x_space" array (the passed svm_model
needs to 'own' the *(model->SV) array).

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