def results(self, dres):
        self.closeContext()

        self.targetClass = None
        self.classifiersQLB.clear()
        self.removeGraphs()
        self.classCombo.clear()

        self.dres = dres

        if dres and dres.test_type != TEST_TYPE_SINGLE:
            self.warning(
                0,
                "Calibration plot is supported only for single-target prediction problems."
            )
            return
        self.warning(0, None)

        self.graphs = []
        if self.dres <> None:
            self.numberOfClasses = len(self.dres.classValues)
            ## one graph for each class
            for i in range(self.numberOfClasses):
                graph = singleClassCalibrationPlotGraph(self.mainArea)
                graph.hide()
                self.graphs.append(graph)
                self.classCombo.addItem(self.dres.classValues[i])

            ## classifiersQLB
            self.classifierColor = []
            self.numberOfClassifiers = self.dres.numberOfLearners
            if self.numberOfClassifiers > 1:
                allCforHSV = self.numberOfClassifiers - 1
            else:
                allCforHSV = self.numberOfClassifiers
            for i in range(self.numberOfClassifiers):
                newColor = QColor()
                newColor.setHsv(i * 255 / allCforHSV, 255, 255)
                self.classifierColor.append(newColor)

            self.calcAllClassGraphs()

            ## update graphics
            ## classifiersQLB
            for i in range(self.numberOfClassifiers):
                newColor = self.classifierColor[i]
                self.classifiersQLB.addItem(
                    QListWidgetItem(ColorPixmap(newColor),
                                    self.dres.classifierNames[i]))
            self.classifiersQLB.selectAll()
        else:
            self.numberOfClasses = 0
            self.classifierColor = None
            self.targetClass = None  ## no results, no target

        if not self.targetClass:
            self.targetClass = 0

        self.openContext("", self.dres)
        self.target()
 def updatellb(self):
     self.blockSelectionChanges = 1
     self.llb.clear()
     colors = ColorPaletteHSV(len(self.learners))
     for (i, lt) in enumerate(self.learners):
         l = lt[1]
         item = QListWidgetItem(ColorPixmap(colors[i]), l.name)
         self.llb.addItem(item)
         item.setSelected(l.isSelected)
         l.color = colors[i]
     self.blockSelectionChanges = 0
Exemplo n.º 3
0
    def results(self, dres):
        self.closeContext()

        self.targeClass = None
        self.classifiersQLB.clear()
        self.removeGraphs()
        self.classCombo.clear()

        self.dres = dres

        self.graphs = []
        if self.dres != None:
            self.numberOfClasses = len(self.dres.classValues)
            ## one graph for each class
            for i in range(self.numberOfClasses):
                graph = singleClassCalibrationPlotGraph(self.mainArea)
                graph.hide()
                self.graphs.append(graph)
                self.classCombo.addItem(self.dres.classValues[i])

            ## classifiersQLB
            self.classifierColor = []
            self.numberOfClassifiers = self.dres.numberOfLearners
            if self.numberOfClassifiers > 1:
                allCforHSV = self.numberOfClassifiers - 1
            else:
                allCforHSV = self.numberOfClassifiers
            for i in range(self.numberOfClassifiers):
                newColor = QColor()
                newColor.setHsv(i * 255 / allCforHSV, 255, 255)
                self.classifierColor.append(newColor)

            self.calcAllClassGraphs()

            ## update graphics
            ## classifiersQLB
            for i in range(self.numberOfClassifiers):
                newColor = self.classifierColor[i]
                self.classifiersQLB.addItem(
                    QListWidgetItem(ColorPixmap(newColor),
                                    self.dres.classifierNames[i]))
            self.classifiersQLB.selectAll()
        else:
            self.numberOfClasses = 0
            self.classifierColor = None
            self.targetClass = None  ## no results, no target

        if not self.targetClass:
            self.targetClass = 0

        self.openContext("", self.dres)
        self.target()
Exemplo n.º 4
0
 def setOutcomeNames(self, list):
     "Sets the outcome target names."
     colors = ColorPaletteGenerator()
     self.outcomes = [(ColorPixmap(c), l) for c, l in zip(colors, list)]
     self.visibleOutcomes = range(len(list))
