Changeset 4661:12402c84d07a in orange


Ignore:
Timestamp:
05/18/08 00:01:58 (6 years ago)
Author:
janezd <janez.demsar@…>
Branch:
default
Convert:
eed79e7447fd96078e23e06dfbd424a625e8160d
Message:
  • learners now also accept list of examples, not only ExampleTables
File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/orngCN2.py

    r4636 r4661  
    141141        self.examples = examples 
    142142        self.__dict__.update(argkw) 
    143         self.prior = orange.Distribution(examples.domain.classVar, examples) 
     143        # examples[0] to make it work on a list of examples, too 
     144        self.prior = orange.Distribution(examples[0].domain.classVar, examples) 
    144145 
    145146    def __call__(self, example, result_type=orange.GetValue): 
     
    191192         
    192193        rules = orange.RuleList() 
    193         self.ruleStopping.apriori = orange.Distribution(examples.domain.classVar,examples) 
     194         
     195        # examples[0] to make it work on a list of examples, too 
     196        self.ruleStopping.apriori = orange.Distribution(examples[0].domain.classVar,examples) 
    194197        progress=getattr(self,"progressCallback",None) 
    195198        if progress: 
    196199            progress.start = 0.0 
    197200            progress.end = 0.0 
    198             distrib = orange.Distribution(examples.domain.classVar, examples, weight) 
     201            # examples[0] to make it work on a list of examples, too 
     202            distrib = orange.Distribution(examples[0].domain.classVar, examples, weight) 
    199203            distrib.normalize() 
    200         for targetClass in examples.domain.classVar: 
     204        for targetClass in examples[0].domain.classVar: 
    201205            if progress: 
    202206                progress.start = progress.end 
     
    229233 
    230234        # create empty distribution 
    231         retDist = orange.DiscDistribution(self.examples.domain.classVar) 
     235        # examples[0] to make it work on a list of examples, too 
     236        retDist = orange.DiscDistribution(self.examples[0].domain.classVar) 
    232237        covRules = orange.RuleList() 
    233238        # iterate through examples - add distributions 
     
    240245            retDist = self.prior 
    241246            sumdisc = self.prior.abs 
    242         for c in self.examples.domain.classVar: 
     247        for c in self.examples[0].domain.classVar: 
    243248            retDist[c] /= sumdisc 
    244249        if retRules: 
     
    265270        self.examples = examples 
    266271        self.__dict__.update(argkw) 
    267         self.prior = orange.Distribution(examples.domain.classVar, examples) 
     272        # examples[0] to make it work on a list of examples, too 
     273        self.prior = orange.Distribution(examples[0].domain.classVar, examples) 
    268274 
    269275    def __call__(self, example, result_type=orange.GetValue): 
Note: See TracChangeset for help on using the changeset viewer.