Changeset 7286:bafacabe4197 in orange


Ignore:
Timestamp:
02/03/11 00:17:00 (3 years ago)
Author:
crt <crtomir.gorup@…>
Branch:
default
Convert:
db0bd7c93670d0d89e2552d11daf2877a0272d7f
Message:

uses orngMisc, add changed to sum

Location:
orange/Orange/ensemble
Files:
2 edited

Legend:

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

    r7266 r7286  
    7676 
    7777    def __call__(self, example, resultType = orange.GetValue): 
    78         if self.classVar.varType == orange.data.Type.Discrete: 
     78        if self.classVar.varType == Orange.data.Type.Discrete: 
    7979            freq = [0.] * len(self.classVar.values) 
    8080            for c in self.classifiers: 
    8181                freq[int(c(example))] += 1 
    8282            index = freq.index(max(freq)) 
    83             value = orange.data.Value(self.classVar, index) 
     83            value = Orange.data.Value(self.classVar, index) 
    8484            if resultType == orange.GetValue: 
    8585                return value 
     
    9090            else: 
    9191                return (value, freq) 
    92         elif self.classVar.varType == orange.data.Type.Continuous: 
     92        elif self.classVar.varType ==Orange.data.Type.Continuous: 
    9393            votes = [c(example, orange.GetBoth if resultType==\ 
    9494                orange.GetProbabilities else resultType) \ 
  • orange/Orange/ensemble/boosting.py

    r7279 r7286  
    5151 
    5252    def __call__(self, instances, origWeight = 0): 
     53        import math 
    5354        weight = orange.newmetaid() 
    5455        if origWeight: 
     
    8182                if corr[e]: 
    8283                    instances[e].setweight(weight, instances[e].getweight(weight)*beta) 
    83             f = 1/float(reduce(add, [e.getweight(weight) for e in instances])) 
     84            f = 1/float(sum([e.getweight(weight) for e in instances])) 
    8485            for e in range(n): 
    8586                instances[e].setweight(weight, instances[e].getweight(weight)*f) 
Note: See TracChangeset for help on using the changeset viewer.