Changeset 7902:20333951f0d5 in orange


Ignore:
Timestamp:
05/13/11 12:28:20 (3 years ago)
Author:
ales_erjavec <ales.erjavec@…>
Branch:
default
Convert:
91d204e242bd84f8618b2fc8bd72fb3ec65c1c65
Message:

Returning orange.Distibution instances from the classifiers call methods.
Fixed handling of 'returnWhat' parameters.

Location:
orange/Orange/ensemble
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orange/Orange/ensemble/bagging.py

    r7901 r7902  
    117117            for i in range(len(freq)): 
    118118                freq[i] = freq[i]/len(self.classifiers) 
     119            freq = Orange.statistics.distribution.Discrete(freq) 
    119120            if resultType == orange.GetProbabilities: 
    120121                return freq 
     122            elif resultType == orange.GetBoth: 
     123                return (value, freq) 
    121124            else: 
    122                 return (value, freq) 
     125                return value 
     126             
    123127        elif self.classVar.varType ==Orange.data.Type.Continuous: 
    124128            votes = [c(instance, orange.GetBoth if resultType==\ 
     
    137141                        prob[float(c)] += 1.0 / wsum 
    138142                prob = orange.ContDistribution(prob) 
    139                 return self.classVar(pred), prob if resultType == orange.GetBoth\ 
     143                return (self.classVar(pred), prob) if resultType == orange.GetBoth\ 
    140144                    else prob 
    141145            elif resultType == orange.GetValue: 
  • orange/Orange/ensemble/boosting.py

    r7901 r7902  
    131131              :class:`Orange.statistics.Distribution` or a tuple with both 
    132132        """ 
    133         votes = [0.] * len(self.classVar.values) 
     133        votes = Orange.statistics.distribution.Discrete(self.classVar) 
    134134        for c, e in self.classifiers: 
    135135            votes[int(c(instance))] += e 
     
    144144        if resultType == orange.GetProbabilities: 
    145145            return votes 
     146        elif resultType == orange.GetBoth: 
     147            return (value, votes) 
    146148        else: 
    147             return (value, votes) 
     149            return value 
    148150         
    149151    def __reduce__(self): 
Note: See TracChangeset for help on using the changeset viewer.