Changeset 10749:8943737ecb78 in orange


Ignore:
Timestamp:
04/04/12 16:37:08 (2 years ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Disable the output if results are from a proportion test.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeWidgets/Evaluate/OWConfusionMatrix.py

    r9671 r10749  
    88from OWWidget import * 
    99import OWGUI 
     10import orange 
    1011import orngStat, orngTest 
    1112import statc, math 
     13 
    1214from operator import add 
     15from collections import defaultdict 
     16 
    1317from Orange.evaluation.testing import TEST_TYPE_SINGLE 
    1418             
     
    7579        OWGUI.separator(self.controlArea) 
    7680 
    77         box = OWGUI.widgetBox(self.controlArea, "Output") 
     81        self.outputBox = box = OWGUI.widgetBox(self.controlArea, "Output") 
    7882        OWGUI.checkBox(box, self, "appendPredictions", "Append class predictions", callback = self.sendIf) 
    7983        OWGUI.checkBox(box, self, "appendProbabilities", "Append predicted class probabilities", callback = self.sendIf) 
     
    105109    def setTestResults(self, res): 
    106110        self.res = res 
     111        self.warning([0, 1]) 
     112        self.outputBox.setEnabled(True) 
     113         
    107114        if not res: 
    108115            self.matrix = None 
     
    114121            self.warning(0, "Confusion matrix can be calculated only for single-target prediction problems.") 
    115122            return 
    116         self.warning(0, None) 
     123         
     124        canOutput = True 
     125        if not hasattr(res, "examples"): 
     126            self.warning(1, "Results do not have testing instances (Output is disabled).") 
     127            canOutput = False 
     128        elif not isinstance(res.examples, orange.ExampleTable): 
     129            self.warning(1, "Output for results from 'Proportion test' is not supported.") 
     130            canOutput = False 
     131             
     132        self.outputBox.setEnabled(canOutput)  
    117133         
    118134        self.matrix = orngStat.confusionMatrices(res, -2) 
     
    279295 
    280296        learnerI = self.selectedLearner[0] 
    281         selectionIndices = [i for i, rese in enumerate(res.results) if (rese.actualClass, rese.classes[learnerI]) in selected] 
    282         data = res.examples.getitemsref(selectionIndices) 
    283          
    284         if self.appendPredictions or self.appendProbabilities: 
     297         
     298        data = None 
     299        if hasattr(res, "examples") and isinstance(res.examples, orange.ExampleTable): 
     300            selectionIndices = [i for i, rese in enumerate(res.results) if (rese.actualClass, rese.classes[learnerI]) in selected] 
     301            data = res.examples.getitemsref(selectionIndices) 
     302         
     303        if data is not None and (self.appendPredictions or self.appendProbabilities): 
    285304            domain = orange.Domain(data.domain.attributes, data.domain.classVar) 
    286305            domain.addmetas(data.domain.getmetas()) 
Note: See TracChangeset for help on using the changeset viewer.