Changeset 11624:365165ac0244 in orange


Ignore:
Timestamp:
07/11/13 17:23:16 (9 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Added an explicit check for subset size reduction.

Fixes #1243

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/orange/tdidt_simple.cpp

    r10965 r11624  
    597597            } 
    598598 
    599         node->type = ContinuousNode; 
    600         node->split_attr = best_attr; 
    601         node->split = best_split; 
    602         node->children_size = 2; 
    603         ASSERT(node->children = (SimpleTreeNode **)calloc(2, sizeof *node->children)); 
    604  
    605         node->children[0] = build_tree(examples_lt, ex_lt - examples_lt, depth + 1, node, args); 
    606         node->children[1] = build_tree(examples_ge, ex_ge - examples_ge, depth + 1, node, args); 
     599        /* 
     600         * Check there was an actual reduction of size in the the two subsets. 
     601         * This test fails when all best_attr's (the only attr) values  are 
     602         * the same (and equal best_split) so the data is split in 0 | n size 
     603         * subsets and recursing would lead to an infinite recursion. 
     604         */ 
     605        if ((ex_lt - examples_lt) < size && (ex_ge - examples_ge) < size) { 
     606            node->type = ContinuousNode; 
     607            node->split_attr = best_attr; 
     608            node->split = best_split; 
     609            node->children_size = 2; 
     610            ASSERT(node->children = (SimpleTreeNode **)calloc(2, sizeof *node->children)); 
     611 
     612            node->children[0] = build_tree(examples_lt, ex_lt - examples_lt, depth + 1, node, args); 
     613            node->children[1] = build_tree(examples_ge, ex_ge - examples_ge, depth + 1, node, args); 
     614        } else { 
     615            node = make_predictor(node, examples, size, args); 
     616        } 
    607617 
    608618        free(examples_lt); 
Note: See TracChangeset for help on using the changeset viewer.