Changeset 10492:4342898bd335 in orange


Ignore:
Timestamp:
03/10/12 09:49:13 (2 years ago)
Author:
Jure Zbontar <jure.zbontar@…>
Branch:
default
Message:

fixes #1126

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/orange/tdidt_simple.cpp

    r10252 r10492  
    698698 
    699699float * 
    700 predict_classification(const TExample &ex, struct SimpleTreeNode *node, int *free_dist) 
    701 { 
    702     int i, j, cls_vals; 
     700predict_classification(const TExample &ex, struct SimpleTreeNode *node, int *free_dist, int cls_vals) 
     701{ 
     702    int i, j; 
    703703    float *dist, *child_dist; 
    704704 
    705705    while (node->type != PredictorNode) 
    706706        if (ex.values[node->split_attr].isSpecial()) { 
    707             cls_vals = ex.domain->classVar->noOfValues(); 
    708707            ASSERT(dist = (float *)calloc(cls_vals, sizeof *dist)); 
    709708            for (i = 0; i < node->children_size; i++) { 
    710                 child_dist = predict_classification(ex, node->children[i], free_dist); 
     709                child_dist = predict_classification(ex, node->children[i], free_dist, cls_vals); 
    711710                for (j = 0; j < cls_vals; j++) 
    712711                    dist[j] += child_dist[j]; 
     
    851850        float *dist; 
    852851 
    853         dist = predict_classification(ex, tree, &free_dist); 
     852        dist = predict_classification(ex, tree, &free_dist, this->cls_vals); 
    854853        best_val = 0; 
    855         for (i = 1; i < ex.domain->classVar->noOfValues(); i++) 
     854        for (i = 1; i < this->cls_vals; i++) 
    856855            if (dist[i] > dist[best_val]) 
    857856                best_val = i; 
     
    877876        float *dist; 
    878877 
    879         dist = predict_classification(ex, tree, &free_dist); 
    880  
    881         PDistribution pdist = TDistribution::create(ex.domain->classVar); 
    882         for (i = 0; i < ex.domain->classVar->noOfValues(); i++) 
     878        dist = predict_classification(ex, tree, &free_dist, this->cls_vals); 
     879 
     880        PDistribution pdist = mlnew TDiscDistribution(this->cls_vals, 0.0); 
     881        for (i = 0; i < this->cls_vals; i++) 
    883882            pdist->setint(i, dist[i]); 
    884883        pdist->normalize(); 
Note: See TracChangeset for help on using the changeset viewer.