Exemplo n.º 5
0
    def test_results(self, dres):
        self.FPcostList = []
        self.FNcostList = []
        self.pvalueList = []

        self.closeContext()

        if not dres:
            self.targetClass = None
            self.classCombo.clear()
            self.testSetsQLB.clear()
            self.classifiersQLB.clear()
            self.removeGraphs()
            self.openContext("", dres)
            return
        self.dres = dres

        self.classifiersQLB.clear()
        self.testSetsQLB.clear()
        self.removeGraphs()
        self.classCombo.clear()

        self.defaultPerfLinePValues = []
        if self.dres != None:
            ## classQLB
            self.numberOfClasses = len(self.dres.classValues)
            self.graphs = []

            for i in range(self.numberOfClasses):
                self.FPcostList.append(500)
                self.FNcostList.append(500)
                graph = singleClassROCgraph(
                    self.mainArea, "",
                    "Predicted class: " + self.dres.classValues[i])
                self.graphs.append(graph)
                self.classCombo.addItem(self.dres.classValues[i])

            ## classifiersQLB
            self.classifierColor = []
            self.numberOfClassifiers = self.dres.numberOfLearners
            if self.numberOfClassifiers > 1:
                allCforHSV = self.numberOfClassifiers - 1
            else:
                allCforHSV = self.numberOfClassifiers
            for i in range(self.numberOfClassifiers):
                newColor = QColor()
                newColor.setHsv(i * 255 / allCforHSV, 255, 255)
                self.classifierColor.append(newColor)

            ## testSetsQLB
            self.dresSplitByIterations = orngStat.splitByIterations(self.dres)
            self.numberOfIterations = len(self.dresSplitByIterations)

            self.calcAllClassGraphs()

            ## classifiersQLB
            for i in range(self.numberOfClassifiers):
                newColor = self.classifierColor[i]
                self.classifiersQLB.addItem(
                    QListWidgetItem(ColorPixmap(newColor),
                                    self.dres.classifierNames[i]))
            self.classifiersQLB.selectAll()

            ## testSetsQLB
            self.testSetsQLB.addItems(
                [str(i) for i in range(self.numberOfIterations)])
            self.testSetsQLB.selectAll()

            ## calculate default pvalues
            reminder = self.maxp
            for f in orngStat.classProbabilitiesFromRes(self.dres):
                v = int(round(f * self.maxp))
                reminder -= v
                if reminder < 0:
                    v = v + reminder
                self.defaultPerfLinePValues.append(v)
                self.pvalueList.append(v)

            self.targetClass = 0  ## select first target
            self.target()
        else:
            self.classifierColor = None
        self.openContext("", self.dres)
        self.performanceTabCosts.setEnabled(self.AveragingMethod == 'merge')
        self.setDefaultPValues()
Exemplo n.º 6
0
    def results(self, dres):
        self.closeContext()

        self.FPcostList = []
        self.FNcostList = []
        self.pvalueList = []

        self.classCombo.clear()
        self.removeGraphs()
        self.testSetsQLB.clear()
        self.classifiersQLB.clear()

        self.warning([0, 1])

        if dres is not None and dres.class_values is None:
            self.warning(1, "Lift Curve cannot be used for regression results.")
            dres = None

        self.dres = dres

        if not dres:
            self.targetClass = None
            self.openContext("", dres)
            return

        if dres and dres.test_type != TEST_TYPE_SINGLE:
            self.warning(0, "Lift curve is supported only for single-target prediction problems.")
            return

        self.defaultPerfLinePValues = []
        if self.dres <> None:
            ## classQLB
            self.numberOfClasses = len(self.dres.classValues)
            self.graphs = []

            for i in range(self.numberOfClasses):
                self.FPcostList.append( 500)
                self.FNcostList.append( 500)
                graph = singleClassLiftCurveGraph(self.mainArea, "", "Predicted class: " + self.dres.classValues[i])
                self.graphs.append( graph )
                self.classCombo.addItem(self.dres.classValues[i])

            ## classifiersQLB
            self.classifierColor = []
            self.numberOfClassifiers = self.dres.numberOfLearners
            if self.numberOfClassifiers > 1:
                allCforHSV = self.numberOfClassifiers - 1
            else:
                allCforHSV = self.numberOfClassifiers
            for i in range(self.numberOfClassifiers):
                newColor = QColor()
                newColor.setHsv(i*255/allCforHSV, 255, 255)
                self.classifierColor.append( newColor )

            ## testSetsQLB
            self.dresSplitByIterations = orngStat.splitByIterations(self.dres)
            self.numberOfIterations = len(self.dresSplitByIterations)

            self.calcAllClassGraphs()

            ## classifiersQLB
            for i in range(self.numberOfClassifiers):
                newColor = self.classifierColor[i]
                self.classifiersQLB.addItem(QListWidgetItem(ColorPixmap(newColor), self.dres.classifierNames[i]))
            self.classifiersQLB.selectAll()

            ## testSetsQLB
            self.testSetsQLB.addItems([str(i) for i in range(self.numberOfIterations)])
            self.testSetsQLB.selectAll()

            ## calculate default pvalues
            reminder = self.maxp
            for f in orngStat.classProbabilitiesFromRes(self.dres):
                v = int(round(f * self.maxp))
                reminder -= v
                if reminder < 0:
                    v = v+reminder
                self.defaultPerfLinePValues.append(v)
                self.pvalueList.append( v)

            self.targetClass = 0  # select first class as default target
            self.openContext("", self.dres)

            # Update target class and selected classifiers from
            # context settings
            self.target()
            self.classifiersSelectionChange()

        else:
            self.classifierColor = None
        self.performanceTabCosts.setEnabled(1)
        self.setDefaultPValues()