Changeset 9250:292c06f7a7a8 in orange


Ignore:
Timestamp:
11/23/11 13:30:25 (2 years ago)
Author:
ales_erjavec <ales.erjavec@…>
Branch:
default
Convert:
6d6a221dd0cf6cde184007ca37d2cb905b88eba2
Message:

Added an option to replace/add predictions as the new class var (fixes #1010).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/Evaluate/OWPredictions.py

    r9239 r9250  
    151151        self.tasklabel = "N/A" 
    152152        self.precision = 2 
     153        self.doPrediction = True 
    153154        self.outvar = None # current output variable (set by the first predictor/data set send in) 
    154155 
     
    202203        cb = OWGUI.checkBox(self.outbox, self, 'sendOnChange', 'Send automatically') 
    203204        OWGUI.setStopper(self, b, cb, "changedFlag", callback=self.sendpredictions) 
     205        OWGUI.checkBox(self.outbox, self, "doPrediction", "Replace/add predicted class", 
     206                       tooltip="Apply the first predictor to input examples and replace/add the predicted value as the new class variable.", 
     207                       callback=self.checksendpredictions) 
    204208 
    205209        self.outbox.setDisabled(1) 
     
    480484                  for c in self.predictors.values()] 
    481485            metas.extend(mc) 
    482  
    483         domain = orange.Domain(self.data.domain.attributes + [self.data.domain.classVar]) 
     486                 
     487        classVar = self.outvar 
     488        domain = orange.Domain(self.data.domain.attributes + [classVar]) 
    484489        domain.addmetas(self.data.domain.getmetas()) 
    485490        for m in metas: 
    486491            domain.addmeta(orange.newmetaid(), m) 
    487492        predictions = orange.ExampleTable(domain, self.data) 
     493        if self.doPrediction: 
     494            c = self.predictors.values()[0] 
     495            for ex in predictions: 
     496                ex[classVar] = c(ex) 
     497                 
    488498        predictions.name = self.data.name 
    489499        self.send("Predictions", predictions) 
Note: See TracChangeset for help on using the changeset viewer.