Ejemplo n.º 1
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, 'AttributeSampler')

        self.inputs = [("Examples", Orange.data.Table, self.dataset)]
        self.outputs = [("Examples", Orange.data.Table)]

        self.icons = self.createAttributeIconDict()

        self.attributeList = []
        self.selectedAttributes = []
        self.classAttribute = None
        self.loadSettings()

        OWGUI.listBox(self.controlArea, self, "selectedAttributes",
                      "attributeList",
                      box="Selected attributes",
                      selectionMode=QListWidget.ExtendedSelection)

        OWGUI.separator(self.controlArea)
        self.classAttrCombo = OWGUI.comboBox(
            self.controlArea, self, "classAttribute",
            box="Class attribute")

        OWGUI.separator(self.controlArea)
        OWGUI.button(self.controlArea, self, "Commit",
                     callback=self.outputData)

        self.resize(150,400)
Ejemplo n.º 2
0
    def __init__(self, parent=None):
        OWWidget.__init__(self, parent, title='Listbox')

        self.colors = ["Red", "Green", "Blue"]
        self.chosenColor = [2]
        self.numbers = ["One", "Two", "Three", "Four"]
        self.chosenNumbers = [0, 2, 3]

        OWGUI.listBox(self.controlArea,
                      self,
                      "chosenColor",
                      "colors",
                      box="Color",
                      callback=self.checkAll)
        OWGUI.listBox(self.controlArea,
                      self,
                      "chosenNumbers",
                      "numbers",
                      box="Number",
                      selectionMode=QListWidget.MultiSelection,
                      callback=self.checkAll)

        OWGUI.separator(self.controlArea)

        box = OWGUI.widgetBox(self.controlArea, "Debug info")
        OWGUI.label(box, self, "Color: %(chosenColor)s")
        OWGUI.label(box, self, "Numbers: %(chosenNumbers)s", labelWidth=100)

        self.setFixedSize(110, 280)
Ejemplo n.º 3
0
    def __init__(self, parent=None):
        OWWidget.__init__(self, parent, title='Listbox')

        self.attributes = []
        self.chosenAttribute = []
        self.values = []
        self.chosenValues = []

        OWGUI.listBox(self.controlArea,
                      self,
                      "chosenAttribute",
                      "attributes",
                      box="Attributes",
                      callback=self.setValues)
        OWGUI.separator(self.controlArea)
        OWGUI.listBox(self.controlArea,
                      self,
                      "chosenValues",
                      "values",
                      box="Values",
                      selectionMode=QListWidget.MultiSelection)

        self.controlArea.setFixedSize(150, 250)
        self.adjustSize()

        # The following assignments usually don't take place in __init__
        # but later on, when the widget receives some data
        import orange
        self.data = orange.ExampleTable(r"..\datasets\horse-colic.tab")
        self.attributes = [(attr.name, attr.varType)
                           for attr in self.data.domain]
        self.chosenAttribute = [0]
Ejemplo n.º 4
0
    def createShowHiddenLists(self, placementTab, callback = None):
        maxWidth = 180
        self.updateCallbackFunction = callback
        self.shownAttributes = []
        self.selectedShown = []
        self.hiddenAttributes = []
        self.selectedHidden = []

        self.shownAttribsGroup = OWGUI.widgetBox(placementTab, " Shown attributes " )
        self.addRemoveGroup = OWGUI.widgetBox(placementTab, 1, orientation = "horizontal" )
        self.hiddenAttribsGroup = OWGUI.widgetBox(placementTab, " Hidden attributes ")

        hbox = OWGUI.widgetBox(self.shownAttribsGroup, orientation = 'horizontal')
        self.shownAttribsLB = OWGUI.listBox(hbox, self, "selectedShown", "shownAttributes", callback = self.resetAttrManipulation, dragDropCallback = callback, enableDragDrop = 1, selectionMode = QListWidget.ExtendedSelection)
        #self.shownAttribsLB.setMaximumWidth(maxWidth)
        vbox = OWGUI.widgetBox(hbox, orientation = 'vertical')
        self.buttonUPAttr   = OWGUI.button(vbox, self, "", callback = self.moveAttrUP, tooltip="Move selected attributes up")
        self.buttonDOWNAttr = OWGUI.button(vbox, self, "", callback = self.moveAttrDOWN, tooltip="Move selected attributes down")
        self.buttonUPAttr.setIcon(QIcon(os.path.join(self.widgetDir, "icons/Dlg_up3.png")))
        self.buttonUPAttr.setSizePolicy(QSizePolicy(QSizePolicy.Fixed , QSizePolicy.Expanding))
        self.buttonUPAttr.setMaximumWidth(30)
        self.buttonDOWNAttr.setIcon(QIcon(os.path.join(self.widgetDir, "icons/Dlg_down3.png")))
        self.buttonDOWNAttr.setSizePolicy(QSizePolicy(QSizePolicy.Fixed , QSizePolicy.Expanding))
        self.buttonDOWNAttr.setMaximumWidth(30)

        self.attrAddButton =    OWGUI.button(self.addRemoveGroup, self, "", callback = self.addAttribute, tooltip="Add (show) selected attributes")
        self.attrAddButton.setIcon(QIcon(os.path.join(self.widgetDir, "icons/Dlg_up3.png")))
        self.attrRemoveButton = OWGUI.button(self.addRemoveGroup, self, "", callback = self.removeAttribute, tooltip="Remove (hide) selected attributes")
        self.attrRemoveButton.setIcon(QIcon(os.path.join(self.widgetDir, "icons/Dlg_down3.png")))
        self.showAllCB = OWGUI.checkBox(self.addRemoveGroup, self, "showAllAttributes", "Show all", callback = self.cbShowAllAttributes)

        self.hiddenAttribsLB = OWGUI.listBox(self.hiddenAttribsGroup, self, "selectedHidden", "hiddenAttributes", callback = self.resetAttrManipulation, dragDropCallback = callback, enableDragDrop = 1, selectionMode = QListWidget.ExtendedSelection)
Ejemplo n.º 5
0
    def __init__(self, parent = None, signalManager = None, name = "Merge data"):
        OWWidget.__init__(self, parent, signalManager, name)  #initialize base class

        # set channels
        self.inputs = [("Examples A", ExampleTable, self.onDataAInput), ("Examples B", ExampleTable, self.onDataBInput)]
        self.outputs = [("Merged Examples A+B", ExampleTable), ("Merged Examples B+A", ExampleTable)]

        # data
        self.dataA = None
        self.dataB = None
        self.varListA = []
        self.varListB = []
        self.varA = None
        self.varB = None
        self.lbAttrAItems = []
        self.lbAttrBItems = []


        # load settings
        self.loadSettings()
        
        # GUI
        w = QWidget(self)
        self.controlArea.layout().addWidget(w)
        grid = QGridLayout()
        grid.setMargin(0)
        w.setLayout(grid)

        # attribute A
        boxAttrA = OWGUI.widgetBox(self, 'Attribute A', orientation = "vertical", addToLayout=0)
        grid.addWidget(boxAttrA, 0,0)
        self.lbAttrA = OWGUI.listBox(boxAttrA, self, "lbAttrAItems", callback = self.lbAttrAChange)

        # attribute  B
        boxAttrB = OWGUI.widgetBox(self, 'Attribute B', orientation = "vertical", addToLayout=0)
        grid.addWidget(boxAttrB, 0,1)
        self.lbAttrB = OWGUI.listBox(boxAttrB, self, "lbAttrBItems", callback = self.lbAttrBChange)

        # info A
        boxDataA = OWGUI.widgetBox(self, 'Data A', orientation = "vertical", addToLayout=0)
        grid.addWidget(boxDataA, 1,0)
        self.lblDataAExamples = OWGUI.widgetLabel(boxDataA, "num examples")
        self.lblDataAAttributes = OWGUI.widgetLabel(boxDataA, "num attributes")

        # info B
        boxDataB = OWGUI.widgetBox(self, 'Data B', orientation = "vertical", addToLayout=0)
        grid.addWidget(boxDataB, 1,1)
        self.lblDataBExamples = OWGUI.widgetLabel(boxDataB, "num examples")
        self.lblDataBAttributes = OWGUI.widgetLabel(boxDataB, "num attributes")

        # general Info
        boxDataB = OWGUI.widgetBox(self, 'Info', orientation = "vertical", addToLayout=0)
        grid.addWidget(boxDataB, 2,0,1,2)
        self.generalInfo = OWGUI.widgetLabel(boxDataB, "The meta attributes will be present at the output table as regular attributes.")

        # icons
        self.icons = self.createAttributeIconDict()

        # resize
        self.resize(400,500)
Ejemplo n.º 6
0
    def __init__(self,parent=None, signalManager = None, name = "Impute"):
        OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0)

        self.inputs = [("Examples", ExampleTable, self.setData, Default), ("Learner for Imputation", orange.Learner, self.setModel)]
        self.outputs = [("Examples", ExampleTable), ("Imputer", orange.ImputerConstructor)]

        self.attrIcons = self.createAttributeIconDict()

        self.defaultMethod = 0
        self.selectedAttr = 0
        self.indiType = 0
        self.imputeClass = 0
        self.autosend = 1
        self.methods = {}
        self.dataChanged = False

        self.model = self.data = None

        self.indiValue = ""
        self.indiValCom = 0

        self.loadSettings()

        self.controlArea.layout().setSpacing(8)
        bgTreat = OWGUI.radioButtonsInBox(self.controlArea, self, "defaultMethod", self.defaultMethods, "Default imputation method", callback=self.sendIf)

        self.indibox = OWGUI.widgetBox(self.controlArea, "Individual attribute settings", "horizontal")

        attrListBox = OWGUI.widgetBox(self.indibox)
        self.attrList = OWGUI.listBox(attrListBox, self, callback = self.individualSelected)
        self.attrList.setMinimumWidth(220)
        self.attrList.setItemDelegate(ImputeListItemDelegate(self, self.attrList))

        indiMethBox = OWGUI.widgetBox(self.indibox)
        indiMethBox.setFixedWidth(160)
        self.indiButtons = OWGUI.radioButtonsInBox(indiMethBox, self, "indiType", ["Default (above)", "Don't impute", "Avg/Most frequent", "Model-based", "Random", "Remove examples", "Value"], 1, callback=self.indiMethodChanged)
        self.indiValueCtrlBox = OWGUI.indentedBox(self.indiButtons)

        self.indiValueLineEdit = OWGUI.lineEdit(self.indiValueCtrlBox, self, "indiValue", callback = self.lineEditChanged)
        #self.indiValueLineEdit.hide()
        valid = QDoubleValidator(self)
        valid.setRange(-1e30, 1e30, 10)
        self.indiValueLineEdit.setValidator(valid)

        self.indiValueComboBox = OWGUI.comboBox(self.indiValueCtrlBox, self, "indiValCom", callback = self.valueComboChanged)
        self.indiValueComboBox.hide()
        OWGUI.rubber(indiMethBox)
        self.btAllToDefault = OWGUI.button(indiMethBox, self, "Set All to Default", callback = self.allToDefault)

        box = OWGUI.widgetBox(self.controlArea, "Class Imputation")
        self.cbImputeClass = OWGUI.checkBox(box, self, "imputeClass", "Impute class values", callback=self.sendIf)

        snbox = OWGUI.widgetBox(self.controlArea, self, "Send data and imputer")
        self.btApply = OWGUI.button(snbox, self, "Apply", callback=self.sendDataAndImputer)
        OWGUI.checkBox(snbox, self, "autosend", "Send automatically", callback=self.enableAuto, disables = [(-1, self.btApply)])

        self.individualSelected(self.selectedAttr)
        self.btApply.setDisabled(self.autosend)
        self.setBtAllToDefault()
        self.resize(200,200)
Ejemplo n.º 7
0
    def __init__(self, parentWidget = None, attr = "", valueList = []):
        OWBaseWidget.__init__(self, None, None, "Sort Attribute Values", modal = TRUE)

        self.setLayout(QVBoxLayout())
        #self.space = QWidget(self)
        #self.layout = QVBoxLayout(self, 4)
        #self.layout.addWidget(self.space)

        box1 = OWGUI.widgetBox(self, "Select Value Order for Attribute \"" + attr + '"', orientation = "horizontal")

        self.attributeList = OWGUI.listBox(box1, self, selectionMode = QListWidget.ExtendedSelection, enableDragDrop = 1)
        self.attributeList.addItems(valueList)

        vbox = OWGUI.widgetBox(box1, "", orientation = "vertical")
        self.buttonUPAttr   = OWGUI.button(vbox, self, "", callback = self.moveAttrUP, tooltip="Move selected attribute values up")
        self.buttonDOWNAttr = OWGUI.button(vbox, self, "", callback = self.moveAttrDOWN, tooltip="Move selected attribute values down")
        self.buttonUPAttr.setIcon(QIcon(os.path.join(self.widgetDir, "icons/Dlg_up3.png")))
        self.buttonUPAttr.setSizePolicy(QSizePolicy(QSizePolicy.Fixed , QSizePolicy.Expanding))
        self.buttonUPAttr.setFixedWidth(40)
        self.buttonDOWNAttr.setIcon(QIcon(os.path.join(self.widgetDir, "icons/Dlg_down3.png")))
        self.buttonDOWNAttr.setSizePolicy(QSizePolicy(QSizePolicy.Fixed , QSizePolicy.Expanding))
        self.buttonDOWNAttr.setFixedWidth(40)

        box2 = OWGUI.widgetBox(self, 1, orientation = "horizontal")
        self.okButton =     OWGUI.button(box2, self, "OK", callback = self.accept)
        self.cancelButton = OWGUI.button(box2, self, "Cancel", callback = self.reject)

        self.resize(300, 300)
Ejemplo n.º 8
0
 def __init__(self, parent, rgbColors):
     OWBaseWidget.__init__(self, None, None, "Palette Editor", modal = 1)
     self.setLayout(QVBoxLayout(self))
     self.layout().setMargin(4)
     
     hbox = OWGUI.widgetBox(self, "Information" , orientation = 'horizontal')
     OWGUI.widgetLabel(hbox, '<p align="center">You can reorder colors in the list using the<br>buttons on the right or by dragging and dropping the items.<br>To change a specific color double click the item in the list.</p>')
     
     hbox = OWGUI.widgetBox(self, 1, orientation = 'horizontal')
     self.discListbox = OWGUI.listBox(hbox, self, enableDragDrop = 1)
     
     vbox = OWGUI.widgetBox(hbox, orientation = 'vertical')
     buttonUPAttr   = OWGUI.button(vbox, self, "", callback = self.moveAttrUP, tooltip="Move selected colors up")
     buttonDOWNAttr = OWGUI.button(vbox, self, "", callback = self.moveAttrDOWN, tooltip="Move selected colors down")
     buttonUPAttr.setIcon(QIcon(os.path.join(self.widgetDir, "icons/Dlg_up3.png")))
     buttonUPAttr.setSizePolicy(QSizePolicy(QSizePolicy.Fixed , QSizePolicy.Expanding))
     buttonUPAttr.setMaximumWidth(30)
     buttonDOWNAttr.setIcon(QIcon(os.path.join(self.widgetDir, "icons/Dlg_down3.png")))
     buttonDOWNAttr.setSizePolicy(QSizePolicy(QSizePolicy.Fixed , QSizePolicy.Expanding))
     buttonDOWNAttr.setMaximumWidth(30)
     self.connect(self.discListbox, SIGNAL("itemDoubleClicked ( QListWidgetItem *)"), self.changeDiscreteColor)
     
     box = OWGUI.widgetBox(self, 1, orientation = "horizontal")
     OWGUI.button(box, self, "OK", self.accept)
     OWGUI.button(box, self, "Cancel", self.reject)
             
     self.discListbox.setIconSize(QSize(25, 25))
     for ind, (r,g,b) in enumerate(rgbColors):
         item = QListWidgetItem(ColorPixmap(QColor(r,g,b), 25), "Color %d" % (ind+1))
         item.rgbColor = (r,g,b)
         self.discListbox.addItem(item)
         
     self.resize(300, 300)
    def __init__(self, parent=None, signalManager=None, title="Multiple Correspondence Analysis"):
        OWCorrespondenceAnalysis.__init__(self, parent, signalManager, title)
        
        self.inputs = [("Data", ExampleTable, self.setData)]
        self.outputs = [("Selected Data", ExampleTable), ("Remaining Data", ExampleTable)]
        
#        self.allAttrs = []
        self.allAttributes = []
        self.selectedAttrs = []
        
        #  GUI
        
        #  Hide the row and column attributes combo boxes
        self.colAttrCB.box.hide()
        self.rowAttrCB.box.hide()
        
        box = OWGUI.widgetBox(self.graphTab, "Attributes", addToLayout=False)
        self.graphTab.layout().insertWidget(0, box)
        self.graphTab.layout().insertSpacing(1, 4)
        
        self.attrsListBox = OWGUI.listBox(box, self, "selectedAttrs", "allAttributes", 
                                          tooltip="Attributes to include in the analysis",
                                          callback=self.runCA,
                                          selectionMode=QListWidget.ExtendedSelection,
                                          )
        
        # Find and hide the "Percent of Column Points" box
        boxes = self.graphTab.findChildren(QGroupBox)
        boxes = [box for box in boxes if str(box.title()).strip() == "Percent of Column Points"]
        if boxes:
            boxes[0].hide()
Ejemplo n.º 10
0
    def init_addon_selection_page(self):
        self.addon_selection_page = page = QWizardPage()
        page.setTitle("Add-on Selection")
        page.setLayout(QVBoxLayout())
        self.addPage(page)
        import os

        p = OWGUI.widgetBox(page,
                            "Select a registered add-on to pack",
                            orientation="horizontal")
        self.aolist = OWGUI.listBox(p,
                                    self,
                                    callback=self.list_selection_callback)
        self.registered_addons = Orange.misc.addons.registered_addons
        for ao in self.registered_addons:
            self.aolist.addItem(ao.name)
        pbtn = OWGUI.widgetBox(p, orientation="vertical")
        btn_custom_location = OWGUI.button(
            pbtn,
            self,
            "Custom Location...",
            callback=self.select_custom_location)
        pbtn.layout().addStretch(1)

        self.directory = ""
        self.e_directory = OWGUI.lineEdit(
            page,
            self,
            "directory",
            label="Add-on directory: ",
            callback=self.directory_change_callback,
            callbackOnType=True)
        page.isComplete = lambda page: os.path.isdir(
            os.path.join(self.directory, "widgets"))
Ejemplo n.º 11
0
    def defineGUI(self):
        # methods Selection
        self.methodsListBox = OWGUI.listBox(
            self.controlArea,
            self,
            "selectedMethods",
            "methodsList",
            box="Select Chemical Similarity Methods",
            selectionMode=QListWidget.ExtendedSelection,
        )
        # Set location of model file
        boxFile = OWGUI.widgetBox(self.controlArea, "Path for loading Actives", addSpace=True, orientation=0)
        L1 = OWGUI.lineEdit(
            boxFile,
            self,
            "activesFile",
            labelWidth=80,
            orientation="horizontal",
            tooltip="Actives must be specified in a .smi file",
        )
        L1.setMinimumWidth(200)
        button = OWGUI.button(
            boxFile, self, "...", callback=self.browseFile, disabled=0, tooltip="Browse for a file to load the Actives"
        )
        button.setMaximumWidth(25)

        # Load Actives
        OWGUI.button(boxFile, self, "Load Actives", callback=self.loadActives)

        # Start descriptors calculation
        OWGUI.button(self.controlArea, self, "Calculate descriptors", callback=self.calcDesc)

        self.adjustSize()
Ejemplo n.º 12
0
    def __init__(self, parentWidget = None, attr = "", valueList = []):
        OWBaseWidget.__init__(self, None, None, "Sort Attribute Values", modal = TRUE)

        self.setLayout(QVBoxLayout())
        #self.space = QWidget(self)
        #self.layout = QVBoxLayout(self, 4)
        #self.layout.addWidget(self.space)

        box1 = OWGUI.widgetBox(self, "Select Value Order for Attribute \"" + attr + '"', orientation = "horizontal")

        self.attributeList = OWGUI.listBox(box1, self, selectionMode = QListWidget.ExtendedSelection, enableDragDrop = 1)
        self.attributeList.addItems(valueList)

        vbox = OWGUI.widgetBox(box1, "", orientation = "vertical")
        self.buttonUPAttr   = OWGUI.button(vbox, self, "", callback = self.moveAttrUP, tooltip="Move selected attribute values up")
        self.buttonDOWNAttr = OWGUI.button(vbox, self, "", callback = self.moveAttrDOWN, tooltip="Move selected attribute values down")
        self.buttonUPAttr.setIcon(QIcon(os.path.join(self.widgetDir, "icons/Dlg_up3.png")))
        self.buttonUPAttr.setSizePolicy(QSizePolicy(QSizePolicy.Fixed , QSizePolicy.Expanding))
        self.buttonUPAttr.setFixedWidth(40)
        self.buttonDOWNAttr.setIcon(QIcon(os.path.join(self.widgetDir, "icons/Dlg_down3.png")))
        self.buttonDOWNAttr.setSizePolicy(QSizePolicy(QSizePolicy.Fixed , QSizePolicy.Expanding))
        self.buttonDOWNAttr.setFixedWidth(40)

        box2 = OWGUI.widgetBox(self, 1, orientation = "horizontal")
        self.okButton =     OWGUI.button(box2, self, "OK", callback = self.accept)
        self.cancelButton = OWGUI.button(box2, self, "Cancel", callback = self.reject)

        self.resize(300, 300)
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self,parent,signalManager,"FeatureSelection")
        self.inputs = [("Example Table", ExampleTable, self.dataset)]
        self.outputs = [("Example Table", ExampleTable)]

        warnings.filterwarnings("ignore", "", orange.AttributeWarning)
        
        self.data = None
        self.chosenMeasure = [0]
        self.measures = ['Term frequency', 'Random', 'Term document frequency', 'Word frequency', 'Number of features']
        self.chosenOp = [0]
        self.measureDict = {0: 'TF', 1: 'RAND', 2: 'TDF', 3: 'WF', 4: 'NF'}
        self.operators = ['MIN', 'MAX']
        self.tmpData = None
        self.perc = 1
        self.threshold = 90
        self.selections = []

        #GUI
        #ca=QFrame(self.controlArea)
        #gl=QGridLayout(ca)
        selectionbox = OWGUI.widgetBox(self.controlArea, "Feature selection", "horizontal") #OWGUI.QHGroupBox('Feature selection', self.controlArea)

        OWGUI.listBox(selectionbox, self, 'chosenMeasure', 'measures', box = 'Select measure', callback = self.selectionChanged)
        OWGUI.listBox(selectionbox, self, 'chosenOp', 'operators', box = 'Select operator', callback = self.selectionChanged)

        boxAttrStat = OWGUI.widgetBox(self.controlArea, "Statistics for features") #QVGroupBox("Statistics for features", self.controlArea)
        self.lblFeatNo = OWGUI.widgetLabel(boxAttrStat, "No. of features: ") #QLabel("No. of features: ", boxAttrStat)
        self.lblMin = OWGUI.widgetLabel(boxAttrStat, "Min: ") #QLabel("Min: ", boxAttrStat)
        self.lblAvg = OWGUI.widgetLabel(boxAttrStat, "Avg: ") #QLabel("Avg: ", boxAttrStat)
        self.lblMax = OWGUI.widgetLabel(boxAttrStat, "Max: ") #QLabel("Max: ", boxAttrStat)

        boxDocStat = OWGUI.widgetBox(self.controlArea, "Statistics for documents") #QVGroupBox("Statistics for documents", self.controlArea)
        self.lblDocNo = OWGUI.widgetLabel(boxDocStat, "No. of documents: ") #QLabel("No. of documents: ", boxDocStat)
        self.lblDocAvg = OWGUI.widgetLabel(boxDocStat, "Avg: ") #QLabel("Avg: ", boxDocStat)
        self.lblDocMax = OWGUI.widgetLabel(boxDocStat, "Max: ") #QLabel("Max: ", boxDocStat)
        self.lblDocMin = OWGUI.widgetLabel(boxDocStat, "Min: ") #QLabel("Min: ", boxDocStat)

        optionBox = OWGUI.widgetBox(selectionbox, "") #OWGUI.QVGroupBox('', selectionbox)        

        self.applyButton = OWGUI.button(optionBox, self, "Apply", self.apply)
        self.applyButton.setDisabled(1)
        OWGUI.checkBox(optionBox, self, "perc", "percentage", callback = self.selectionChanged)
        #OWGUI.spin(optionBox, self, "threshold", 0, 10000, label="Threshold:", callback = None)
        OWGUI.lineEdit(optionBox, self, "threshold", orientation="horizontal", valueType=float, box="Threshold", callback = self.selectionChanged)
        OWGUI.rubber(self.controlArea)
        self.controlArea.adjustSize()
    def __init__(self,parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "Confusion Matrix", 1)

        # inputs
        self.inputs=[("Evaluation Results", orngTest.ExperimentResults, self.setTestResults, Default)]
        self.outputs=[("Selected Data", ExampleTable, 8)]

        self.selectedLearner = []
        self.learnerNames = []
        self.selectionDirty = 0
        self.autoApply = True
        self.appendPredictions = True
        self.appendProbabilities = False
        self.shownQuantity = 0

        self.learnerList = OWGUI.listBox(self.controlArea, self, "selectedLearner", "learnerNames", box = "Learners", callback = self.learnerChanged)
        self.learnerList.setMinimumHeight(100)
        
        OWGUI.separator(self.controlArea)

        OWGUI.comboBox(self.controlArea, self, "shownQuantity", items = self.quantities, box = "Show", callback=self.reprint)

        OWGUI.separator(self.controlArea)
        
        box = OWGUI.widgetBox(self.controlArea, "Selection") #, addSpace=True)
        OWGUI.button(box, self, "Correct", callback=self.selectCorrect)
        OWGUI.button(box, self, "Misclassified", callback=self.selectWrong)
        OWGUI.button(box, self, "None", callback=self.selectNone)
        
        OWGUI.separator(self.controlArea)

        self.outputBox = box = OWGUI.widgetBox(self.controlArea, "Output")
        OWGUI.checkBox(box, self, "appendPredictions", "Append class predictions", callback = self.sendIf)
        OWGUI.checkBox(box, self, "appendProbabilities", "Append predicted class probabilities", callback = self.sendIf)
        applyButton = OWGUI.button(box, self, "Commit", callback = self.sendData, default=True)
        autoApplyCB = OWGUI.checkBox(box, self, "autoApply", "Commit automatically")
        OWGUI.setStopper(self, applyButton, autoApplyCB, "selectionDirty", self.sendData)

        import sip
        sip.delete(self.mainArea.layout())
        self.layout = QGridLayout(self.mainArea)

        self.layout.addWidget(OWGUI.widgetLabel(self.mainArea, "Prediction"), 0, 1, Qt.AlignCenter)
        
        label = TransformedLabel("Correct Class")
        self.layout.addWidget(label, 2, 0, Qt.AlignCenter)
#        self.layout.addWidget(OWGUI.widgetLabel(self.mainArea, "Correct Class  "), 2, 0, Qt.AlignCenter)
        self.table = OWGUI.table(self.mainArea, rows = 0, columns = 0, selectionMode = QTableWidget.MultiSelection, addToLayout = 0)
        self.layout.addWidget(self.table, 2, 1)
        self.layout.setColumnStretch(1, 100)
        self.layout.setRowStretch(2, 100)
        self.connect(self.table, SIGNAL("itemSelectionChanged()"), self.sendIf)
        
        self.res = None
        self.matrix = None
        self.selectedLearner = None
        self.resize(700,450)
Ejemplo n.º 15
0
    def __init__(self, parent=None):
        OWWidget.__init__(self, parent, title='Listbox')

        self.colors = ["Red", "Green", "Blue"]
        self.chosenColor = [2]
        self.numbers = ["One", "Two", "Three", "Four"]
        self.chosenNumbers = [0, 2, 3]

        OWGUI.listBox(self.controlArea, self, "chosenColor", "colors", box="Color", callback=self.checkAll)
        OWGUI.listBox(self.controlArea, self, "chosenNumbers", "numbers", box="Number", selectionMode=QListWidget.MultiSelection, callback=self.checkAll)

        OWGUI.separator(self.controlArea)
        
        box = OWGUI.widgetBox(self.controlArea, "Debug info")
        OWGUI.label(box, self, "Color: %(chosenColor)s")
        OWGUI.label(box, self, "Numbers: %(chosenNumbers)s", labelWidth=100)

        self.setFixedSize(110, 280)
Ejemplo n.º 16
0
    def __init__(self,parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "Calibration Plot", 1)

        # inputs
        self.inputs=[("Evaluation Results", orngTest.ExperimentResults, self.results, Default)]

        #set default settings
        self.CalibrationCurveWidth = 3
        self.ShowDiagonal = TRUE
        self.ShowRugs = TRUE
        #load settings
        self.loadSettings()

        # temp variables
        self.dres = None
        self.targetClass = None
        self.numberOfClasses = 0
        self.graphs = []
        self.classifierColor = None
        self.numberOfClassifiers = 0
        self.classifiers = []
        self.selectedClassifiers = []

        # GUI
        import sip
        sip.delete(self.mainArea.layout())
        self.graphsGridLayoutQGL = QGridLayout(self.mainArea)
        self.mainArea.setLayout(self.graphsGridLayoutQGL)

        ## save each ROC graph in separate file
        self.graph = None
        self.connect(self.graphButton, SIGNAL("clicked()"), self.saveToFile)

        ## general tab
        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.generalTab = OWGUI.createTabPage(self.tabs, "General")
        self.settingsTab = OWGUI.createTabPage(self.tabs, "Settings")

        self.splitQS = QSplitter()
        self.splitQS.setOrientation(Qt.Vertical)

        ## target class
        self.classCombo = OWGUI.comboBox(self.generalTab, self, 'targetClass', box='Target class', items=[], callback=self.target)
        OWGUI.separator(self.generalTab)

        ## classifiers selection (classifiersQLB)
        self.classifiersQVGB = OWGUI.widgetBox(self.generalTab, "Classifiers")
        self.classifiersQLB = OWGUI.listBox(self.classifiersQVGB, self, "selectedClassifiers", selectionMode = QListWidget.MultiSelection, callback = self.classifiersSelectionChange)
        self.unselectAllClassifiersQLB = OWGUI.button(self.classifiersQVGB, self, "(Un)select all", callback = self.SUAclassifiersQLB)

        ## settings tab
        OWGUI.hSlider(self.settingsTab, self, 'CalibrationCurveWidth', box='Calibration Curve Width', minValue=1, maxValue=9, step=1, callback=self.setCalibrationCurveWidth, ticks=1)
        OWGUI.checkBox(self.settingsTab, self, 'ShowDiagonal', 'Show Diagonal Line', tooltip='', callback=self.setShowDiagonal)
        OWGUI.checkBox(self.settingsTab, self, 'ShowRugs', 'Show Rugs', tooltip='', callback=self.setShowRugs)
        self.settingsTab.layout().addStretch(100)
Ejemplo n.º 17
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, "FeatureConstructor")

        self.inputs = [("Data", orange.ExampleTable, self.setData)]
        self.outputs = [("Data", ExampleTable)]

        self.expression = self.attrname = ""
        self.selected_def = []
        self.def_labels = []
        self.data = None
        self.definitions = []

        self.selected_features = 0
        self.selectedFunc = 0
        self.autosend = True
        self.loadSettings()

        db = OWGUI.widgetBox(self.controlArea, "Attribute definitions", addSpace=True)

        hb = OWGUI.widgetBox(db, None, "horizontal")
        hbv = OWGUI.widgetBox(hb)
        self.leAttrName = OWGUI.lineEdit(hbv, self, "attrname", "New attribute")
        OWGUI.rubber(hbv)
        vb = OWGUI.widgetBox(hb, None, "vertical", addSpace=True)
        self.leExpression = OWGUI.lineEdit(vb, self, "expression", "Expression")
        hhb = OWGUI.widgetBox(vb, None, "horizontal")
        self.cbAttrs = OWGUI.comboBox(
            hhb, self, "selected_features", items=["(all attributes)"], callback=self.feature_list_selected
        )
        sortedFuncs = sorted(m for m in AttrComputer.FUNCTIONS.keys())
        self.cbFuncs = OWGUI.comboBox(
            hhb, self, "selectedFunc", items=["(all functions)"] + sortedFuncs, callback=self.funcListSelected
        )
        model = self.cbFuncs.model()
        for i, func in enumerate(sortedFuncs):
            model.item(i + 1).setToolTip(inspect.getdoc(AttrComputer.FUNCTIONS[func]))

        hb = OWGUI.widgetBox(db, None, "horizontal", addSpace=True)
        OWGUI.button(hb, self, "Add", callback=self.addAttr, autoDefault=True)
        OWGUI.button(hb, self, "Update", callback=self.updateAttr)
        OWGUI.button(hb, self, "Remove", callback=self.remove_feature)
        OWGUI.button(hb, self, "Remove All", callback=self.remove_all_features)

        self.lbDefinitions = OWGUI.listBox(db, self, "selected_def", "def_labels", callback=self.select_feature)
        self.lbDefinitions.setFixedHeight(160)

        hb = OWGUI.widgetBox(self.controlArea, "Apply", "horizontal")
        OWGUI.button(hb, self, "Apply", callback=self.apply)
        cb = OWGUI.checkBox(hb, self, "autosend", "Apply automatically", callback=self.enableAuto)
        cb.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))

        self.adjustSize()
Ejemplo n.º 18
0
    def __init__(self, parent=None):
		OWWidget.__init__(self, parent, title='Line Edit as Filter')
		
		self.filter = ""
		self.listboxValue = ""
		lineEdit = OWGUIEx.lineEditFilter(self.controlArea, self, "filter", "Filter:", useRE = 1, emptyText = "filter...")
		    
		lineEdit.setListBox(OWGUI.listBox(self.controlArea, self, "listboxValue"))
		names = []
		for i in range(10000):
		    names.append("".join([string.ascii_lowercase[random.randint(0, len(string.ascii_lowercase)-1)] for c in range(10)]))
		lineEdit.listbox.addItems(names)
		lineEdit.setAllListItems(names)
Ejemplo n.º 19
0
    def __init__(self, parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "Predictions")

        self.callbackDeposit = []
        self.inputs = [("Examples", ExampleTable, self.setData), ("Predictors", orange.Classifier, self.setPredictor, Multiple)]
        self.outputs = [("Predictions", ExampleTable)]
        self.predictors = {}

        # saveble settings
        self.ShowAttributeMethod = 0
        self.classes = []
        self.selectedClasses = []
        self.loadSettings()
        self.datalabel = "N/A"
        self.predictorlabel = "N/A"
        self.tasklabel = "N/A"
        self.outvar = None # current output variable (set by the first predictor/data set send in)
        self.classifications = []
        self.rindx = None        
        self.data = None
        self.verbose = 0
        self.nVarImportance = 0

        # GUI - Options

        # Options - classification
        ibox = OWGUI.widgetBox(self.controlArea, "Info")
        OWGUI.label(ibox, self, "Data: %(datalabel)s")
        OWGUI.label(ibox, self, "Predictors: %(predictorlabel)s")
        OWGUI.label(ibox, self, "Task: %(tasklabel)s")
        OWGUI.separator(ibox)
        OWGUI.label(ibox, self, "Predictions can be viewed with the 'Data Table'\nand saved with the 'Save' widget!")

        OWGUI.separator(self.controlArea)
        
        self.copt = OWGUI.widgetBox(self.controlArea,"Probabilities (classification)")
        self.copt.setDisabled(1)

        self.lbcls = OWGUI.listBox(self.copt, self, "selectedClasses", "classes",
                                   selectionMode=QListWidget.MultiSelection)
        self.lbcls.setFixedHeight(50)
        OWGUI.separator(self.controlArea)
        self.VarImportanceBox = OWGUI.doubleSpin(self.controlArea, self, "nVarImportance", 0,9999999,1, label="Variable importance",  orientation="horizontal", tooltip="The number of variables to report for each prediction.")

        OWGUI.checkBox(self.controlArea, self, 'verbose', 'Verbose', tooltip='Show detailed info while predicting. This will slow down the predictions process!') 
        OWGUI.separator(self.controlArea)
        self.outbox = OWGUI.widgetBox(self.controlArea,"Output")
        self.apply = OWGUI.button(self.outbox, self, "Apply", callback=self.sendpredictions)

        OWGUI.rubber(self.controlArea)
        self.adjustSize()
Ejemplo n.º 20
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, "Pubmed Network View", wantMainArea=0)

        self.inputs = []
        self.outputs = [("Nx View", Orange.network.NxView)]

        self._nhops = 2
        self._edge_threshold = 0.5
        self._n_max_neighbors = 20
        self.selected_titles = []
        self.titles = []
        self.filter = ""
        self.ids = []
        self._selected_nodes = []
        self._algorithm = 0
        self._k_algorithm = 0.3

        self.loadSettings()

        box = OWGUI.widgetBox(self.controlArea, "Paper Selection", orientation="vertical")
        OWGUI.lineEdit(box, self, "filter", callback=self.filter_list, callbackOnType=True)
        self.list_titles = OWGUI.listBox(
            box, self, "selected_titles", "titles", selectionMode=QListWidget.MultiSelection, callback=self.update_view
        )
        OWGUI.separator(self.controlArea)
        box_pref = OWGUI.widgetBox(self.controlArea, "Preferences", orientation="vertical")
        OWGUI.spin(box_pref, self, "_nhops", 1, 6, 1, label="Number of hops: ", callback=self.update_view)
        OWGUI.spin(
            box_pref, self, "_n_max_neighbors", 1, 100, 1, label="Max number of neighbors: ", callback=self.update_view
        )
        OWGUI.doubleSpin(
            box_pref, self, "_edge_threshold", 0, 1, step=0.01, label="Edge threshold: ", callback=self.update_view
        )
        OWGUI.separator(self.controlArea)
        box_alg = OWGUI.widgetBox(self.controlArea, "Interest Propagation Algorithm", orientation="vertical")
        radio_box = OWGUI.radioButtonsInBox(box_alg, self, "_algorithm", [], callback=self.update_view)
        OWGUI.appendRadioButton(radio_box, self, "_algorithm", "Without Clustering", callback=self.update_view)
        OWGUI.doubleSpin(
            OWGUI.indentedBox(radio_box),
            self,
            "_k_algorithm",
            0,
            1,
            step=0.01,
            label="Parameter k: ",
            callback=self.update_view,
        )
        OWGUI.appendRadioButton(radio_box, self, "_algorithm", "With Clustering", callback=self.update_view)

        self.inside_view = PubmedNetworkView(self)
        self.send("Nx View", self.inside_view)
Ejemplo n.º 21
0
    def __init__(self, parent=None):
        OWWidget.__init__(self, parent, title='Listbox')

        self.attributes = []
        self.chosenAttribute = []
        self.values = []
        self.chosenValues = []

        OWGUI.listBox(self.controlArea, self, "chosenAttribute", "attributes",
                      box="Attributes", callback=self.setValues)
        OWGUI.separator(self.controlArea)
        OWGUI.listBox(self.controlArea, self, "chosenValues", "values",
                      box="Values", selectionMode=QListWidget.MultiSelection)

        self.controlArea.setFixedSize(150, 250)
        self.adjustSize()


        # The following assignments usually don't take place in __init__
        # but later on, when the widget receives some data
        import orange
        self.data = orange.ExampleTable(r"..\datasets\horse-colic.tab")
        self.attributes = [(attr.name, attr.varType) for attr in self.data.domain]
        self.chosenAttribute = [0]
Ejemplo n.º 22
0
    def __init__(self,parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "FeatureConstructor")

        self.inputs = [("Examples", orange.ExampleTable, self.setData)]
        self.outputs = [("Examples", ExampleTable)]

        self.expression = self.attrname = ""
        self.selectedDef = []
        self.defLabels = []
        self.data = None
        self.definitions = []

        self.selectedAttr = 0
        self.selectedFunc = 0
        self.autosend = True
        self.loadSettings()

        db = OWGUI.widgetBox(self.controlArea, "Attribute definitions", addSpace = True)

        hb = OWGUI.widgetBox(db, None, "horizontal")
        hbv = OWGUI.widgetBox(hb)
        self.leAttrName = OWGUI.lineEdit(hbv, self, "attrname", "New attribute")
        OWGUI.rubber(hbv)
        vb = OWGUI.widgetBox(hb, None, "vertical", addSpace=True)
        self.leExpression = OWGUI.lineEdit(vb, self, "expression", "Expression")
        hhb = OWGUI.widgetBox(vb, None, "horizontal")
        self.cbAttrs = OWGUI.comboBox(hhb, self, "selectedAttr", items = ["(all attributes)"], callback = self.attrListSelected)
        sortedFuncs = sorted(m for m in list(AttrComputer.FUNCTIONS.keys()))
        self.cbFuncs = OWGUI.comboBox(hhb, self, "selectedFunc", items = ["(all functions)"] + sortedFuncs, callback = self.funcListSelected)
        model = self.cbFuncs.model()
        for i, func in enumerate(sortedFuncs):
            model.item(i + 1).setToolTip(AttrComputer.FUNCTIONS[func].__doc__)
        
        hb = OWGUI.widgetBox(db, None, "horizontal", addSpace=True)
        OWGUI.button(hb, self, "Add", callback = self.addAttr)
        OWGUI.button(hb, self, "Update", callback = self.updateAttr)
        OWGUI.button(hb, self, "Remove", callback = self.removeAttr)
        OWGUI.button(hb, self, "Remove All", callback = self.removeAllAttr)

        self.lbDefinitions = OWGUI.listBox(db, self, "selectedDef", "defLabels", callback=self.selectAttr)
        self.lbDefinitions.setFixedHeight(160)

        hb = OWGUI.widgetBox(self.controlArea, "Apply", "horizontal")
        OWGUI.button(hb, self, "Apply", callback = self.apply)
        cb = OWGUI.checkBox(hb, self, "autosend", "Apply automatically", callback=self.enableAuto)
        cb.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))

        self.adjustSize()
Ejemplo n.º 23
0
    def init_addon_selection_page(self):
        self.addon_selection_page = page = QWizardPage()
        page.setTitle("Add-on Selection")
        page.setLayout(QVBoxLayout())
        self.addPage( page )
        import os

        p = OWGUI.widgetBox(page, "Select a registered add-on to pack", orientation="horizontal")
        self.aolist = OWGUI.listBox(p, self, callback=self.list_selection_callback)
        self.registered_addons = Orange.misc.addons.registered_addons
        for ao in self.registered_addons:
            self.aolist.addItem(ao.name)
        pbtn = OWGUI.widgetBox(p, orientation="vertical")
        btn_custom_location = OWGUI.button(pbtn, self, "Custom Location...", callback=self.select_custom_location)
        pbtn.layout().addStretch(1)
        
        self.directory = ""
        self.e_directory = OWGUI.lineEdit(page, self, "directory", label="Add-on directory: ", callback=self.directory_change_callback, callbackOnType=True)
        page.isComplete = lambda page: os.path.isdir(os.path.join(self.directory, "widgets"))
    def __init__(self,
                 parent=None,
                 signalManager=None,
                 title="Multiple Correspondence Analysis"):
        OWCorrespondenceAnalysis.__init__(self, parent, signalManager, title)

        self.inputs = [("Data", ExampleTable, self.setData)]
        self.outputs = [("Selected Data", ExampleTable),
                        ("Remaining Data", ExampleTable)]

        #        self.allAttrs = []
        self.allAttributes = []
        self.selectedAttrs = []

        #  GUI

        #  Hide the row and column attributes combo boxes
        self.colAttrCB.box.hide()
        self.rowAttrCB.box.hide()

        box = OWGUI.widgetBox(self.graphTab, "Attributes", addToLayout=False)
        self.graphTab.layout().insertWidget(0, box)
        self.graphTab.layout().insertSpacing(1, 4)

        self.attrsListBox = OWGUI.listBox(
            box,
            self,
            "selectedAttrs",
            "allAttributes",
            tooltip="Attributes to include in the analysis",
            callback=self.runCA,
            selectionMode=QListWidget.ExtendedSelection,
        )

        # Find and hide the "Percent of Column Points" box
        boxes = self.graphTab.findChildren(QGroupBox)
        boxes = [
            box for box in boxes
            if str(box.title()).strip() == "Percent of Column Points"
        ]
        if boxes:
            boxes[0].hide()
Ejemplo n.º 25
0
    def defineGUI(self):
        # methods Selection
        self.methodsListBox = OWGUI.listBox(
            self.controlArea,
            self,
            "selectedMethods",
            "methodsList",
            box="Select Chemical Similarity Methods",
            selectionMode=QListWidget.ExtendedSelection)
        # Set location of model file
        boxFile = OWGUI.widgetBox(self.controlArea,
                                  "Path for loading Actives",
                                  addSpace=True,
                                  orientation=0)
        L1 = OWGUI.lineEdit(boxFile,
                            self,
                            "activesFile",
                            labelWidth=80,
                            orientation="horizontal",
                            tooltip="Actives must be specified in a .smi file")
        L1.setMinimumWidth(200)
        button = OWGUI.button(boxFile,
                              self,
                              '...',
                              callback=self.browseFile,
                              disabled=0,
                              tooltip="Browse for a file to load the Actives")
        button.setMaximumWidth(25)

        # Load Actives
        OWGUI.button(boxFile, self, "Load Actives", callback=self.loadActives)

        # Start descriptors calculation
        OWGUI.button(self.controlArea,
                     self,
                     "Calculate descriptors",
                     callback=self.calcDesc)

        self.adjustSize()
Ejemplo n.º 26
0
    def __init__(self, imgCategory, parent=None, signalManager = None, visible=True):
#==================================
        #get settings from the ini file, if they exist
        #self.loadSettings()
        self.imgCategory = imgCategory
        self.name = self.imgCategory.name
        
        OWImageSubFile.__init__(self, parent, signalManager, "Category "+self.imgCategory.name)

        #set default settings
        self.domain = None
        #GUI
        self.dialogWidth = 250
        buttonWidth = 1.5
        self.recentFiles=["(none)"]
        
        box = OWGUI.widgetBox(self.controlArea, 'Dataset', addSpace = True, orientation=1)
        OWGUI.lineEdit(box, self, "name", "Name of dataset: ", orientation="horizontal", tooltip="The name of the dataset used throughout the training")

        self.widgetFileList = OWGUI.listBox(box, self)
        self.connect(self.widgetFileList, SIGNAL('itemDoubleClicked(QListWidgetItem *)'), self.displayImage)
        self.connect(self.widgetFileList, SIGNAL('itemEntered(QListWidgetItem *)'), self.displayImage)
        self.connect(self.widgetFileList, SIGNAL('itemSelectionChanged()'), self.selectionChanged)
        self.connect(self, SIGNAL('updateParent'), parent.updateCategoryList)
        #OWGUI.connectControl(self.widgetFileList, self, None, self.displayImage, "itemDoubleClicked(*QListWidgetItem)", None, None)

        self.fileButton = OWGUI.button(box, self, 'Add file(s)', callback = self.browseImgFile, disabled=0, width=self.dialogWidth)
        self.dirButton = OWGUI.button(box, self, 'Add directory', callback = self.browseImgDir, disabled=0, width=self.dialogWidth)
        self.removeButton = OWGUI.button(box, self, 'Remove selected file', callback = self.removeFile, disabled=1, width=self.dialogWidth)
        self.applyButton = OWGUI.button(self.controlArea, self, 'OK', callback = self.ok, disabled=0, width=self.dialogWidth)        
        self.inChange = False
        self.resize(self.dialogWidth,300)

        # Add the filenames to the widgetFileList
        self.widgetFileList.addItems(self.imgCategory.fnames)
        if visible:
            self.show()
Ejemplo n.º 27
0
 def __init__(self, parent=None, signalManager=None):
     OWWidget.__init__(self, parent, signalManager, 'Pubmed Network View', wantMainArea=0)
     
     self.inputs = []
     self.outputs = [("Nx View", Orange.network.NxView)]
     
     self._nhops = 2
     self._edge_threshold = 0.5
     self._n_max_neighbors = 20
     self.selected_titles = []
     self.titles = []
     self.filter = ''
     self.ids = []
     self._selected_nodes = []
     self._algorithm = 0
     self._k_algorithm = 0.3
     
     self.loadSettings()
     
     box = OWGUI.widgetBox(self.controlArea, "Paper Selection", orientation="vertical")
     OWGUI.lineEdit(box, self, "filter", callback=self.filter_list, callbackOnType=True)
     self.list_titles = OWGUI.listBox(box, self, "selected_titles", "titles", selectionMode=QListWidget.MultiSelection, callback=self.update_view)
     OWGUI.separator(self.controlArea)
     box_pref = OWGUI.widgetBox(self.controlArea, "Preferences", orientation="vertical")
     OWGUI.spin(box_pref, self, "_nhops", 1, 6, 1, label="Number of hops: ", callback=self.update_view)
     OWGUI.spin(box_pref, self, "_n_max_neighbors", 1, 100, 1, label="Max number of neighbors: ", callback=self.update_view)
     OWGUI.doubleSpin(box_pref, self, "_edge_threshold", 0, 1, step=0.01, label="Edge threshold: ", callback=self.update_view)
     OWGUI.separator(self.controlArea)
     box_alg = OWGUI.widgetBox(self.controlArea, "Interest Propagation Algorithm", orientation="vertical")
     radio_box = OWGUI.radioButtonsInBox(box_alg, self, "_algorithm", [], callback=self.update_view)
     OWGUI.appendRadioButton(radio_box, self, "_algorithm", "Without Clustering", callback=self.update_view)
     OWGUI.doubleSpin(OWGUI.indentedBox(radio_box), self, "_k_algorithm", 0, 1, step=0.01, label="Parameter k: ", callback=self.update_view)
     OWGUI.appendRadioButton(radio_box, self, "_algorithm", "With Clustering", callback=self.update_view)
     
     self.inside_view = PubmedNetworkView(self)
     self.send("Nx View", self.inside_view)
Ejemplo n.º 28
0
    def __init__(self, parent = None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "Data Domain", wantMainArea = 0) 

        self.inputs = [("Examples", ExampleTable, self.setData), ("Attribute Subset", AttributeList, self.setAttributeList)]
        self.outputs = [("Examples", ExampleTable)]

        buttonWidth = 50
        applyButtonWidth = 101

        self.data = None
        self.receivedAttrList = None

        self.selectedInput = []
        self.inputAttributes = []
        self.selectedChosen = []
        self.chosenAttributes = []
        self.selectedClass = []
        self.classAttribute = []
        self.metaAttributes = []
        self.selectedMeta = []

        self.loadSettings()

        import sip
        sip.delete(self.controlArea.layout())
        grid = QGridLayout()
        self.controlArea.setLayout(grid)
        grid.setMargin(0)
                
        boxAvail = OWGUI.widgetBox(self, 'Available Attributes', addToLayout = 0)
        grid.addWidget(boxAvail, 0, 0, 3, 1)

        self.filterInputAttrs = OWGUIEx.lineEditFilter(boxAvail, self, None, useRE = 1, emptyText = "filter attributes...", callback = self.setInputAttributes, caseSensitive = 0)
        self.inputAttributesList = OWGUI.listBox(boxAvail, self, "selectedInput", "inputAttributes", callback = self.onSelectionChange, selectionMode = QListWidget.ExtendedSelection, enableDragDrop = 1, dragDropCallback = self.updateInterfaceAndApplyButton)
        self.filterInputAttrs.listbox = self.inputAttributesList 

        vbAttr = OWGUI.widgetBox(self, addToLayout = 0)
        grid.addWidget(vbAttr, 0, 1)
        self.attributesButtonUp = OWGUI.button(vbAttr, self, "Up", self.onAttributesButtonUpClick)
        self.attributesButtonUp.setMaximumWidth(buttonWidth)
        self.attributesButton = OWGUI.button(vbAttr, self, ">", self.onAttributesButtonClicked)
        self.attributesButton.setMaximumWidth(buttonWidth)
        self.attributesButtonDown = OWGUI.button(vbAttr, self, "Down", self.onAttributesButtonDownClick)
        self.attributesButtonDown.setMaximumWidth(buttonWidth)

        boxAttr = OWGUI.widgetBox(self, 'Attributes', addToLayout = 0)
        grid.addWidget(boxAttr, 0, 2)
        self.attributesList = OWGUI.listBox(boxAttr, self, "selectedChosen", "chosenAttributes", callback = self.onSelectionChange, selectionMode = QListWidget.ExtendedSelection, enableDragDrop = 1, dragDropCallback = self.updateInterfaceAndApplyButton)

        self.classButton = OWGUI.button(self, self, ">", self.onClassButtonClicked, addToLayout = 0)
        self.classButton.setMaximumWidth(buttonWidth)
        grid.addWidget(self.classButton, 1, 1)
        boxClass = OWGUI.widgetBox(self, 'Class', addToLayout = 0)
        boxClass.setFixedHeight(55)
        grid.addWidget(boxClass, 1, 2)
        self.classList = OWGUI.listBox(boxClass, self, "selectedClass", "classAttribute", callback = self.onSelectionChange, selectionMode = QListWidget.ExtendedSelection, enableDragDrop = 1, dragDropCallback = self.updateInterfaceAndApplyButton, dataValidityCallback = self.dataValidityCallback)

        vbMeta = OWGUI.widgetBox(self, addToLayout = 0)
        grid.addWidget(vbMeta, 2, 1)
        self.metaButtonUp = OWGUI.button(vbMeta, self, "Up", self.onMetaButtonUpClick)
        self.metaButtonUp.setMaximumWidth(buttonWidth)
        self.metaButton = OWGUI.button(vbMeta, self, ">", self.onMetaButtonClicked)
        self.metaButton.setMaximumWidth(buttonWidth)
        self.metaButtonDown = OWGUI.button(vbMeta, self, "Down", self.onMetaButtonDownClick)
        self.metaButtonDown.setMaximumWidth(buttonWidth)
        boxMeta = OWGUI.widgetBox(self, 'Meta Attributes', addToLayout = 0)
        grid.addWidget(boxMeta, 2, 2)
        self.metaList = OWGUI.listBox(boxMeta, self, "selectedMeta", "metaAttributes", callback = self.onSelectionChange, selectionMode = QListWidget.ExtendedSelection, enableDragDrop = 1, dragDropCallback = self.updateInterfaceAndApplyButton)

        boxApply = OWGUI.widgetBox(self, addToLayout = 0, orientation = "horizontal", addSpace = 1)
        grid.addWidget(boxApply, 3, 0, 3, 3)
        self.applyButton = OWGUI.button(boxApply, self, "Apply", callback = self.setOutput)
        self.applyButton.setEnabled(False)
        self.applyButton.setMaximumWidth(applyButtonWidth)
        self.resetButton = OWGUI.button(boxApply, self, "Reset", callback = self.reset)
        self.resetButton.setMaximumWidth(applyButtonWidth)
        
        grid.setRowStretch(0, 4)
        grid.setRowStretch(1, 0)
        grid.setRowStretch(2, 2)

        self.icons = self.createAttributeIconDict()

        self.inChange = False
        self.resize(400, 480)
Ejemplo n.º 29
0
    def __init__(self,parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "Mosaic display", True, True)

        #set default settings
        self.data = None
        self.unprocessedSubsetData = None
        self.subsetData = None
        self.names = []     # class values

        self.inputs = [("Data", ExampleTable, self.setData, Default), ("Data Subset", ExampleTable, self.setSubsetData)]
        self.outputs = [("Selected Data", ExampleTable), ("Learner", orange.Learner)]

        #load settings
        self.colorSettings = None
        self.selectedSchemaIndex = 0
        self.interiorColoring = 0
        self.cellspace = 4
        self.showAprioriDistributionBoxes = 1
        self.useBoxes = 1
        self.showSubsetDataBoxes = 1
        self.horizontalDistribution = 0
        self.showAprioriDistributionLines = 0
        self.boxSize = 5
        self.exploreAttrPermutations = 0
        self.attr1 = ""
        self.attr2 = ""
        self.attr3 = ""
        self.attr4 = ""

        self.attributeNameOffset = 30
        self.attributeValueOffset = 15
        self.residuals = [] # residual values if the residuals are visualized
        self.aprioriDistributions = []
        self.colorPalette = None
        self.permutationDict = {}
        self.manualAttributeValuesDict = {}
        self.conditionalDict = None
        self.conditionalSubsetDict = None
        self.activeRule = None
        self.removeUnusedValues = 0

        self.selectionRectangle = None
        self.selectionConditionsHistorically = []
        self.selectionConditions = []

        # color paletes for visualizing pearsons residuals
        #self.blueColors = [QColor(255, 255, 255), QColor(117, 149, 255), QColor(38, 43, 232), QColor(1,5,173)]
        self.blueColors = [QColor(255, 255, 255), QColor(210, 210, 255), QColor(110, 110, 255), QColor(0,0,255)]
        self.redColors = [QColor(255, 255, 255), QColor(255, 200, 200), QColor(255, 100, 100), QColor(255, 0, 0)]

        self.loadSettings()

        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main")
        self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings")

        self.canvas = QGraphicsScene()
        self.canvasView = MosaicSceneView(self, self.canvas, self.mainArea)
        self.mainArea.layout().addWidget(self.canvasView)
        self.canvasView.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.canvasView.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.canvasView.setRenderHint(QPainter.Antialiasing)
        #self.canvasView.setAlignment(Qt.AlignLeft | Qt.AlignTop)

        #GUI
        #add controls to self.controlArea widget
        #self.controlArea.setMinimumWidth(235)

        texts = ["1st Attribute", "2nd Attribute", "3rd Attribute", "4th Attribute"]
        for i in range(1,5):
            box = OWGUI.widgetBox(self.GeneralTab, texts[i-1], orientation = "horizontal")
            combo = OWGUI.comboBox(box, self, "attr" + str(i), None, callback = self.updateGraphAndPermList, sendSelectedValue = 1, valueType = str)

            butt = OWGUI.button(box, self, "", callback = self.orderAttributeValues, tooltip = "Change the order of attribute values", debuggingEnabled = 0)
            butt.setFixedSize(26, 24)
            butt.setCheckable(1)
            butt.setIcon(QIcon(os.path.join(self.widgetDir, "icons/Dlg_sort.png")))

            setattr(self, "sort"+str(i), butt)
            setattr(self, "attr" + str(i)+ "Combo", combo)

        self.optimizationDlg = OWMosaicOptimization(self, self.signalManager)

        optimizationButtons = OWGUI.widgetBox(self.GeneralTab, "Dialogs", orientation = "horizontal")
        OWGUI.button(optimizationButtons, self, "VizRank", callback = self.optimizationDlg.reshow, debuggingEnabled = 0, tooltip = "Find attribute combinations that will separate different classes as clearly as possible.")

        self.collapsableWBox = OWGUI.collapsableWidgetBox(self.GeneralTab, "Explore Attribute Permutations", self, "exploreAttrPermutations", callback = self.permutationListToggle)
        self.permutationList = OWGUI.listBox(self.collapsableWBox, self, callback = self.setSelectedPermutation)
        #self.permutationList.hide()
        self.GeneralTab.layout().addStretch(100)

        # ######################
        # SETTINGS TAB
        # ######################
        box5 = OWGUI.widgetBox(self.SettingsTab, "Colors in Cells Represent...", addSpace = 1)
        OWGUI.comboBox(box5, self, "interiorColoring", None, items = self.interiorColoringOpts, callback = self.updateGraph)
        #box5.setSizePolicy(QSizePolicy(QSizePolicy.Minimum , QSizePolicy.Fixed ))

        box = OWGUI.widgetBox(self.SettingsTab, "Visual Settings", addSpace = 1)
        
        OWGUI.hSlider(box, self, 'cellspace', label = "Cell distance: ", minValue=1, maxValue=15, step=1, callback = self.updateGraph, tooltip = "What is the minimum distance between two rectangles in the plot?")
        OWGUI.checkBox(box, self, "removeUnusedValues", "Remove unused attribute values", tooltip = "Do you want to remove unused attribute values?\nThis setting will not be considered until new data is received.")

        self.box6 = OWGUI.widgetBox(self.SettingsTab, "Cell Distribution Settings", addSpace = 1)
        OWGUI.comboBox(self.box6, self, 'horizontalDistribution', items = ["Show Distribution Vertically", "Show Distribution Horizontally"], tooltip = "Do you wish to see class distribution drawn horizontally or vertically?", callback = self.updateGraph)
        OWGUI.checkBox(self.box6, self, 'showAprioriDistributionLines', 'Show apriori distribution with lines', callback = self.updateGraph, tooltip = "Show the lines that represent the apriori class distribution")

        self.box8 = OWGUI.widgetBox(self.SettingsTab, "Boxes in Cells", addSpace = 1)
        OWGUI.hSlider(self.box8, self, 'boxSize', label = "Size: ", minValue=1, maxValue=15, step=1, callback = self.updateGraph, tooltip = "What is the size of the boxes on the left and right edge of each cell?")
        OWGUI.checkBox(self.box8, self, 'showSubsetDataBoxes', 'Show class distribution of subset data', callback = self.updateGraph, tooltip = "Show small boxes at right (or bottom) edge of cells to represent class distribution of examples from example subset input.")
        cb = OWGUI.checkBox(self.box8, self, 'useBoxes', 'Use boxes on left to show...', callback = self.updateGraph, tooltip = "Show small boxes at left (or top) edge of cells to represent additional information.")
        indBox = OWGUI.indentedBox(self.box8, sep=OWGUI.checkButtonOffsetHint(cb))
        OWGUI.comboBox(indBox, self, 'showAprioriDistributionBoxes', items = self.subboxesOpts, tooltip = "Show additional boxes for each mosaic cell representing:\n - expected class distribution (assuming independence between attributes)\n - apriori class distribution (based on all examples).", callback = self.updateGraph)

        hbox = OWGUI.widgetBox(self.SettingsTab, "Colors", addSpace = 1)
        OWGUI.button(hbox, self, "Set Colors", self.setColors, tooltip = "Set the color palette for class values", debuggingEnabled = 0)

        #self.box6.setSizePolicy(QSizePolicy(QSizePolicy.Minimum , QSizePolicy.Fixed ))
        self.SettingsTab.layout().addStretch(1)

        self.connect(self.graphButton, SIGNAL("clicked()"), self.saveToFileCanvas)
        self.icons = self.createAttributeIconDict()
        self.resize(830, 550)

        self.VizRankLearner = MosaicTreeLearner(self.optimizationDlg)
        self.send("Learner", self.VizRankLearner)

        self.wdChildDialogs = [self.optimizationDlg]        # used when running widget debugging

        self.collapsableWBox.updateControls()
        dlg = self.createColorDialog()
        self.colorPalette = dlg.getDiscretePalette("discPalette")
        self.selectionColorPalette = [QColor(*col) for col in OWColorPalette.defaultRGBColors]
Ejemplo n.º 30
0
    def __init__(self, parent=None, signalManager=None):
        "Constructor"
        OWWidget.__init__(self, parent, signalManager, "&Distributions", TRUE)
        # settings
        self.numberOfBars = 5
        self.barSize = 50
        self.showContinuousClassGraph = 1
        self.showProbabilities = 1
        self.showConfidenceIntervals = 0
        self.smoothLines = 0
        self.lineWidth = 1
        self.showMainTitle = 0
        self.showXaxisTitle = 1
        self.showYaxisTitle = 1
        self.showYPaxisTitle = 1

        self.attribute = ""
        self.targetValue = 0
        self.visibleOutcomes = []
        self.outcomes = []

        # tmp values
        self.mainTitle = ""
        self.xaxisTitle = ""
        self.yaxisTitle = "frequency"
        self.yPaxisTitle = ""

        # GUI
        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main")
        self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings")

        self.graph = OWDistributionGraph(self, self.mainArea)
        self.mainArea.layout().addWidget(self.graph)
        self.graph.setYRlabels(None)
        self.graph.setAxisScale(QwtPlot.yRight, 0.0, 1.0, 0.1)
        self.connect(self.graphButton, SIGNAL("clicked()"),
                     self.graph.saveToFile)

        self.loadSettings()

        # inputs
        # data and graph temp variables
        self.inputs = [("Examples", ExampleTable, self.setData, Default)]

        self.data = None
        self.outcomenames = []
        self.probGraphValues = []

        # GUI connections
        # options dialog connections
        self.numberOfBarsSlider = OWGUI.hSlider(self.SettingsTab,
                                                self,
                                                'numberOfBars',
                                                box='Number of bars',
                                                minValue=5,
                                                maxValue=60,
                                                step=5,
                                                callback=self.setNumberOfBars,
                                                ticks=5)
        self.numberOfBarsSlider.setTracking(
            0)  # no change until the user stop dragging the slider

        self.barSizeSlider = OWGUI.hSlider(self.SettingsTab,
                                           self,
                                           'barSize',
                                           box="Bar size",
                                           minValue=30,
                                           maxValue=100,
                                           step=5,
                                           callback=self.setBarSize,
                                           ticks=10)

        box = OWGUI.widgetBox(self.SettingsTab, "General graph settings")
        box.setMinimumWidth(180)
        box2 = OWGUI.widgetBox(box, orientation="horizontal")
        OWGUI.checkBox(box2,
                       self,
                       'showMainTitle',
                       'Show main title',
                       callback=self.setShowMainTitle)
        OWGUI.lineEdit(box2, self, 'mainTitle', callback=self.setMainTitle)

        box3 = OWGUI.widgetBox(box, orientation="horizontal")
        OWGUI.checkBox(box3,
                       self,
                       'showXaxisTitle',
                       'Show X axis title',
                       callback=self.setShowXaxisTitle)
        OWGUI.lineEdit(box3, self, 'xaxisTitle', callback=self.setXaxisTitle)

        box4 = OWGUI.widgetBox(box, orientation="horizontal")
        OWGUI.checkBox(box4,
                       self,
                       'showYaxisTitle',
                       'Show Y axis title',
                       callback=self.setShowYaxisTitle)
        OWGUI.lineEdit(box4, self, 'yaxisTitle', callback=self.setYaxisTitle)

        OWGUI.checkBox(box,
                       self,
                       'graph.showContinuousClassGraph',
                       'Show continuous class graph',
                       callback=self.setShowContinuousClassGraph)

        box5 = OWGUI.widgetBox(self.SettingsTab, "Probability plot")
        self.showProb = OWGUI.checkBox(box5,
                                       self,
                                       'showProbabilities',
                                       'Show probabilities',
                                       callback=self.setShowProbabilities)

        box6 = OWGUI.widgetBox(box5, orientation="horizontal")

        self.showYPaxisCheck = OWGUI.checkBox(box6,
                                              self,
                                              'showYPaxisTitle',
                                              'Show axis title',
                                              callback=self.setShowYPaxisTitle)
        self.yPaxisEdit = OWGUI.lineEdit(box6,
                                         self,
                                         'yPaxisTitle',
                                         callback=self.setYPaxisTitle)
        self.confIntCheck = OWGUI.checkBox(
            box5,
            self,
            'showConfidenceIntervals',
            'Show confidence intervals',
            callback=self.setShowConfidenceIntervals)
        self.showProb.disables = [
            self.showYPaxisCheck, self.yPaxisEdit, self.confIntCheck
        ]
        self.showProb.makeConsistent()

        OWGUI.checkBox(box5,
                       self,
                       'smoothLines',
                       'Smooth probability lines',
                       callback=self.setSmoothLines)

        self.barSizeSlider = OWGUI.hSlider(box5,
                                           self,
                                           'lineWidth',
                                           box='Line width',
                                           minValue=1,
                                           maxValue=9,
                                           step=1,
                                           callback=self.setLineWidth,
                                           ticks=1)

        #add controls to self.controlArea widget
        self.variablesQCB = OWGUI.comboBox(self.GeneralTab,
                                           self,
                                           "attribute",
                                           box="Variable",
                                           valueType=str,
                                           sendSelectedValue=True,
                                           callback=self.setVariable)
        self.targetQCB = OWGUI.comboBox(self.GeneralTab,
                                        self,
                                        "targetValue",
                                        box="Target value",
                                        valueType=int,
                                        callback=self.setTarget)
        self.outcomesQLB = OWGUI.listBox(
            self.GeneralTab,
            self,
            "visibleOutcomes",
            "outcomes",
            "Outcomes",
            selectionMode=QListWidget.MultiSelection,
            callback=self.outcomeSelectionChange)

        self.icons = self.createAttributeIconDict()

        self.graph.numberOfBars = self.numberOfBars
        self.graph.barSize = self.barSize
        self.graph.setShowMainTitle(self.showMainTitle)
        self.graph.setShowXaxisTitle(self.showXaxisTitle)
        self.graph.setShowYLaxisTitle(self.showYaxisTitle)
        self.graph.setShowYRaxisTitle(self.showYPaxisTitle)
        self.graph.setMainTitle(self.mainTitle)
        self.graph.setXaxisTitle(self.xaxisTitle)
        self.graph.setYLaxisTitle(self.yaxisTitle)
        self.graph.setYRaxisTitle(self.yPaxisTitle)
        self.graph.showProbabilities = self.showProbabilities
        self.graph.showConfidenceIntervals = self.showConfidenceIntervals
        self.graph.smoothLines = self.smoothLines
        self.graph.lineWidth = self.lineWidth
        #self.graph.variableContinuous = self.VariableContinuous
        self.graph.targetValue = self.targetValue
Ejemplo n.º 31
0
    def __init__(self,
                 parent=None,
                 selectText="",
                 applyText="Apply",
                 callbackOnApply=None,
                 callbackOnReset=None):
        QWidget.__init__(self)
        if parent:
            parent.layout().addWidget(self)
        gl = QGridLayout()
        gl.setMargin(0)
        self.setLayout(gl)
        self.callbackOnApply = callbackOnApply
        self.callbackOnReset = callbackOnReset
        #Local Variables
        buttonWidth = 50
        applyButtonWidth = 101

        self.inputItems = []  # A backup of all input Items
        self.availableItems = [
        ]  # A managed list of the available items that can still be selected (inputItems that are not yet selectedItems)
        self.availableItems2 = [
            "a", "b", "c"
        ]  # A managed list of the available items that can still be selected (inputItems that are not yet selectedItems)
        self.selectedItems = []  # A managed list of the already selected items

        # Left pane Box.
        boxAvail = OWGUI.widgetBox(self,
                                   'Available ' + selectText,
                                   addToLayout=0)
        gl.addWidget(boxAvail, 0, 0, 3, 1)

        self.filterInputItems = OWGUIEx.lineEditFilter(
            boxAvail,
            self,
            None,
            useRE=1,
            emptyText="filter " + selectText + "...",
            callback=self.__setFilteredInput,
            caseSensitive=0)

        self.inputItemsList = OWGUI.listBox(
            boxAvail,
            self,
            None,
            None,
            selectionMode=QListWidget.ExtendedSelection)

        self.filterInputItems.listbox = self.inputItemsList

        vbItems = OWGUI.widgetBox(self)
        gl.addWidget(vbItems, 0, 1)
        self.ButtonAdd = OWGUI.button(vbItems, self, ">",
                                      self.__onButtonAddClicked)
        self.ButtonAdd.setMaximumWidth(buttonWidth)
        self.ButtonRemove = OWGUI.button(vbItems, self, "<",
                                         self.__onButtonRemoveClicked)
        self.ButtonRemove.setMaximumWidth(buttonWidth)

        # Right pane selected descriptors.
        box = OWGUI.widgetBox(self, 'Selected ' + selectText)
        gl.addWidget(box, 0, 2)
        self.selectedItemsList = OWGUI.listBox(
            box, self, None, None, selectionMode=QListWidget.ExtendedSelection)

        #Apply Reset buttons
        boxApply = OWGUI.widgetBox(self,
                                   '',
                                   orientation="horizontal",
                                   addToLayout=0)
        gl.addWidget(boxApply, 3, 0, 1, 3)
        if self.callbackOnApply != None:
            self.applyButton = OWGUI.button(boxApply,
                                            self,
                                            applyText,
                                            callback=self.__apply)
            self.applyButton.setMaximumWidth(applyButtonWidth)
        self.resetButton = OWGUI.button(boxApply,
                                        self,
                                        "Reset",
                                        callback=self.__reset)
        self.resetButton.setMaximumWidth(applyButtonWidth)
Ejemplo n.º 32
0
    def __init__(self, parent=None, signalManager=None):
        "Constructor"
        OWWidget.__init__(self, parent, signalManager, "&Distributions", TRUE)
        # settings
        self.numberOfBars = 5
        self.barSize = 50
        self.showContinuousClassGraph = 1
        self.showProbabilities = 1
        self.showConfidenceIntervals = 0
        self.smoothLines = 0
        self.lineWidth = 1
        self.showMainTitle = 0
        self.showXaxisTitle = 1
        self.showYaxisTitle = 1
        self.showYPaxisTitle = 1

        self.attribute = ""
        self.targetValue = 0
        self.visibleOutcomes = []
        self.outcomes = []

        # tmp values
        self.mainTitle = ""
        self.xaxisTitle = ""
        self.yaxisTitle = "frequency"
        self.yPaxisTitle = ""

        # GUI
        #        self.tabs = OWGUI.tabWidget(self.controlArea)
        #        self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main")
        #        self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings")
        self.GeneralTab = self.SettingsTab = self.controlArea

        self.graph = OWDistributionGraph(self, self.mainArea)
        # Set a fixed minimum width. This disables the dynamic minimumSizeHint
        # from the layout, which can return a uselessly large width for the
        # x axis when showing a discrete variable with many values.
        self.graph.setMinimumWidth(250)

        self.mainArea.layout().addWidget(self.graph)
        self.graph.setYRlabels(None)
        self.graph.setAxisScale(QwtPlot.yRight, 0.0, 1.0, 0.1)
        self.connect(self.graphButton, SIGNAL("clicked()"),
                     self.graph.saveToFile)

        self.loadSettings()

        self.barSize = 50

        # inputs
        # data and graph temp variables
        self.inputs = [("Data", ExampleTable, self.setData, Default)]

        self.data = None
        self.outcomenames = []
        self.probGraphValues = []

        b = OWGUI.widgetBox(self.controlArea, "Variable", addSpace=True)
        self.variablesQCB = OWGUI.comboBox(b,
                                           self,
                                           "attribute",
                                           valueType=str,
                                           sendSelectedValue=True,
                                           callback=self.setVariable)
        OWGUI.widgetLabel(b, "Displayed outcomes")
        self.outcomesQLB = OWGUI.listBox(
            b,
            self,
            "visibleOutcomes",
            "outcomes",
            selectionMode=QListWidget.MultiSelection,
            callback=self.outcomeSelectionChange)

        # GUI connections
        # options dialog connections
        #        b = OWGUI.widgetBox(self.SettingsTab, "Bars")
        #        OWGUI.spin(b, self, "numberOfBars", label="Number of bars", min=5, max=60, step=5, callback=self.setNumberOfBars, callbackOnReturn=True)
        #        self.numberOfBarsSlider = OWGUI.hSlider(self.SettingsTab, self, 'numberOfBars', box='Number of bars', minValue=5, maxValue=60, step=5, callback=self.setNumberOfBars, ticks=5)
        #        self.numberOfBarsSlider.setTracking(0) # no change until the user stop dragging the slider

        #        self.barSizeSlider = OWGUI.hSlider(self.SettingsTab, self, 'barSize', box="Bar size", minValue=30, maxValue=100, step=5, callback=self.setBarSize, ticks=10)
        #        OWGUI.spin(b, self, "barSize", label="Bar size", min=30, max=100, step=5, callback=self.setBarSize, callbackOnReturn=True)

        box = OWGUI.widgetBox(self.SettingsTab,
                              "General graph settings",
                              addSpace=True)
        box.setMinimumWidth(180)
        box2 = OWGUI.widgetBox(box, orientation="horizontal")
        OWGUI.checkBox(box2,
                       self,
                       'showMainTitle',
                       'Main title',
                       callback=self.setShowMainTitle)
        OWGUI.lineEdit(box2,
                       self,
                       'mainTitle',
                       callback=self.setMainTitle,
                       enterPlaceholder=True)

        box3 = OWGUI.widgetBox(box, orientation="horizontal")
        OWGUI.checkBox(box3,
                       self,
                       'showXaxisTitle',
                       'X axis title',
                       callback=self.setShowXaxisTitle)
        OWGUI.lineEdit(box3,
                       self,
                       'xaxisTitle',
                       callback=self.setXaxisTitle,
                       enterPlaceholder=True)

        box4 = OWGUI.widgetBox(box, orientation="horizontal")
        OWGUI.checkBox(box4,
                       self,
                       'showYaxisTitle',
                       'Y axis title',
                       callback=self.setShowYaxisTitle)
        OWGUI.lineEdit(box4,
                       self,
                       'yaxisTitle',
                       callback=self.setYaxisTitle,
                       enterPlaceholder=True)

        OWGUI.checkBox(box,
                       self,
                       'graph.showContinuousClassGraph',
                       'Show continuous class graph',
                       callback=self.setShowContinuousClassGraph)
        OWGUI.spin(box,
                   self,
                   "numberOfBars",
                   label="Number of bars",
                   min=5,
                   max=60,
                   step=5,
                   callback=self.setNumberOfBars,
                   callbackOnReturn=True)

        self.probabilityPlotBox = box5 = OWGUI.widgetBox(
            self.SettingsTab, "Probability plot")
        self.showProb = OWGUI.checkBox(box5,
                                       self,
                                       'showProbabilities',
                                       'Show probabilities',
                                       callback=self.setShowProbabilities)
        self.targetQCB = OWGUI.comboBox(OWGUI.indentedBox(
            box5, sep=OWGUI.checkButtonOffsetHint(self.showProb)),
                                        self,
                                        "targetValue",
                                        label="Target value",
                                        valueType=int,
                                        callback=self.setTarget)

        box6 = OWGUI.widgetBox(box5, orientation="horizontal")

        self.showYPaxisCheck = OWGUI.checkBox(box6,
                                              self,
                                              'showYPaxisTitle',
                                              'Axis title',
                                              callback=self.setShowYPaxisTitle)
        self.yPaxisEdit = OWGUI.lineEdit(box6,
                                         self,
                                         'yPaxisTitle',
                                         callback=self.setYPaxisTitle,
                                         enterPlaceholder=True)
        self.confIntCheck = OWGUI.checkBox(
            box5,
            self,
            'showConfidenceIntervals',
            'Show confidence intervals',
            callback=self.setShowConfidenceIntervals)
        self.cbSmooth = OWGUI.checkBox(box5,
                                       self,
                                       'smoothLines',
                                       'Smooth probability lines',
                                       callback=self.setSmoothLines)
        self.showProb.disables = [
            self.showYPaxisCheck, self.yPaxisEdit, self.confIntCheck,
            self.targetQCB, self.cbSmooth
        ]
        self.showProb.makeConsistent()

        #        self.barSizeSlider = OWGUI.hSlider(box5, self, 'lineWidth', box='Line width', minValue=1, maxValue=9, step=1, callback=self.setLineWidth, ticks=1)

        OWGUI.rubber(self.SettingsTab)

        #add controls to self.controlArea widget

        self.icons = self.createAttributeIconDict()

        self.graph.numberOfBars = self.numberOfBars
        self.graph.barSize = self.barSize
        self.graph.setShowMainTitle(self.showMainTitle)
        self.graph.setShowXaxisTitle(self.showXaxisTitle)
        self.graph.setShowYLaxisTitle(self.showYaxisTitle)
        self.graph.setShowYRaxisTitle(self.showYPaxisTitle)
        self.graph.setMainTitle(self.mainTitle)
        self.graph.setXaxisTitle(self.xaxisTitle)
        self.graph.setYLaxisTitle(self.yaxisTitle)
        self.graph.setYRaxisTitle(self.yPaxisTitle)
        self.graph.showProbabilities = self.showProbabilities
        self.graph.showConfidenceIntervals = self.showConfidenceIntervals
        self.graph.smoothLines = self.smoothLines
        self.graph.lineWidth = self.lineWidth
        #self.graph.variableContinuous = self.VariableContinuous
        self.graph.targetValue = self.targetValue
Ejemplo n.º 33
0
    def __init__(self, visualizationWidget=None, signalManager=None):
        OWWidget.__init__(self,
                          None,
                          signalManager,
                          "Sieve Evaluation Dialog",
                          savePosition=True,
                          wantMainArea=0,
                          wantStatusBar=1)
        orngMosaic.__init__(self)

        self.resize(390, 620)
        self.setCaption("Sieve Diagram Evaluation Dialog")

        # loaded variables
        self.visualizationWidget = visualizationWidget
        self.useTimeLimit = 0
        self.useProjectionLimit = 0
        self.qualityMeasure = CHI_SQUARE  # we will always compute only chi square with sieve diagram
        self.optimizationType = EXACT_NUMBER_OF_ATTRS
        self.attributeCount = 2
        self.attrCondition = None
        self.attrConditionValue = None

        self.lastSaveDirName = os.getcwd()

        self.attrLenDict = {}
        self.shownResults = []
        self.loadSettings()

        self.layout().setMargin(0)
        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.MainTab = OWGUI.createTabPage(self.tabs, "Main")
        self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings")
        self.ManageTab = OWGUI.createTabPage(self.tabs, "Manage")

        # ###########################
        # MAIN TAB
        box = OWGUI.widgetBox(self.MainTab, box="Condition")
        self.attrConditionCombo = OWGUI.comboBoxWithCaption(
            box,
            self,
            "attrCondition",
            "Attribute:",
            callback=self.updateConditionAttr,
            sendSelectedValue=1,
            valueType=str,
            labelWidth=70)
        self.attrConditionValueCombo = OWGUI.comboBoxWithCaption(
            box,
            self,
            "attrConditionValue",
            "Value:",
            sendSelectedValue=1,
            valueType=str,
            labelWidth=70)

        self.optimizationBox = OWGUI.widgetBox(self.MainTab, "Evaluate")
        self.buttonBox = OWGUI.widgetBox(self.optimizationBox,
                                         orientation="horizontal")
        self.resultsBox = OWGUI.widgetBox(
            self.MainTab, "Projection List Ordered by Chi-Square")

        #        self.label1 = OWGUI.widgetLabel(self.buttonBox, 'Projections with ')
        #        self.optimizationTypeCombo = OWGUI.comboBox(self.buttonBox, self, "optimizationType", items = ["    exactly    ", "  maximum  "] )
        #        self.attributeCountCombo = OWGUI.comboBox(self.buttonBox, self, "attributeCount", items = range(1, 5), tooltip = "Evaluate only projections with exactly (or maximum) this number of attributes", sendSelectedValue = 1, valueType = int)
        #        self.attributeLabel = OWGUI.widgetLabel(self.buttonBox, ' attributes')

        self.startOptimizationButton = OWGUI.button(
            self.optimizationBox,
            self,
            "Start Evaluating Projections",
            callback=self.evaluateProjections)
        f = self.startOptimizationButton.font()
        f.setBold(1)
        self.startOptimizationButton.setFont(f)
        self.stopOptimizationButton = OWGUI.button(
            self.optimizationBox,
            self,
            "Stop Evaluation",
            callback=self.stopEvaluationClick)
        self.stopOptimizationButton.setFont(f)
        self.stopOptimizationButton.hide()

        self.resultList = OWGUI.listBox(self.resultsBox,
                                        self,
                                        callback=self.showSelectedAttributes)
        self.resultList.setMinimumHeight(200)

        # ##########################
        # SETTINGS TAB
        OWGUI.checkBox(
            self.SettingsTab,
            self,
            "ignoreTooSmallCells",
            "Ignore cells where expected number of cases is less than 5",
            box="Ignore small cells",
            tooltip=
            "Statisticians advise that in cases when the number of expected examples is less than 5 we ignore the cell \nsince it can significantly influence the chi-square value."
        )

        OWGUI.comboBoxWithCaption(
            self.SettingsTab,
            self,
            "percentDataUsed",
            "Percent of data used: ",
            box="Data settings",
            items=self.percentDataNums,
            sendSelectedValue=1,
            valueType=int,
            tooltip=
            "In case that we have a large dataset the evaluation of each projection can take a lot of time.\nWe can therefore use only a subset of randomly selected examples, evaluate projection on them and thus make evaluation faster."
        )

        self.stopOptimizationBox = OWGUI.widgetBox(
            self.SettingsTab, "When to Stop Evaluation or Optimization?")
        OWGUI.checkWithSpin(
            self.stopOptimizationBox,
            self,
            "Time limit:                     ",
            1,
            1000,
            "useTimeLimit",
            "timeLimit",
            "  (minutes)",
            debuggingEnabled=0
        )  # disable debugging. we always set this to 1 minute
        OWGUI.checkWithSpin(self.stopOptimizationBox,
                            self,
                            "Use projection count limit:  ",
                            1,
                            1000000,
                            "useProjectionLimit",
                            "projectionLimit",
                            "  (projections)",
                            debuggingEnabled=0)
        OWGUI.rubber(self.SettingsTab)

        # ##########################
        # SAVE TAB
        #        self.visualizedAttributesBox = OWGUI.widgetBox(self.ManageTab, "Number of Concurrently Visualized Attributes")
        self.dialogsBox = OWGUI.widgetBox(self.ManageTab, "Dialogs")
        self.manageResultsBox = OWGUI.widgetBox(self.ManageTab,
                                                "Manage projections")

        #        self.attrLenList = OWGUI.listBox(self.visualizedAttributesBox, self, selectionMode = QListWidget.MultiSelection, callback = self.attrLenListChanged)
        #        self.attrLenList.setMinimumHeight(60)

        self.buttonBox7 = OWGUI.widgetBox(self.dialogsBox,
                                          orientation="horizontal")
        OWGUI.button(self.buttonBox7,
                     self,
                     "Attribute Ranking",
                     self.attributeAnalysis,
                     debuggingEnabled=0)
        OWGUI.button(self.buttonBox7,
                     self,
                     "Graph Projection Scores",
                     self.graphProjectionQuality,
                     debuggingEnabled=0)

        hbox = OWGUI.widgetBox(self.manageResultsBox, orientation="horizontal")
        OWGUI.button(hbox, self, "Load", self.load, debuggingEnabled=0)
        OWGUI.button(hbox, self, "Save", self.save, debuggingEnabled=0)

        hbox = OWGUI.widgetBox(self.manageResultsBox, orientation="horizontal")
        OWGUI.button(hbox, self, "Clear results", self.clearResults)
        OWGUI.rubber(self.ManageTab)

        # reset some parameters if we are debugging so that it won't take too much time
        if orngDebugging.orngDebuggingEnabled:
            self.useTimeLimit = 1
            self.timeLimit = 0.3
            self.useProjectionLimit = 1
            self.projectionLimit = 100
        self.icons = self.createAttributeIconDict()
Ejemplo n.º 34
0
    def __init__(self, parent=None, signalManager=None, name='Correspondence Analysis', **kwargs):
        OWWidget.__init__(self, parent, signalManager, name, *kwargs)
        self.callbackDeposit = []

        self.inputs = [("Data", ExampleTable, self.dataset)]
        self.outputs = [("Selected data", ExampleTable)]
        self.recentFiles=[]

        self.data = None
        self.CA = None
        self.CAloaded = False
        self.colors = ColorPaletteHSV(2)

        #Locals
        self.showGridlines = 0
        self.autoSendSelection = 0
        self.toolbarSelection = 0
        self.percRadius = 5


        self.colorSettings = None

        # GUI
        self.tabs = OWGUI.tabWidget(self.controlArea) #QTabWidget(self.controlArea, 'tabWidget')
        self.GeneralTab = OWGUI.createTabPage(self.tabs, "General") #QVGroupBox(self)
        self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings") #QVGroupBox(self)
#        self.tabs.insertTab(self.GeneralTab, "General")
#        self.tabs.insertTab(self.SettingsTab, "Settings")

#        layout = QVBoxLayout(self.mainArea)
        self.tabsMain = OWGUI.tabWidget(self.mainArea) #QTabWidget(self.mainArea, 'tabWidgetMain')

#        layout.addWidget(self.tabsMain)

        # ScatterPlot
        self.graph = OWCorrAnalysisGraph(None, "ScatterPlot")
#        self.tabsMain.insertTab(self.graph, "Scatter Plot")
        OWGUI.createTabPage(self.tabsMain, "Scatter Plot", self.graph)

        self.icons = self.createAttributeIconDict()

        self.textData = False
        if textCorpusModul:
          OWGUI.checkBox(self.GeneralTab, self, 'textData', 'Textual data', callback = self.initAttrValues)

        #col attribute
        self.attrCol = ""
        self.attrColCombo = OWGUI.comboBox(self.GeneralTab, self, "attrCol", " Column table attribute ", callback = self.updateTables, sendSelectedValue = 1, valueType = str)

        # row attribute
        self.attrRow = ""
        self.attrRowCombo = OWGUI.comboBox(self.GeneralTab, self, "attrRow", "Row table attribute ", callback = self.updateTables, sendSelectedValue = 1, valueType = str)

        #x principal axis
        self.attrX = 0
        self.attrXCombo = OWGUI.comboBox(self.GeneralTab, self, "attrX", " Principal axis X ", callback = self.contributionBox, sendSelectedValue = 1, valueType = str)

        #y principal axis
        self.attrY = 0
        self.attrYCombo = OWGUI.comboBox(self.GeneralTab, self, "attrY", " Principal axis Y ", callback = self.contributionBox, sendSelectedValue = 1, valueType = str)

        contribution = OWGUI.widgetBox(self.GeneralTab, 'Contribution to inertia') #QVGroupBox('Contribution to inertia', self.GeneralTab)
        self.firstAxis = OWGUI.widgetLabel(contribution, 'Axis %d: %f%%' % (1, 10))
        self.secondAxis = OWGUI.widgetLabel(contribution, 'Axis %d: %f%%' % (2, 10))

        sliders = OWGUI.widgetBox(self.GeneralTab, 'Percentage of points') #QVGroupBox('Percentage of points', self.GeneralTab)
        OWGUI.widgetLabel(sliders, 'Row points')
        self.percRow = 100
        self.rowSlider = OWGUI.hSlider(sliders, self, 'percRow', minValue=1, maxValue=100, step=10, callback = self.updateGraph)
        OWGUI.widgetLabel(sliders, 'Column points')
        self.percCol = 100
        self.colSlider = OWGUI.hSlider(sliders, self, 'percCol', minValue=1, maxValue=100, step=10, callback = self.updateGraph)


        #zooming
#        self.zoomSelectToolbar = ZoomBrowseSelectToolbar(self, self.GeneralTab, self.graph, self.autoSendSelection)
        self.zoomSelectToolbar = OWToolbars.ZoomSelectToolbar(self, self.GeneralTab, self.graph, self.autoSendSelection)
        
        self.connect(self.zoomSelectToolbar.buttonSendSelections, SIGNAL("clicked()"), self.sendSelections)
#        self.connect(self.graph, SIGNAL('plotMousePressed(const QMouseEvent&)'), self.sendSelections)

        OWGUI.button(self.GeneralTab, self, 'Update Graph', self.buttonUpdate)

        OWGUI.button(self.GeneralTab, self, 'Save graph', self.graph.saveToFile)
        OWGUI.button(self.GeneralTab, self, 'Save CA', self.saveCA)
        OWGUI.button(self.GeneralTab, self, 'Load CA', self.loadCA)
        self.chosenSelection = []
        self.selections = []
        OWGUI.listBox(self.GeneralTab, self, "chosenSelection", "selections", box="Feature selection used", selectionMode = QListWidget.MultiSelection, callback = None)
        # ####################################
        # SETTINGS TAB
        # point width
        OWGUI.hSlider(self.SettingsTab, self, 'graph.pointWidth', box=' Point size ', minValue=1, maxValue=20, step=1, callback = self.replotCurves)
        OWGUI.hSlider(self.SettingsTab, self, 'graph.brushAlpha', box=' Transparancy ', minValue=1, maxValue=255, step=1, callback = self.replotCurves)

        # general graph settings
        box4 = OWGUI.widgetBox(self.SettingsTab, " General graph settings ")
        OWGUI.checkBox(box4, self, 'graph.showXaxisTitle', 'X-axis title', callback = self.updateGraph)
        OWGUI.checkBox(box4, self, 'graph.showYLaxisTitle', 'Y-axis title', callback = self.updateGraph)
##        OWGUI.checkBox(box4, self, 'graph.showAxisScale', 'Show axis scale', callback = self.updateGraph)
        OWGUI.checkBox(box4, self, 'graph.showLegend', 'Show legend', callback = self.updateGraph)
        OWGUI.checkBox(box4, self, 'graph.showFilledSymbols', 'Show filled symbols', callback = self.updateGraph)
        OWGUI.checkBox(box4, self, 'showGridlines', 'Show gridlines', callback = self.setShowGridlines)
##        OWGUI.checkBox(box4, self, 'graph.showClusters', 'Show clusters', callback = self.updateGraph, tooltip = "Show a line boundary around a significant cluster")
        OWGUI.checkBox(box4, self, 'graph.showRowLabels', 'Show row labels', callback = self.updateGraph)
        OWGUI.checkBox(box4, self, 'graph.showColumnLabels', 'Show column labels', callback = self.updateGraph)


        self.colorButtonsBox = OWGUI.widgetBox(self.SettingsTab, " Colors ", orientation = "horizontal")
        OWGUI.button(self.colorButtonsBox, self, "Set Colors", self.setColors, tooltip = "Set the canvas background color, grid color and color palette for coloring continuous variables", debuggingEnabled = 0)

        #browsing radius
        OWGUI.hSlider(self.SettingsTab, self, 'percRadius', box=' Browsing curve size ', minValue = 0, maxValue=100, step=5, callback = self.calcRadius)

        #font size
        OWGUI.hSlider(self.SettingsTab, self, 'graph.labelSize', box=' Set font size for labels ', minValue = 8, maxValue=48, step=1, callback = self.updateGraph)

        OWGUI.hSlider(self.SettingsTab, self, 'graph.maxPoints', box=' Maximum number of points ', minValue = 10, maxValue=40, step=1, callback = None)
        
        OWGUI.rubber(self.SettingsTab)

#        self.resultsTab = QVGroupBox(self, "Results")
#        self.tabsMain.insertTab(self.resultsTab, "Results")
        self.resultsTab = OWGUI.createTabPage(self.tabsMain, "Results", OWGUI.widgetBox(self, "Results", addToLayout=False))
        self.chosenDoc = []
        self.docs = self.graph.docs
        OWGUI.listBox(self.resultsTab, self, "chosenDoc", "docs", box="Documents", callback = None)
        self.chosenFeature = []
        self.features = self.graph.features
        OWGUI.listBox(self.resultsTab, self, "chosenFeature", "features", box="Features", selectionMode = QListWidget.MultiSelection, callback = None)
        OWGUI.button(self.resultsTab, self, "Save selected features", callback = self.saveFeatures)
        OWGUI.button(self.resultsTab, self, "Reconstruct words from letter ngrams", callback = self.reconstruct)
        self.chosenWord = []
        self.words = []
        OWGUI.listBox(self.resultsTab, self, "chosenWord", "words", box="Suggested words", callback = None)

        dlg = self.createColorDialog()
        self.graph.contPalette = dlg.getContinuousPalette("contPalette")
        self.graph.discPalette = dlg.getDiscretePalette("discPalette")
        self.graph.setCanvasBackground(dlg.getColor("Canvas"))
        self.graph.setGridColor(QPen(dlg.getColor("Grid")))

        self.graph.enableGridXB(self.showGridlines)
        self.graph.enableGridYL(self.showGridlines)

#        apply([self.zoomSelectToolbar.actionZooming, self.zoomSelectToolbar.actionRectangleSelection, self.zoomSelectToolbar.actionPolygonSelection, self.zoomSelectToolbar.actionBrowse, self.zoomSelectToolbar.actionBrowseCircle][self.toolbarSelection], [])

        self.resize(700, 800)
Ejemplo n.º 35
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, "Time Data Visualizer",
                          TRUE)

        self.inputs = [("Examples", ExampleTable, self.setData, Default),
                       ("Example Subset", ExampleTable, self.setSubsetData),
                       ("Attribute selection", AttributeList,
                        self.setShownAttributes)]
        self.outputs = [("Selected Examples", ExampleTable),
                        ("Unselected Examples", ExampleTable)]

        # local variables
        self.autoSendSelection = 1
        self.toolbarSelection = 0
        self.colorSettings = None
        self.selectedSchemaIndex = 0

        self.graph = OWTimeDataVisualizerGraph(self, self.mainArea,
                                               "Time Data Visualizer")

        self.data = None
        self.subsetData = None

        #load settings
        self.loadSettings()

        #GUI
        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main")
        self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings")

        #add a graph widget
        self.mainArea.layout().addWidget(self.graph)
        self.connect(self.graphButton, SIGNAL("clicked()"),
                     self.graph.saveToFile)

        #x attribute
        self.attrX = ""
        box = OWGUI.widgetBox(self.GeneralTab, "Time Attribute")
        # add an option to use the index of the example as time stamp
        #OWGUI.checkBox(box, self, 'graph.use', 'X axis title', callback = self.graph.setShowXaxisTitle)
        self.timeCombo = OWGUI.comboBox(box,
                                        self,
                                        "graph.timeAttr",
                                        callback=self.majorUpdateGraph,
                                        sendSelectedValue=1,
                                        valueType=str)

        self.colorCombo = OWGUI.comboBox(self.GeneralTab,
                                         self,
                                         "graph.colorAttr",
                                         "Point Color",
                                         callback=self.updateGraph,
                                         sendSelectedValue=1,
                                         valueType=str)

        # y attributes
        box = OWGUI.widgetBox(self.GeneralTab, "Visualized attributes")
        OWGUI.listBox(box,
                      self,
                      "graph.shownAttributeIndices",
                      "graph.attributes",
                      selectionMode=QListWidget.ExtendedSelection,
                      sizeHint=QSize(150, 250))
        OWGUI.button(box,
                     self,
                     "Update listbox changes",
                     callback=self.majorUpdateGraph)

        # zooming / selection
        self.zoomSelectToolbar = OWToolbars.ZoomSelectToolbar(
            self, self.GeneralTab, self.graph, self.autoSendSelection)
        self.connect(self.zoomSelectToolbar.buttonSendSelections,
                     SIGNAL("clicked()"), self.sendSelections)

        # ####################################
        # SETTINGS TAB
        # point width
        pointBox = OWGUI.widgetBox(self.SettingsTab, "Point properties")
        OWGUI.hSlider(pointBox,
                      self,
                      'graph.pointWidth',
                      label="Symbol size:   ",
                      minValue=1,
                      maxValue=10,
                      step=1,
                      callback=self.pointSizeChange)
        OWGUI.hSlider(pointBox,
                      self,
                      'graph.alphaValue',
                      label="Transparency: ",
                      minValue=0,
                      maxValue=255,
                      step=10,
                      callback=self.alphaChange)

        # general graph settings
        box4 = OWGUI.widgetBox(self.SettingsTab, "General graph settings")
        OWGUI.checkBox(box4,
                       self,
                       'graph.drawLines',
                       'Draw lines',
                       callback=self.updateGraph)
        OWGUI.checkBox(box4,
                       self,
                       'graph.drawPoints',
                       'Draw points (slower)',
                       callback=self.updateGraph)
        OWGUI.checkBox(box4,
                       self,
                       'graph.trackExamples',
                       'Track examples',
                       callback=self.updateGraph)
        OWGUI.checkBox(box4,
                       self,
                       'graph.showGrayRects',
                       'Show gray rectangles',
                       callback=self.updateGraph)
        OWGUI.checkBox(box4,
                       self,
                       'graph.showXaxisTitle',
                       'Show x axis title',
                       callback=self.graph.setShowXaxisTitle)
        OWGUI.checkBox(box4,
                       self,
                       'graph.showLegend',
                       'Show legend',
                       callback=self.updateGraph)
        OWGUI.checkBox(box4,
                       self,
                       'graph.useAntialiasing',
                       'Use antialiasing',
                       callback=self.antialiasingChange)

        self.colorButtonsBox = OWGUI.widgetBox(self.SettingsTab,
                                               "Colors",
                                               orientation="horizontal")
        OWGUI.button(
            self.colorButtonsBox,
            self,
            "Set Colors",
            self.setColors,
            tooltip=
            "Set the canvas background color, grid color and color palette for coloring continuous variables",
            debuggingEnabled=0)

        box5 = OWGUI.widgetBox(self.SettingsTab, "Tooltips settings")
        OWGUI.comboBox(box5,
                       self,
                       "graph.tooltipKind",
                       items=[
                           "Don't Show Tooltips", "Show Visible Attributes",
                           "Show All Attributes"
                       ],
                       callback=self.updateGraph)

        OWGUI.checkBox(
            self.SettingsTab,
            self,
            'autoSendSelection',
            'Auto send selected data',
            box="Data selection",
            callback=self.setAutoSendSelection,
            tooltip=
            "Send signals with selected data whenever the selection changes")
        self.graph.selectionChangedCallback = self.setAutoSendSelection

        OWGUI.rubber(self.GeneralTab)
        OWGUI.rubber(self.SettingsTab)
        self.icons = self.createAttributeIconDict()

        self.activateLoadedSettings()
        self.resize(700, 550)
Ejemplo n.º 36
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, "Predictions")

        self.callbackDeposit = []
        self.inputs = [("Examples", ExampleTable, self.setData),
                       ("Predictors", orange.Classifier, self.setPredictor,
                        Multiple)]
        self.outputs = [("Predictions", ExampleTable)]
        self.predictors = {}

        # saveble settings
        self.ShowAttributeMethod = 0
        self.classes = []
        self.selectedClasses = []
        self.loadSettings()
        self.datalabel = "N/A"
        self.predictorlabel = "N/A"
        self.tasklabel = "N/A"
        self.outvar = None  # current output variable (set by the first predictor/data set send in)
        self.classifications = []
        self.rindx = None
        self.data = None
        self.verbose = 0
        self.nVarImportance = 0

        # GUI - Options

        # Options - classification
        ibox = OWGUI.widgetBox(self.controlArea, "Info")
        OWGUI.label(ibox, self, "Data: %(datalabel)s")
        OWGUI.label(ibox, self, "Predictors: %(predictorlabel)s")
        OWGUI.label(ibox, self, "Task: %(tasklabel)s")
        OWGUI.separator(ibox)
        OWGUI.label(
            ibox, self,
            "Predictions can be viewed with the 'Data Table'\nand saved with the 'Save' widget!"
        )

        OWGUI.separator(self.controlArea)

        self.copt = OWGUI.widgetBox(self.controlArea,
                                    "Probabilities (classification)")
        self.copt.setDisabled(1)

        self.lbcls = OWGUI.listBox(self.copt,
                                   self,
                                   "selectedClasses",
                                   "classes",
                                   selectionMode=QListWidget.MultiSelection)
        self.lbcls.setFixedHeight(50)
        OWGUI.separator(self.controlArea)
        self.VarImportanceBox = OWGUI.doubleSpin(
            self.controlArea,
            self,
            "nVarImportance",
            0,
            9999999,
            1,
            label="Variable importance",
            orientation="horizontal",
            tooltip="The number of variables to report for each prediction.")

        OWGUI.checkBox(
            self.controlArea,
            self,
            'verbose',
            'Verbose',
            tooltip=
            'Show detailed info while predicting. This will slow down the predictions process!'
        )
        OWGUI.separator(self.controlArea)
        self.outbox = OWGUI.widgetBox(self.controlArea, "Output")
        self.apply = OWGUI.button(self.outbox,
                                  self,
                                  "Apply",
                                  callback=self.sendpredictions)

        OWGUI.rubber(self.controlArea)
        self.adjustSize()
Ejemplo n.º 37
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, "ROC Analysis", 1)

        # inputs
        self.inputs = [("Evaluation Results", orngTest.ExperimentResults,
                        self.test_results, Default)]

        # default settings
        self.PointWidth = 7
        self.CurveWidth = 3
        self.ConvexCurveWidth = 1
        self.ShowDiagonal = TRUE
        self.ConvexHullCurveWidth = 3
        self.HullColor = str(QColor(Qt.yellow).name())
        self.AveragingMethodIndex = 0  ##'merge'
        self.ShowConvexHull = TRUE
        self.ShowConvexCurves = FALSE
        self.EnablePerformance = TRUE
        self.DefaultThresholdPoint = TRUE

        #load settings
        self.loadSettings()

        # temp variables
        self.dres = None
        self.classifierColor = None
        self.numberOfClasses = 0
        self.targetClass = None
        self.numberOfClassifiers = 0
        self.numberOfIterations = 0
        self.graphs = []
        self.maxp = 1000
        self.defaultPerfLinePValues = []
        self.classifiers = []
        self.selectedClassifiers = []

        # performance analysis (temporary values
        self.FPcost = 500.0
        self.FNcost = 500.0
        self.pvalue = 50.0  ##0.400

        # list of values (remember for each class)
        self.FPcostList = []
        self.FNcostList = []
        self.pvalueList = []

        self.AveragingMethodNames = ['merge', 'vertical', 'threshold', None]
        self.AveragingMethod = self.AveragingMethodNames[min(
            3, self.AveragingMethodIndex)]

        # GUI
        import sip
        sip.delete(self.mainArea.layout())
        self.graphsGridLayoutQGL = QGridLayout(self.mainArea)
        self.mainArea.setLayout(self.graphsGridLayoutQGL)
        # save each ROC graph in separate file
        self.connect(self.graphButton, SIGNAL("clicked()"), self.saveToFile)

        ## general tab
        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.generalTab = OWGUI.createTabPage(self.tabs, "General")

        ## target class
        self.classCombo = OWGUI.comboBox(self.generalTab,
                                         self,
                                         'targetClass',
                                         box='Target class',
                                         items=[],
                                         callback=self.target)
        #self.classCombo.setMaximumSize(150, 20)

        ## classifiers selection (classifiersQLB)
        self.classifiersQVGB = OWGUI.widgetBox(self.generalTab, "Classifiers")
        self.classifiersQLB = OWGUI.listBox(
            self.classifiersQVGB,
            self,
            "selectedClassifiers",
            selectionMode=QListWidget.MultiSelection,
            callback=self.classifiersSelectionChange)
        self.unselectAllClassifiersQLB = OWGUI.button(
            self.classifiersQVGB,
            self,
            "(Un)select All",
            callback=self.SUAclassifiersQLB)

        # show convex ROC curves and show ROC convex hull
        self.convexCurvesQCB = OWGUI.checkBox(
            self.generalTab,
            self,
            'ShowConvexCurves',
            'Show convex ROC curves',
            tooltip='',
            callback=self.setShowConvexCurves)
        OWGUI.checkBox(self.generalTab,
                       self,
                       'ShowConvexHull',
                       'Show ROC convex hull',
                       tooltip='',
                       callback=self.setShowConvexHull)

        # performance analysis
        self.performanceTab = OWGUI.createTabPage(self.tabs, "Analysis")
        self.performanceTabCosts = OWGUI.widgetBox(self.performanceTab, box=1)
        OWGUI.checkBox(self.performanceTabCosts,
                       self,
                       'EnablePerformance',
                       'Show performance line',
                       tooltip='',
                       callback=self.setShowPerformanceAnalysis)
        OWGUI.checkBox(self.performanceTabCosts,
                       self,
                       'DefaultThresholdPoint',
                       'Default threshold (0.5) point',
                       tooltip='',
                       callback=self.setShowDefaultThresholdPoint)

        ## FP and FN cost ranges
        mincost = 1
        maxcost = 1000
        stepcost = 5
        self.maxpsum = 100
        self.minp = 1
        self.maxp = self.maxpsum - self.minp  ## need it also in self.pvaluesUpdated
        stepp = 1.0

        OWGUI.hSlider(self.performanceTabCosts,
                      self,
                      'FPcost',
                      box='FP Cost',
                      minValue=mincost,
                      maxValue=maxcost,
                      step=stepcost,
                      callback=self.costsChanged,
                      ticks=50)
        OWGUI.hSlider(self.performanceTabCosts,
                      self,
                      'FNcost',
                      box='FN Cost',
                      minValue=mincost,
                      maxValue=maxcost,
                      step=stepcost,
                      callback=self.costsChanged,
                      ticks=50)

        ptc = OWGUI.widgetBox(self.performanceTabCosts,
                              "Prior target class probability [%]")
        OWGUI.hSlider(ptc,
                      self,
                      'pvalue',
                      minValue=self.minp,
                      maxValue=self.maxp,
                      step=stepp,
                      callback=self.pvaluesUpdated,
                      ticks=5,
                      labelFormat="%2.1f")
        OWGUI.button(ptc, self, 'Compute from data',
                     self.setDefaultPValues)  ## reset p values to default

        ## test set selection (testSetsQLB)
        self.testSetsQVGB = OWGUI.widgetBox(self.performanceTab, "Test sets")
        self.testSetsQLB = OWGUI.listBox(
            self.testSetsQVGB,
            self,
            selectionMode=QListWidget.MultiSelection,
            callback=self.testSetsSelectionChange)
        self.unselectAllTestSetsQLB = OWGUI.button(
            self.testSetsQVGB,
            self,
            "(Un)select All",
            callback=self.SUAtestSetsQLB)

        # settings tab
        self.settingsTab = OWGUI.createTabPage(self.tabs, "Settings")
        OWGUI.radioButtonsInBox(
            self.settingsTab,
            self,
            'AveragingMethodIndex',
            ['Merge (expected ROC perf.)', 'Vertical', 'Threshold', 'None'],
            box='Averaging ROC curves',
            callback=self.selectAveragingMethod)
        OWGUI.hSlider(self.settingsTab,
                      self,
                      'PointWidth',
                      box='Point width',
                      minValue=0,
                      maxValue=9,
                      step=1,
                      callback=self.setPointWidth,
                      ticks=1)
        OWGUI.hSlider(self.settingsTab,
                      self,
                      'CurveWidth',
                      box='ROC curve width',
                      minValue=1,
                      maxValue=5,
                      step=1,
                      callback=self.setCurveWidth,
                      ticks=1)
        OWGUI.hSlider(self.settingsTab,
                      self,
                      'ConvexCurveWidth',
                      box='ROC convex curve width',
                      minValue=1,
                      maxValue=5,
                      step=1,
                      callback=self.setConvexCurveWidth,
                      ticks=1)
        OWGUI.hSlider(self.settingsTab,
                      self,
                      'ConvexHullCurveWidth',
                      box='ROC convex hull',
                      minValue=2,
                      maxValue=9,
                      step=1,
                      callback=self.setConvexHullCurveWidth,
                      ticks=1)
        OWGUI.checkBox(self.settingsTab,
                       self,
                       'ShowDiagonal',
                       'Show diagonal ROC line',
                       tooltip='',
                       callback=self.setShowDiagonal)
        self.settingsTab.layout().addStretch(100)

        self.resize(800, 600)
Ejemplo n.º 38
0
    def __init__(self, parallelWidget, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager,
                          "Parallel Optimization Dialog", FALSE)
        self.setCaption("Parallel Optimization Dialog")
        self.parallelWidget = parallelWidget

        self.optimizationMeasure = 0
        self.attributeCount = 5
        self.numberOfAttributes = 6
        self.fileName = ""
        self.lastSaveDirName = os.getcwd() + "/"
        self.fileBuffer = []
        self.projections = []
        self.allResults = []
        self.canOptimize = 0
        self.orderAllAttributes = 1  # do we wish to order all attributes or find just an interesting subset
        self.worstVal = -1  # used in heuristics to stop the search in uninteresting parts of the graph

        self.loadSettings()

        self.measureBox = OWGUI.radioButtonsInBox(
            self.controlArea,
            self,
            "optimizationMeasure", ["Correlation", "VizRank"],
            box="Select optimization measure",
            callback=self.updateGUI)
        self.vizrankSettingsBox = OWGUI.widgetBox(self.controlArea,
                                                  "VizRank settings")
        self.optimizeBox = OWGUI.widgetBox(self.controlArea, "Optimize")
        self.manageBox = OWGUI.widgetBox(self.controlArea, "Manage results")
        self.resultsBox = OWGUI.widgetBox(self.mainArea, "Results")

        self.resultList = OWGUI.listBox(self.resultsBox, self)
        self.resultList.setMinimumSize(200, 200)
        self.connect(self.resultList, SIGNAL("itemSelectionChanged()"),
                     self.showSelectedAttributes)

        # remove non-existing files
        names = []
        for i in range(len(self.fileBuffer) - 1, -1, -1):
            (short, longName) = self.fileBuffer[i]
            if not os.path.exists(longName):
                self.fileBuffer.remove((short, longName))
            else:
                names.append(short)
        names.append("(None)")
        self.fileName = "(None)"

        self.hbox1 = OWGUI.widgetBox(self.vizrankSettingsBox,
                                     "VizRank projections file",
                                     orientation="horizontal")
        self.vizrankFileCombo = OWGUI.comboBox(
            self.hbox1,
            self,
            "fileName",
            items=names,
            tooltip=
            "File that contains information about interestingness of scatterplots \ngenerated by VizRank method in scatterplot widget",
            callback=self.changeProjectionFile,
            sendSelectedValue=1,
            valueType=str)
        self.browseButton = OWGUI.button(self.hbox1,
                                         self,
                                         "...",
                                         callback=self.loadProjections)
        self.browseButton.setMaximumWidth(20)

        self.resultsInfoBox = OWGUI.widgetBox(self.vizrankSettingsBox,
                                              "VizRank parameters")
        self.kNeighborsLabel = OWGUI.widgetLabel(self.resultsInfoBox,
                                                 "Number of neighbors (k):")
        self.percentDataUsedLabel = OWGUI.widgetLabel(self.resultsInfoBox,
                                                      "Percent of data used:")
        self.testingMethodLabel = OWGUI.widgetLabel(self.resultsInfoBox,
                                                    "Testing method used:")
        self.qualityMeasureLabel = OWGUI.widgetLabel(self.resultsInfoBox,
                                                     "Quality measure used:")

        #self.numberOfAttributesCombo = OWGUI.comboBoxWithCaption(self.optimizeBox, self, "numberOfAttributes", "Number of visualized attributes: ", tooltip = "Projections with this number of attributes will be evaluated", items = [x for x in range(3, 12)], sendSelectedValue = 1, valueType = int)
        self.allAttributesRadio = QRadioButton("Order all attributes",
                                               self.optimizeBox)
        self.optimizeBox.layout().addWidget(self.allAttributesRadio)
        self.connect(self.allAttributesRadio, SIGNAL("clicked()"),
                     self.setAllAttributeRadio)
        box = OWGUI.widgetBox(self.optimizeBox, orientation="horizontal")
        self.subsetAttributeRadio = QRadioButton("Find subsets of", box)
        #        self.optimizeBox.layout().addWidget(self.subsetAttributeRadio)
        box.layout().addWidget(self.subsetAttributeRadio)
        self.connect(self.subsetAttributeRadio, SIGNAL("clicked()"),
                     self.setSubsetAttributeRadio)
        self.subsetAttributeEdit = OWGUI.lineEdit(box,
                                                  self,
                                                  "numberOfAttributes",
                                                  valueType=int)
        self.subsetAttributeEdit.setMaximumWidth(30)
        label = OWGUI.widgetLabel(box, "attributes")

        self.startOptimizationButton = OWGUI.button(
            self.optimizeBox,
            self,
            "Start Optimization",
            callback=self.startOptimization)
        f = self.startOptimizationButton.font()
        f.setBold(1)
        self.startOptimizationButton.setFont(f)
        self.stopOptimizationButton = OWGUI.button(
            self.optimizeBox,
            self,
            "Stop Evaluation",
            callback=self.stopOptimizationClick)
        self.stopOptimizationButton.setFont(f)
        self.stopOptimizationButton.hide()
        self.connect(self.stopOptimizationButton, SIGNAL("clicked()"),
                     self.stopOptimizationClick)

        self.clearButton = OWGUI.button(self.manageBox, self, "Clear Results",
                                        self.clearResults)
        self.loadButton = OWGUI.button(self.manageBox, self, "Load",
                                       self.loadResults)
        self.saveButton = OWGUI.button(self.manageBox, self, "Save",
                                       self.saveResults)
        self.closeButton = OWGUI.button(self.manageBox, self, "Close Dialog",
                                        self.hide)

        self.changeProjectionFile()
        self.updateGUI()
        if self.orderAllAttributes: self.setAllAttributeRadio()
        else: self.setSubsetAttributeRadio()
    def __init__(self, parent=None, signalManager = None):
        "Constructor"
        OWWidget.__init__(self, parent, signalManager, "&Distributions", TRUE)
        # settings
        self.numberOfBars = 5
        self.barSize = 50
        self.showContinuousClassGraph=1
        self.showProbabilities = 1
        self.showConfidenceIntervals = 0
        self.smoothLines = 0
        self.lineWidth = 1
        self.showMainTitle = 0
        self.showXaxisTitle = 1
        self.showYaxisTitle = 1
        self.showYPaxisTitle = 1

        self.attribute = ""
        self.targetValue = 0
        self.visibleOutcomes = []
        self.outcomes = []

        # tmp values
        self.mainTitle = ""
        self.xaxisTitle = ""
        self.yaxisTitle = "frequency"
        self.yPaxisTitle = ""

        # GUI
#        self.tabs = OWGUI.tabWidget(self.controlArea)
#        self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main")
#        self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings")
        self.GeneralTab = self.SettingsTab = self.controlArea

        self.graph = OWDistributionGraph(self, self.mainArea)
        self.mainArea.layout().addWidget(self.graph)
        self.graph.setYRlabels(None)
        self.graph.setAxisScale(QwtPlot.yRight, 0.0, 1.0, 0.1)
        self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile)
        
        self.loadSettings()

        self.barSize = 50

        # inputs
        # data and graph temp variables
        self.inputs = [("Data", ExampleTable, self.setData, Default)]

        self.data = None
        self.outcomenames = []
        self.probGraphValues = []

        b = OWGUI.widgetBox(self.controlArea, "Variable", addSpace=True)
        self.variablesQCB = OWGUI.comboBox(b, self, "attribute", valueType = str, sendSelectedValue = True, callback=self.setVariable)
        OWGUI.widgetLabel(b, "Displayed outcomes")
        self.outcomesQLB = OWGUI.listBox(b, self, "visibleOutcomes", "outcomes", selectionMode = QListWidget.MultiSelection, callback = self.outcomeSelectionChange)

        # GUI connections
        # options dialog connections
#        b = OWGUI.widgetBox(self.SettingsTab, "Bars")
#        OWGUI.spin(b, self, "numberOfBars", label="Number of bars", min=5, max=60, step=5, callback=self.setNumberOfBars, callbackOnReturn=True)
#        self.numberOfBarsSlider = OWGUI.hSlider(self.SettingsTab, self, 'numberOfBars', box='Number of bars', minValue=5, maxValue=60, step=5, callback=self.setNumberOfBars, ticks=5)
#        self.numberOfBarsSlider.setTracking(0) # no change until the user stop dragging the slider

#        self.barSizeSlider = OWGUI.hSlider(self.SettingsTab, self, 'barSize', box="Bar size", minValue=30, maxValue=100, step=5, callback=self.setBarSize, ticks=10)
#        OWGUI.spin(b, self, "barSize", label="Bar size", min=30, max=100, step=5, callback=self.setBarSize, callbackOnReturn=True)

        box = OWGUI.widgetBox(self.SettingsTab, "General graph settings", addSpace=True)
        box.setMinimumWidth(180)
        box2 = OWGUI.widgetBox(box, orientation = "horizontal")
        OWGUI.checkBox(box2, self, 'showMainTitle', 'Main title', callback = self.setShowMainTitle)
        OWGUI.lineEdit(box2, self, 'mainTitle', callback = self.setMainTitle, enterPlaceholder=True)

        box3 = OWGUI.widgetBox(box, orientation = "horizontal")
        OWGUI.checkBox(box3, self, 'showXaxisTitle', 'X axis title', callback = self.setShowXaxisTitle)
        OWGUI.lineEdit(box3, self, 'xaxisTitle', callback = self.setXaxisTitle, enterPlaceholder=True)

        box4 = OWGUI.widgetBox(box, orientation = "horizontal")
        OWGUI.checkBox(box4, self, 'showYaxisTitle', 'Y axis title', callback = self.setShowYaxisTitle)
        OWGUI.lineEdit(box4, self, 'yaxisTitle', callback = self.setYaxisTitle, enterPlaceholder=True)

        OWGUI.checkBox(box, self, 'graph.showContinuousClassGraph', 'Show continuous class graph', callback=self.setShowContinuousClassGraph)
        OWGUI.spin(box, self, "numberOfBars", label="Number of bars", min=5, max=60, step=5, callback=self.setNumberOfBars, callbackOnReturn=True)

        self.probabilityPlotBox = box5 = OWGUI.widgetBox(self.SettingsTab, "Probability plot")
        self.showProb = OWGUI.checkBox(box5, self, 'showProbabilities', 'Show probabilities', callback = self.setShowProbabilities)
        self.targetQCB = OWGUI.comboBox(OWGUI.indentedBox(box5, sep=OWGUI.checkButtonOffsetHint(self.showProb)), self, "targetValue", label="Target value", valueType=int, callback=self.setTarget)

        box6 = OWGUI.widgetBox(box5, orientation = "horizontal")

        self.showYPaxisCheck = OWGUI.checkBox(box6, self, 'showYPaxisTitle', 'Axis title', callback = self.setShowYPaxisTitle)
        self.yPaxisEdit = OWGUI.lineEdit(box6, self, 'yPaxisTitle', callback = self.setYPaxisTitle, enterPlaceholder=True)
        self.confIntCheck = OWGUI.checkBox(box5, self, 'showConfidenceIntervals', 'Show confidence intervals', callback = self.setShowConfidenceIntervals)
        self.cbSmooth = OWGUI.checkBox(box5, self, 'smoothLines', 'Smooth probability lines', callback = self.setSmoothLines)
        self.showProb.disables = [self.showYPaxisCheck, self.yPaxisEdit, self.confIntCheck, self.targetQCB, self.cbSmooth]
        self.showProb.makeConsistent()


#        self.barSizeSlider = OWGUI.hSlider(box5, self, 'lineWidth', box='Line width', minValue=1, maxValue=9, step=1, callback=self.setLineWidth, ticks=1)
        
        OWGUI.rubber(self.SettingsTab)

        #add controls to self.controlArea widget

        self.icons = self.createAttributeIconDict()

        self.graph.numberOfBars = self.numberOfBars
        self.graph.barSize = self.barSize
        self.graph.setShowMainTitle(self.showMainTitle)
        self.graph.setShowXaxisTitle(self.showXaxisTitle)
        self.graph.setShowYLaxisTitle(self.showYaxisTitle)
        self.graph.setShowYRaxisTitle(self.showYPaxisTitle)
        self.graph.setMainTitle(self.mainTitle)
        self.graph.setXaxisTitle(self.xaxisTitle)
        self.graph.setYLaxisTitle(self.yaxisTitle)
        self.graph.setYRaxisTitle(self.yPaxisTitle)
        self.graph.showProbabilities = self.showProbabilities
        self.graph.showConfidenceIntervals = self.showConfidenceIntervals
        self.graph.smoothLines = self.smoothLines
        self.graph.lineWidth = self.lineWidth
        #self.graph.variableContinuous = self.VariableContinuous
        self.graph.targetValue = self.targetValue
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, 'LearningCurveC')

        self.inputs = [("Data", ExampleTable, self.dataset),
                       ("Learner", orange.Learner, self.learner, Multiple)]

        self.folds = 5  # cross validation folds
        self.steps = 10  # points in the learning curve
        self.scoringF = 0  # scoring function
        self.commitOnChange = 1  # compute curve on any change of parameters
        self.graphPointSize = 5  # size of points in the graphs
        self.graphDrawLines = 1  # draw lines between points in the graph
        self.graphShowGrid = 1  # show gridlines in the graph
        self.selectedLearners = []
        self.loadSettings()

        warnings.filterwarnings("ignore", ".*builtin attribute.*",
                                orange.AttributeWarning)

        self.setCurvePoints(
        )  # sets self.curvePoints, self.steps equidistantpoints from 1/self.steps to 1
        self.scoring = [("Classification Accuracy", orngStat.CA),
                        ("AUC", orngStat.AUC),
                        ("BrierScore", orngStat.BrierScore),
                        ("Information Score", orngStat.IS),
                        ("Sensitivity", orngStat.sens),
                        ("Specificity", orngStat.spec)]
        self.learners = [
        ]  # list of current learners from input channel, tuples (id, learner)
        self.data = None  # data on which to construct the learning curve
        self.curves = [
        ]  # list of evaluation results (one per learning curve point)
        self.scores = []  # list of current scores, learnerID:[learner scores]

        # GUI
        box = OWGUI.widgetBox(self.controlArea, "Info")
        self.infoa = OWGUI.widgetLabel(box, 'No data on input.')
        self.infob = OWGUI.widgetLabel(box, 'No learners.')

        ## class selection (classQLB)
        OWGUI.separator(self.controlArea)
        self.cbox = OWGUI.widgetBox(self.controlArea, "Learners")
        self.llb = OWGUI.listBox(self.cbox,
                                 self,
                                 "selectedLearners",
                                 selectionMode=QListWidget.MultiSelection,
                                 callback=self.learnerSelectionChanged)

        self.llb.setMinimumHeight(50)
        self.blockSelectionChanges = 0

        OWGUI.separator(self.controlArea)
        box = OWGUI.widgetBox(self.controlArea, "Evaluation Scores")
        scoringNames = [x[0] for x in self.scoring]
        OWGUI.comboBox(box,
                       self,
                       "scoringF",
                       items=scoringNames,
                       callback=self.computeScores)

        OWGUI.separator(self.controlArea)
        box = OWGUI.widgetBox(self.controlArea, "Options")
        OWGUI.spin(box,
                   self,
                   'folds',
                   2,
                   100,
                   step=1,
                   label='Cross validation folds:  ',
                   callback=lambda: self.computeCurve(self.commitOnChange))
        OWGUI.spin(box,
                   self,
                   'steps',
                   2,
                   100,
                   step=1,
                   label='Learning curve points:  ',
                   callback=[
                       self.setCurvePoints,
                       lambda: self.computeCurve(self.commitOnChange)
                   ])

        OWGUI.checkBox(box, self, 'commitOnChange',
                       'Apply setting on any change')
        self.commitBtn = OWGUI.button(box,
                                      self,
                                      "Apply Setting",
                                      callback=self.computeCurve,
                                      disabled=1)

        # start of content (right) area
        tabs = OWGUI.tabWidget(self.mainArea)

        # graph widget
        tab = OWGUI.createTabPage(tabs, "Graph")
        self.graph = OWGraph(tab)
        self.graph.setAxisAutoScale(QwtPlot.xBottom)
        self.graph.setAxisAutoScale(QwtPlot.yLeft)
        tab.layout().addWidget(self.graph)
        self.setGraphGrid()

        # table widget
        tab = OWGUI.createTabPage(tabs, "Table")
        self.table = OWGUI.table(tab, selectionMode=QTableWidget.NoSelection)

        self.resize(550, 200)
Ejemplo n.º 41
0
    def __init__(self, parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "Time Data Visualizer", TRUE)

        self.inputs =  [("Data", ExampleTable, self.setData, Default), ("Data Subset", ExampleTable, self.setSubsetData), ("Features", AttributeList, self.setShownAttributes)]
        self.outputs = [("Selected Data", ExampleTable), ("Other Data", ExampleTable)]

        # local variables
        self.autoSendSelection = 1
        self.toolbarSelection = 0
        self.colorSettings = None
        self.selectedSchemaIndex = 0

        self.graph = OWTimeDataVisualizerGraph(self, self.mainArea, "Time Data Visualizer")

        self.data = None
        self.subsetData = None

        #load settings
        self.loadSettings()

        #GUI
        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main")
        self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings")

        #add a graph widget
        self.mainArea.layout().addWidget(self.graph)
        self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile)

        #x attribute
        self.attrX = ""
        box = OWGUI.widgetBox(self.GeneralTab, "Time Attribute")
        # add an option to use the index of the example as time stamp
        #OWGUI.checkBox(box, self, 'graph.use', 'X axis title', callback = self.graph.setShowXaxisTitle)
        self.timeCombo = OWGUI.comboBox(box, self, "graph.timeAttr", callback = self.majorUpdateGraph, sendSelectedValue = 1, valueType = str)

        self.colorCombo = OWGUI.comboBox(self.GeneralTab, self, "graph.colorAttr", "Point Color", callback = self.updateGraph, sendSelectedValue = 1, valueType = str)

        # y attributes
        box = OWGUI.widgetBox(self.GeneralTab, "Visualized attributes")
        OWGUI.listBox(box, self, "graph.shownAttributeIndices", "graph.attributes", selectionMode = QListWidget.ExtendedSelection, sizeHint = QSize(150, 250))
        OWGUI.button(box, self, "Update listbox changes", callback = self.majorUpdateGraph)


        # zooming / selection
        self.zoomSelectToolbar = OWToolbars.ZoomSelectToolbar(self, self.GeneralTab, self.graph, self.autoSendSelection)
        self.connect(self.zoomSelectToolbar.buttonSendSelections, SIGNAL("clicked()"), self.sendSelections)

        # ####################################
        # SETTINGS TAB
        # point width
        pointBox = OWGUI.widgetBox(self.SettingsTab, "Point properties")
        OWGUI.hSlider(pointBox, self, 'graph.pointWidth', label = "Symbol size:   ", minValue=1, maxValue=10, step=1, callback = self.pointSizeChange)
        OWGUI.hSlider(pointBox, self, 'graph.alphaValue', label = "Transparency: ", minValue=0, maxValue=255, step=10, callback = self.alphaChange)

        # general graph settings
        box4 = OWGUI.widgetBox(self.SettingsTab, "General graph settings")
        OWGUI.checkBox(box4, self, 'graph.drawLines', 'Draw lines', callback = self.updateGraph)
        OWGUI.checkBox(box4, self, 'graph.drawPoints', 'Draw points (slower)', callback = self.updateGraph)
        OWGUI.checkBox(box4, self, 'graph.trackExamples', 'Track examples', callback = self.updateGraph)
        OWGUI.checkBox(box4, self, 'graph.showGrayRects', 'Show gray rectangles', callback = self.updateGraph)
        OWGUI.checkBox(box4, self, 'graph.showXaxisTitle', 'Show x axis title', callback = self.graph.setShowXaxisTitle)
        OWGUI.checkBox(box4, self, 'graph.showLegend', 'Show legend', callback = self.updateGraph)
        OWGUI.checkBox(box4, self, 'graph.useAntialiasing', 'Use antialiasing', callback = self.antialiasingChange)

        self.colorButtonsBox = OWGUI.widgetBox(self.SettingsTab, "Colors", orientation = "horizontal")
        OWGUI.button(self.colorButtonsBox, self, "Set Colors", self.setColors, tooltip = "Set the canvas background color, grid color and color palette for coloring continuous variables", debuggingEnabled = 0)

        box5 = OWGUI.widgetBox(self.SettingsTab, "Tooltips settings")
        OWGUI.comboBox(box5, self, "graph.tooltipKind", items = ["Don't Show Tooltips", "Show Visible Attributes", "Show All Attributes"], callback = self.updateGraph)

        OWGUI.checkBox(self.SettingsTab, self, 'autoSendSelection', 'Auto send selected data', box = "Data selection", callback = self.setAutoSendSelection, tooltip = "Send signals with selected data whenever the selection changes")
        self.graph.selectionChangedCallback = self.setAutoSendSelection

        OWGUI.rubber(self.GeneralTab)
        OWGUI.rubber(self.SettingsTab)
        self.icons = self.createAttributeIconDict()

        self.activateLoadedSettings()
        self.resize(700, 550)
Ejemplo n.º 42
0
    def __init__(self, parent=None, signalManager=None):
        """Widget creator."""

        # Standard call to creator of base class (OWWidget).
        OWWidget.__init__(self, parent, signalManager, wantMainArea=0)

        # Channel definitions...
        self.inputs = []
        self.outputs = [('Text data', Segmentation)]

        # Settings initializations...
        self.autoSend = True
        self.label = u'xml_tei_data'
        self.filterCriterion = u'author'
        self.filterValue = u'(all)'
        self.titleLabels = list()
        self.selectedTitles = list()
        self.importedURLs = list()
        self.displayAdvancedSettings = False

        # Always end Textable widget settings with the following 3 lines...
        self.uuid = None
        self.loadSettings()
        self.uuid = getWidgetUuid(self)

        # Other attributes...
        self.segmenter = Segmenter()
        self.processor = Processor()
        self.segmentation = Input()
        self.titleSeg = None
        self.filteredTitleSeg = None
        self.filterValues = dict()
        self.base_url =     \
          u'http://github.com/cltk/latin_text_latin_library/'
        self.document_base_url =     \
          u'http://github.com/cltk/latin_text_latin_library/'

        # Next two instructions are helpers from TextableUtils. Corresponding
        # interface elements are declared here and actually drawn below (at
        # their position in the UI)...
        self.infoBox = InfoBox(widget=self.controlArea)
        self.sendButton = SendButton(
            widget=self.controlArea,
            master=self,
            callback=self.sendData,
            infoBoxAttribute=u'infoBox',
            sendIfPreCallback=self.updateGUI,
        )

        # The AdvancedSettings class, also from TextableUtils, facilitates
        # the management of basic vs. advanced interface. An object from this 
        # class (here assigned to self.advancedSettings) contains two lists 
        # (basicWidgets and advanceWidgets), to which the corresponding
        # widgetBoxes must be added.
        self.advancedSettings = AdvancedSettings(
            widget=self.controlArea,
            master=self,
            callback=self.updateFilterValueList,
        )
        self.selectBox = OWGUI.widgetBox(
                widget              = self.controlArea,
                box                 = u'Select',
                orientation         = 'vertical',
        )
        self.sampleBox = OWGUI.widgetBox(
                widget              = self.selectBox,
                orientation         = 'vertical',
        )
        # User interface...

        # Advanced settings checkbox (basic/advanced interface will appear 
        # immediately after it...
        self.advancedSettings.draw()

        # Filter box (advanced settings only)
        filterBox = OWGUI.widgetBox(
            widget=self.controlArea,
            box=u'Filter',
            orientation=u'vertical',
        ) 
        
        OWGUI.separator(widget=filterBox, height=3)
        
        # The following lines add filterBox (and a vertical separator) to the
        # advanced interface...
        self.advancedSettings.advancedWidgets.append(filterBox)
        self.advancedSettings.advancedWidgetsAppendSeparator()

        # Title box
        titleBox = OWGUI.widgetBox(
            widget=self.controlArea,
            box=u'Titles',
            orientation=u'vertical',
        )
        CriterionCombo = OWGUI.comboBox(
            widget=titleBox,
            master=self,
            value=u'filterValue',
            sendSelectedValue=True,
            orientation=u'horizontal',
            label=u'Author:',
            labelWidth=180,
            callback=self.updateFilterValueList,
            tooltip=(
                u"Tool\n"
                u"tips."
            ),
        )
        CriterionCombo.setMinimumWidth(120)
        OWGUI.separator(widget=filterBox, height=3)
        self.filterValueCombo = OWGUI.comboBox(
            widget=titleBox,
            master=self,
            value=u'filterValue',
            sendSelectedValue=True,
            orientation=u'horizontal',
            label=u'Piece:',
            labelWidth=180,
            callback=self.updateTitleList,
            tooltip=(
                u"Tool\n"
                u"tips."
            ),
        )
        self.titleListbox = OWGUI.listBox(
            widget=titleBox,
            master=self,
            value=u'selectedTitles',    # setting (list)
            labels=u'titleLabels',      # setting (list)
            callback=self.sendButton.settingsChanged,
            tooltip=u"The list of titles whose content will be imported",
        )
        self.titleListbox.setMinimumHeight(150)
        self.titleListbox.setSelectionMode(3)
        OWGUI.separator(widget=titleBox, height=3)
        OWGUI.button(
            widget=titleBox,
            master=self,
            label=u'Refresh',
            callback=self.refreshTitleSeg,
            tooltip=u"Connect to Theatre-classique website and refresh list.",
        )
        # OWGUI.spin(
                # widget              = self.sampleBox,
                # master              = self,
                # value               = 'samplingRate',
                # min                 = 1,
                # max                 = 1,
                # orientation         = 'horizontal',
                # label               = u'Sampling rate (%):',
                # labelWidth          = 180,
                # callback            = self.sendButton.settingsChanged,
                # tooltip             = (
                        # u"The proportion of segments that will be sampled."
                # ),
        # )
        OWGUI.separator(widget=titleBox, height=3)

        OWGUI.separator(widget=self.controlArea, height=3)

        # From TextableUtils: a minimal Options box (only segmentation label).
        basicOptionsBox = BasicOptionsBox(self.controlArea, self)
 
        OWGUI.separator(widget=self.controlArea, height=3)

        # Now Info box and Send button must be drawn...
        self.infoBox.draw()
        self.sendButton.draw()
        
        # This initialization step needs to be done after infoBox has been 
        # drawn (because getTitleSeg may need to display an error message).
        self.getTitleSeg()

        # Send data if autoSend.
        self.sendButton.sendIf()
    def __init__(self, parent=None, signalManager=None, name="Select data"):
        OWWidget.__init__(self, parent, signalManager, name,
                          wantMainArea=0)  #initialize base class

        self.inputs = [("Data", ExampleTable, self.setData)]
        self.outputs = [("Matching Data", ExampleTable, Default),
                        ("Unmatched Data", ExampleTable)]

        self.name2var = {}  # key: variable name, item: orange.Variable
        self.Conditions = []

        self.currentVar = None
        self.NegateCondition = False
        self.currentOperatorDict = {
            orange.VarTypes.Continuous:
            Operator(Operator.operatorsC[0], orange.VarTypes.Continuous),
            orange.VarTypes.Discrete:
            Operator(Operator.operatorsD[0], orange.VarTypes.Discrete),
            orange.VarTypes.String:
            Operator(Operator.operatorsS[0], orange.VarTypes.String)
        }
        self.Num1 = 0.0
        self.Num2 = 0.0
        self.Str1 = ""
        self.Str2 = ""
        self.attrSearchText = ""
        self.currentVals = []
        self.CaseSensitive = False
        self.updateOnChange = True
        self.purgeAttributes = True
        self.purgeClasses = True
        self.oldPurgeClasses = True

        self.loadedVarNames = []
        self.loadedConditions = []
        self.loadSettings()

        w = QWidget(self)
        self.controlArea.layout().addWidget(w)
        grid = QGridLayout()
        grid.setMargin(0)
        w.setLayout(grid)

        boxAttrCond = OWGUI.widgetBox(self,
                                      '',
                                      orientation=QGridLayout(),
                                      addToLayout=0)
        grid.addWidget(boxAttrCond, 0, 0, 1, 3)
        glac = boxAttrCond.layout()
        glac.setColumnStretch(0, 2)
        glac.setColumnStretch(1, 1)
        glac.setColumnStretch(2, 2)

        boxAttr = OWGUI.widgetBox(self, 'Attribute', addToLayout=0)
        glac.addWidget(boxAttr, 0, 0)
        self.lbAttr = OWGUI.listBox(boxAttr, self, callback=self.lbAttrChange)

        self.leSelect = OWGUI.lineEdit(boxAttr,
                                       self,
                                       "attrSearchText",
                                       label="Search: ",
                                       orientation="horizontal",
                                       callback=self.setLbAttr,
                                       callbackOnType=1)

        boxOper = OWGUI.widgetBox(self, 'Operator')
        # operators 0: empty
        self.lbOperatosNone = OWGUI.listBox(boxOper, self)
        # operators 1: discrete
        self.lbOperatorsD = OWGUI.listBox(boxOper,
                                          self,
                                          callback=self.lbOperatorsChange)
        self.lbOperatorsD.hide()
        self.lbOperatorsD.addItems(Operator.operatorsD +
                                   [Operator.operatorDef])
        # operators 2: continuous
        self.lbOperatorsC = OWGUI.listBox(boxOper,
                                          self,
                                          callback=self.lbOperatorsChange)
        self.lbOperatorsC.hide()
        self.lbOperatorsC.addItems(Operator.operatorsC +
                                   [Operator.operatorDef])
        # operators 6: string
        self.lbOperatorsS = OWGUI.listBox(boxOper,
                                          self,
                                          callback=self.lbOperatorsChange)
        self.lbOperatorsS.hide()
        self.lbOperatorsS.addItems(Operator.operatorsS +
                                   [Operator.operatorDef])
        self.lbOperatorsDict = {
            0: self.lbOperatosNone,
            orange.VarTypes.Continuous: self.lbOperatorsC,
            orange.VarTypes.Discrete: self.lbOperatorsD,
            orange.VarTypes.String: self.lbOperatorsS
        }

        glac.addWidget(boxOper, 0, 1)
        self.cbNot = OWGUI.checkBox(boxOper, self, "NegateCondition", "Negate")

        self.boxIndices = {}
        self.valuesStack = QStackedWidget(self)
        glac.addWidget(self.valuesStack, 0, 2)

        # values 0: empty
        boxVal = OWGUI.widgetBox(self, "Values", addToLayout=0)
        self.boxIndices[0] = boxVal
        self.valuesStack.addWidget(boxVal)

        # values 1: discrete
        boxVal = OWGUI.widgetBox(self, "Values", addToLayout=0)
        self.boxIndices[orange.VarTypes.Discrete] = boxVal
        self.valuesStack.addWidget(boxVal)
        self.lbVals = OWGUI.listBox(boxVal, self, callback=self.lbValsChange)

        # values 2: continuous between num and num
        boxVal = OWGUI.widgetBox(self, "Values", addToLayout=0)
        self.boxIndices[orange.VarTypes.Continuous] = boxVal
        self.valuesStack.addWidget(boxVal)
        self.leNum1 = OWGUI.lineEdit(boxVal,
                                     self,
                                     "Num1",
                                     validator=QDoubleValidator(self))
        self.lblAndCon = OWGUI.widgetLabel(boxVal, "and")
        self.leNum2 = OWGUI.lineEdit(boxVal,
                                     self,
                                     "Num2",
                                     validator=QDoubleValidator(self))
        boxAttrStat = OWGUI.widgetBox(boxVal, "Statistics")
        self.lblMin = OWGUI.widgetLabel(boxAttrStat, "Min: ")
        self.lblAvg = OWGUI.widgetLabel(boxAttrStat, "Avg: ")
        self.lblMax = OWGUI.widgetLabel(boxAttrStat, "Max: ")
        self.lblDefined = OWGUI.widgetLabel(boxAttrStat,
                                            "Defined for ---- examples")
        OWGUI.rubber(boxAttrStat)

        # values 6: string between str and str
        boxVal = OWGUI.widgetBox(self, "Values", addToLayout=0)
        self.boxIndices[orange.VarTypes.String] = boxVal
        self.valuesStack.addWidget(boxVal)
        self.leStr1 = OWGUI.lineEdit(boxVal, self, "Str1")
        self.lblAndStr = OWGUI.widgetLabel(boxVal, "and")
        self.leStr2 = OWGUI.lineEdit(boxVal, self, "Str2")
        self.cbCaseSensitive = OWGUI.checkBox(boxVal, self, "CaseSensitive",
                                              "Case sensitive")

        self.boxButtons = OWGUI.widgetBox(self, orientation="horizontal")
        grid.addWidget(self.boxButtons, 1, 0, 1, 3)
        self.btnNew = OWGUI.button(self.boxButtons, self, "Add",
                                   self.OnNewCondition)
        self.btnUpdate = OWGUI.button(self.boxButtons, self, "Modify",
                                      self.OnUpdateCondition)
        self.btnRemove = OWGUI.button(self.boxButtons, self, "Remove",
                                      self.OnRemoveCondition)
        self.btnOR = OWGUI.button(self.boxButtons, self, "OR",
                                  self.OnDisjunction)
        self.btnMoveUp = OWGUI.button(self.boxButtons, self, "Move Up",
                                      self.btnMoveUpClicked)
        self.btnMoveDown = OWGUI.button(self.boxButtons, self, "Move Down",
                                        self.btnMoveDownClicked)
        self.btnRemove.setEnabled(False)
        self.btnUpdate.setEnabled(False)
        self.btnMoveUp.setEnabled(False)
        self.btnMoveDown.setEnabled(False)

        boxCriteria = OWGUI.widgetBox(self,
                                      'Data Selection Criteria',
                                      addToLayout=0)
        grid.addWidget(boxCriteria, 2, 0, 1, 3)
        self.criteriaTable = QTableWidget(boxCriteria)
        boxCriteria.layout().addWidget(self.criteriaTable)
        self.criteriaTable.setShowGrid(False)
        self.criteriaTable.setSelectionMode(QTableWidget.SingleSelection)
        self.criteriaTable.setColumnCount(2)
        self.criteriaTable.verticalHeader().setClickable(False)
        #self.criteriaTable.verticalHeader().setResizeEnabled(False,-1)
        self.criteriaTable.horizontalHeader().setClickable(False)
        self.criteriaTable.setHorizontalHeaderLabels(["Active", "Condition"])
        self.criteriaTable.resizeColumnToContents(0)
        self.criteriaTable.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.criteriaTable.horizontalHeader().setResizeMode(
            1, QHeaderView.Stretch)
        self.connect(self.criteriaTable, SIGNAL('cellClicked(int, int)'),
                     self.currentCriteriaChange)

        boxDataIn = OWGUI.widgetBox(self, 'Data In', addToLayout=0)
        grid.addWidget(boxDataIn, 3, 0)
        self.dataInExamplesLabel = OWGUI.widgetLabel(boxDataIn, "num examples")
        self.dataInAttributesLabel = OWGUI.widgetLabel(boxDataIn,
                                                       "num attributes")
        OWGUI.rubber(boxDataIn)

        boxDataOut = OWGUI.widgetBox(self, 'Data Out', addToLayout=0)
        grid.addWidget(boxDataOut, 3, 1)
        self.dataOutExamplesLabel = OWGUI.widgetLabel(boxDataOut,
                                                      "num examples")
        self.dataOutAttributesLabel = OWGUI.widgetLabel(
            boxDataOut, "num attributes")
        OWGUI.rubber(boxDataOut)

        boxSettings = OWGUI.widgetBox(self, 'Commit', addToLayout=0)
        grid.addWidget(boxSettings, 3, 2)
        cb = OWGUI.checkBox(boxSettings,
                            self,
                            "purgeAttributes",
                            "Remove unused values/attributes",
                            box=None,
                            callback=self.OnPurgeChange)
        self.purgeClassesCB = OWGUI.checkBox(OWGUI.indentedBox(
            boxSettings, sep=OWGUI.checkButtonOffsetHint(cb)),
                                             self,
                                             "purgeClasses",
                                             "Remove unused classes",
                                             callback=self.OnPurgeChange)
        OWGUI.checkBox(boxSettings,
                       self,
                       "updateOnChange",
                       "Commit on change",
                       box=None)
        btnUpdate = OWGUI.button(boxSettings,
                                 self,
                                 "Commit",
                                 self.setOutput,
                                 default=True)

        self.icons = self.createAttributeIconDict()
        self.setData(None)
        self.lbOperatorsD.setCurrentRow(0)
        self.lbOperatorsC.setCurrentRow(0)
        self.lbOperatorsS.setCurrentRow(0)
        self.resize(500, 661)
        grid.setRowStretch(0, 10)
        grid.setRowStretch(2, 10)
Ejemplo n.º 44
0
    def __init__(self, parent = None, signalManager = None, name = "Pade"):
        OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0)  #initialize base class
        self.inputs = [("Data", ExampleTable, self.onDataInput)]
        self.outputs = [("Data", ExampleTable)]

        self.attributes = []
        self.dimensions = []
        self.output = 0
        self.outputAttr = 0
        self.derivativeAsMeta = 0
        self.savedDerivativeAsMeta = 0
        self.correlationsAsMeta = 1
        self.differencesAsMeta = 1
        self.originalAsMeta = 1
        self.enableThreshold = 0
        self.threshold = 0.0
        self.method = 2
        self.useMQCNotation = False
        #self.persistence = 40

        self.nNeighbours = 30

        self.loadSettings()

        box = OWGUI.widgetBox(self.controlArea, "Attributes") #, addSpace = True)
        lb = self.lb = OWGUI.listBox(box, self, "dimensions", "attributes", selectionMode=QListWidget.MultiSelection, callback=self.dimensionsChanged)
        hbox = OWGUI.widgetBox(box, orientation=0)
        OWGUI.button(hbox, self, "All", callback=self.onAllAttributes)
        OWGUI.button(hbox, self, "None", callback=self.onNoAttributes)
        lb.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
        lb.setMinimumSize(200, 200)
        
        OWGUI.separator(self.controlArea)

        box = OWGUI.widgetBox(self.controlArea, "Method") #, addSpace = True)
        OWGUI.comboBox(box, self, "method", callback = self.methodChanged, items = self.methodNames)
#        self.nNeighboursSpin = OWGUI.spin(box, self, "nNeighbours", 10, 200, 10, label = "Number of neighbours" + "  ", callback = self.methodChanged)
        #self.persistenceSpin = OWGUI.spin(box, self, "persistence", 0, 100, 5, label = "Persistence (0-100)" + "  ", callback = self.methodChanged, controlWidth=50)

        OWGUI.separator(box)
        hbox = OWGUI.widgetBox(box, orientation=0)
        threshCB = OWGUI.checkBox(hbox, self, "enableThreshold", "Ignore differences below ")
#        OWGUI.rubber(hbox, orientation = 0)
        ledit = OWGUI.lineEdit(hbox, self, "threshold", valueType=float, validator=QDoubleValidator(0, 1e30, 0, self), controlWidth=50)
        threshCB.disables.append(ledit)
        threshCB.makeConsistent()
        OWGUI.checkBox(box, self, "useMQCNotation", label = "Use MQC notation")

        OWGUI.separator(self.controlArea)
        
        box = OWGUI.radioButtonsInBox(self.controlArea, self, "output", self.outputTypes, box="Output class", callback=self.dimensionsChanged)
        self.outputLB = OWGUI.comboBox(OWGUI.indentedBox(box, sep=OWGUI.checkButtonOffsetHint(box.buttons[-1])), self, "outputAttr", callback=self.outputDiffChanged)
        
        OWGUI.separator(self.controlArea)
        
        box = OWGUI.widgetBox(self.controlArea, "Output meta attributes") #, addSpace = True)
        self.metaCB = OWGUI.checkBox(box, self, "derivativeAsMeta", label="Qualitative constraint")
        OWGUI.checkBox(box, self, "differencesAsMeta", label="Derivatives of selected attributes")
        OWGUI.checkBox(box, self, "correlationsAsMeta", label="Absolute values of derivatives")
        OWGUI.checkBox(box, self, "originalAsMeta", label="Original class attribute")

        self.applyButton = OWGUI.button(self.controlArea, self, "&Apply", callback=self.apply, disabled=True, default=True)
        
        self.contAttributes = []
        self.dimensions = []
        self.data = None
Ejemplo n.º 45
0
    def __init__(self, parent=None, signalManager=None, name="Interactive Discretization"):
        OWWidget.__init__(self, parent, signalManager, name)
        self.showBaseLine=1
        self.showLookaheadLine=1
        self.showTargetClassProb=1
        self.showRug=0
        self.snap=1
        self.measure=0
        self.targetClass=0
        self.discretization = self.classDiscretization = self.indiDiscretization = 1
        self.intervals = self.classIntervals = self.indiIntervals = 3
        self.outputOriginalClass = True
        self.indiData = []
        self.indiLabels = []
        self.resetIndividuals = 0
        self.customClassSplits = ""

        self.selectedAttr = 0
        self.customSplits = ["", "", ""]
        self.autoApply = True
        self.dataChanged = False
        self.autoSynchronize = True
        self.pointsChanged = False

        self.customLineEdits = []
        self.needsDiscrete = []

        self.data = self.originalData = None

        self.loadSettings()

        self.inputs=[("Data", ExampleTable, self.setData)]
        self.outputs=[("Data", ExampleTable)]
        self.measures=[("Information gain", orange.MeasureAttribute_info()),
                       #("Gain ratio", orange.MeasureAttribute_gainRatio),
                       ("Gini", orange.MeasureAttribute_gini()),
                       ("chi-square", orange.MeasureAttribute_chiSquare()),
                       ("chi-square prob.", orange.MeasureAttribute_chiSquare(computeProbabilities=1)),
                       ("Relevance", orange.MeasureAttribute_relevance()),
                       ("ReliefF", orange.MeasureAttribute_relief())]
        self.discretizationMethods=["Leave continuous", "Entropy-MDL discretization", "Equal-frequency discretization", "Equal-width discretization", "Remove continuous attributes"]
        self.classDiscretizationMethods=["Equal-frequency discretization", "Equal-width discretization"]
        self.indiDiscretizationMethods=["Default", "Leave continuous", "Entropy-MDL discretization", "Equal-frequency discretization", "Equal-width discretization", "Remove attribute"]

        self.mainHBox =  OWGUI.widgetBox(self.mainArea, orientation=0)

        vbox = self.controlArea
        box = OWGUI.radioButtonsInBox(vbox, self, "discretization", self.discretizationMethods[:-1], "Default discretization", callback=[self.clearLineEditFocus, self.defaultMethodChanged])
        self.needsDiscrete.append(box.buttons[1])
        box.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed))
        indent = OWGUI.checkButtonOffsetHint(self.needsDiscrete[-1])
        self.interBox = OWGUI.widgetBox(OWGUI.indentedBox(box, sep=indent))
        OWGUI.widgetLabel(self.interBox, "Number of intervals (for equal width/frequency)")
        OWGUI.separator(self.interBox, height=4)
        self.intervalSlider=OWGUI.hSlider(OWGUI.indentedBox(self.interBox), self, "intervals", None, 2, 10, callback=[self.clearLineEditFocus, self.defaultMethodChanged])
        OWGUI.appendRadioButton(box, self, "discretization", self.discretizationMethods[-1])
        OWGUI.separator(vbox)

        ribg = OWGUI.radioButtonsInBox(vbox, self, "resetIndividuals", ["Use default discretization for all attributes", "Explore and set individual discretizations"], "Individual attribute treatment", callback = self.setAllIndividuals)
        ll = QWidget(ribg)
        ll.setFixedHeight(1)
        OWGUI.widgetLabel(ribg, "Set discretization of all attributes to")
        hcustbox = OWGUI.widgetBox(OWGUI.indentedBox(ribg), 0, 0)
        for c in range(1, 4):
            OWGUI.appendRadioButton(ribg, self, "resetIndividuals", "Custom %i" % c, insertInto = hcustbox)

        OWGUI.separator(vbox)

        box = self.classDiscBox = OWGUI.radioButtonsInBox(vbox, self, "classDiscretization", self.classDiscretizationMethods, "Class discretization", callback=[self.clearLineEditFocus, self.classMethodChanged])
        cinterBox = OWGUI.widgetBox(box)
        self.intervalSlider=OWGUI.hSlider(OWGUI.indentedBox(cinterBox, sep=indent), self, "classIntervals", None, 2, 10, callback=[self.clearLineEditFocus, self.classMethodChanged], label="Number of intervals")
        hbox = OWGUI.widgetBox(box, orientation = 0)
        OWGUI.appendRadioButton(box, self, "discretization", "Custom" + "  ", insertInto = hbox)
        self.classCustomLineEdit = OWGUI.lineEdit(hbox, self, "customClassSplits", callback = self.classCustomChanged, focusInCallback = self.classCustomSelected)
#        Can't validate - need to allow spaces
        box.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed))
        OWGUI.separator(box)
        self.classIntervalsLabel = OWGUI.widgetLabel(box, "Current splits: ")
        OWGUI.separator(box)
        OWGUI.checkBox(box, self, "outputOriginalClass", "Output original class", callback = self.commitIf)
        OWGUI.widgetLabel(box, "("+"Widget always uses discretized class internally."+")")

        OWGUI.separator(vbox)
        #OWGUI.rubber(vbox)

        box = OWGUI.widgetBox(vbox, "Commit")
        applyButton = OWGUI.button(box, self, "Commit", callback = self.commit, default=True)
        autoApplyCB = OWGUI.checkBox(box, self, "autoApply", "Commit automatically", callback=[self.clearLineEditFocus])
        OWGUI.setStopper(self, applyButton, autoApplyCB, "dataChanged", self.commit)
        OWGUI.rubber(vbox)

        #self.mainSeparator = OWGUI.separator(self.mainHBox, width=25)        # space between control and main area
        self.mainIABox =  OWGUI.widgetBox(self.mainHBox, "Individual attribute settings")
        self.mainBox = OWGUI.widgetBox(self.mainIABox, orientation=0)
        OWGUI.separator(self.mainIABox)#, height=30)
        graphBox = OWGUI.widgetBox(self.mainIABox, "", orientation=0)
        
        
#        self.needsDiscrete.append(graphBox)
        graphOptBox = OWGUI.widgetBox(graphBox)
        OWGUI.separator(graphBox, width=10)
        
        graphGraphBox = OWGUI.widgetBox(graphBox)
        self.graph = DiscGraph(self, graphGraphBox)
        graphGraphBox.layout().addWidget(self.graph)
        reportButton2 = OWGUI.button(graphGraphBox, self, "Report Graph", callback = self.reportGraph, debuggingEnabled=0)

        #graphOptBox.layout().setSpacing(4)
        box = OWGUI.widgetBox(graphOptBox, "Split gain measure", addSpace=True)
        self.measureCombo=OWGUI.comboBox(box, self, "measure", orientation=0, items=[e[0] for e in self.measures], callback=[self.clearLineEditFocus, self.graph.invalidateBaseScore, self.graph.plotBaseCurve])
        OWGUI.checkBox(box, self, "showBaseLine", "Show discretization gain", callback=[self.clearLineEditFocus, self.graph.plotBaseCurve])
        OWGUI.checkBox(box, self, "showLookaheadLine", "Show lookahead gain", callback=self.clearLineEditFocus)
        self.needsDiscrete.append(box)

        box = OWGUI.widgetBox(graphOptBox, "Target class", addSpace=True)
        self.targetCombo=OWGUI.comboBox(box, self, "targetClass", orientation=0, callback=[self.clearLineEditFocus, self.graph.targetClassChanged])
        stc = OWGUI.checkBox(box, self, "showTargetClassProb", "Show target class probability", callback=[self.clearLineEditFocus, self.graph.plotProbCurve])
        OWGUI.checkBox(box, self, "showRug", "Show rug (may be slow)", callback=[self.clearLineEditFocus, self.graph.plotRug])
        self.needsDiscrete.extend([self.targetCombo, stc])

        box = OWGUI.widgetBox(graphOptBox, "Editing", addSpace=True)
        OWGUI.checkBox(box, self, "snap", "Snap to grid", callback=[self.clearLineEditFocus])
        syncCB = OWGUI.checkBox(box, self, "autoSynchronize", "Apply on the fly", callback=self.clearLineEditFocus)
        syncButton = OWGUI.button(box, self, "Apply", callback = self.synchronizePressed)
        OWGUI.setStopper(self, syncButton, syncCB, "pointsChanged", self.synchronize)
        OWGUI.rubber(graphOptBox)

        self.attrList = OWGUI.listBox(self.mainBox, self, callback = self.individualSelected)
        self.attrList.setItemDelegate(CustomListItemDelegate(self.attrList))
        self.attrList.setFixedWidth(300)

        self.defaultMethodChanged()

        OWGUI.separator(self.mainBox, width=10)
        box = OWGUI.radioButtonsInBox(OWGUI.widgetBox(self.mainBox), self, "indiDiscretization", [], callback=[self.clearLineEditFocus, self.indiMethodChanged])
        #hbbox = OWGUI.widgetBox(box)
        #hbbox.layout().setSpacing(4)
        for meth in self.indiDiscretizationMethods[:-1]:
            OWGUI.appendRadioButton(box, self, "indiDiscretization", meth)
        self.needsDiscrete.append(box.buttons[2])
        self.indiInterBox = OWGUI.indentedBox(box, sep=indent, orientation = "horizontal")
        OWGUI.widgetLabel(self.indiInterBox, "Num. of intervals: ")
        self.indiIntervalSlider = OWGUI.hSlider(self.indiInterBox, self, "indiIntervals", None, 2, 10, callback=[self.clearLineEditFocus, self.indiMethodChanged], width = 100)
        OWGUI.rubber(self.indiInterBox) 
        OWGUI.appendRadioButton(box, self, "indiDiscretization", self.indiDiscretizationMethods[-1])
        #OWGUI.rubber(hbbox)
        #OWGUI.separator(box)
        #hbbox = OWGUI.widgetBox(box)
        for i in range(3):
            hbox = OWGUI.widgetBox(box, orientation = "horizontal")
            OWGUI.appendRadioButton(box, self, "indiDiscretization", "Custom %i" % (i+1) + " ", insertInto = hbox)
            le = OWGUI.lineEdit(hbox, self, "", callback = lambda w=i: self.customChanged(w), focusInCallback = lambda w=i: self.customSelected(w))
            le.setFixedWidth(110)
            self.customLineEdits.append(le)
            OWGUI.toolButton(hbox, self, "CC", width=30, callback = lambda w=i: self.copyToCustom(w))
            OWGUI.rubber(hbox)
        OWGUI.rubber(box)

        #self.controlArea.setFixedWidth(0)

        self.contAttrIcon =  self.createAttributeIconDict()[orange.VarTypes.Continuous]
        
        self.setAllIndividuals()
    def __init__(self, parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "Predictions")

        self.callbackDeposit = []
        self.inputs = [("Data", ExampleTable, self.setData), ("Predictors", orange.Classifier, self.setPredictor, Multiple)]
        self.outputs = [("Predictions", ExampleTable)]
        self.predictors = {}

        # saveble settings
        self.showProb = 1;
        self.showClass = 1
        self.ShowAttributeMethod = 0
        self.sendOnChange = 1
        self.classes = []
        self.selectedClasses = []
        self.loadSettings()
        self.datalabel = "N/A"
        self.predictorlabel = "N/A"
        self.tasklabel = "N/A"
        self.precision = 2
        self.doPrediction = False
        self.outvar = None # current output variable (set by the first predictor/data set send in)

        self.data = None
        self.changedFlag = False
        
        self.loadSettings()

        # GUI - Options

        # Options - classification
        ibox = OWGUI.widgetBox(self.controlArea, "Info")
        OWGUI.label(ibox, self, "Data: %(datalabel)s")
        OWGUI.label(ibox, self, "Predictors: %(predictorlabel)s")
        OWGUI.label(ibox, self, "Task: %(tasklabel)s")
        OWGUI.separator(self.controlArea)
        
        self.copt = OWGUI.widgetBox(self.controlArea, "Options (classification)")
        self.copt.setDisabled(1)
        cb = OWGUI.checkBox(self.copt, self, 'showProb', "Show predicted probabilities", callback=self.setPredictionDelegate)#self.updateTableOutcomes)

#        self.lbClasses = OWGUI.listBox(self.copt, self, selectionMode = QListWidget.MultiSelection, callback = self.updateTableOutcomes)
        ibox = OWGUI.indentedBox(self.copt, sep=OWGUI.checkButtonOffsetHint(cb))
        self.lbcls = OWGUI.listBox(ibox, self, "selectedClasses", "classes",
                                   callback=[self.setPredictionDelegate, self.checksendpredictions],
#                                   callback=[self.updateTableOutcomes, self.checksendpredictions],
                                   selectionMode=QListWidget.MultiSelection)
        self.lbcls.setFixedHeight(50)

        OWGUI.spin(ibox, self, "precision", 1, 6, label="No. of decimals: ",
                   orientation=0, callback=self.setPredictionDelegate) #self.updateTableOutcomes)
        
        cb.disables.append(ibox)
        ibox.setEnabled(bool(self.showProb))

        OWGUI.checkBox(self.copt, self, 'showClass', "Show predicted class",
                       callback=[self.setPredictionDelegate, self.checksendpredictions])
#                       callback=[self.updateTableOutcomes, self.checksendpredictions])

        OWGUI.separator(self.controlArea)

        self.att = OWGUI.widgetBox(self.controlArea, "Data attributes")
        OWGUI.radioButtonsInBox(self.att, self, 'ShowAttributeMethod', ['Show all', 'Hide all'], callback=lambda :self.setDataModel(self.data)) #self.updateAttributes)
        self.att.setDisabled(1)
        OWGUI.rubber(self.controlArea)

        OWGUI.separator(self.controlArea)
        self.outbox = OWGUI.widgetBox(self.controlArea, "Output")
        
        b = self.commitBtn = OWGUI.button(self.outbox, self, "Send Predictions", callback=self.sendpredictions, default=True)
        cb = OWGUI.checkBox(self.outbox, self, 'sendOnChange', 'Send automatically')
        OWGUI.setStopper(self, b, cb, "changedFlag", callback=self.sendpredictions)
        OWGUI.checkBox(self.outbox, self, "doPrediction", "Replace/add predicted class",
                       tooltip="Apply the first predictor to input examples and replace/add the predicted value as the new class variable.",
                       callback=self.checksendpredictions)

        self.outbox.setDisabled(1)

        ## GUI table

        self.splitter = splitter = QSplitter(Qt.Horizontal, self.mainArea)
        self.dataView = QTableView()
        self.predictionsView = QTableView()
        
        self.dataView.verticalHeader().setDefaultSectionSize(22)
        self.dataView.setHorizontalScrollMode(QTableWidget.ScrollPerPixel)
        self.dataView.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.dataView.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        
        self.predictionsView.verticalHeader().setDefaultSectionSize(22)
        self.predictionsView.setHorizontalScrollMode(QTableWidget.ScrollPerPixel)
        self.predictionsView.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self.predictionsView.verticalHeader().hide()
        
        
#        def syncVertical(value):
#            """ sync vertical scroll positions of the two views
#            """
#            v1 = self.predictionsView.verticalScrollBar().value()
#            if v1 != value:
#                self.predictionsView.verticalScrollBar().setValue(value)
#            v2 = self.dataView.verticalScrollBar().value()
#            if v2 != value:
#                self.dataView.verticalScrollBar().setValue(v1)
                
        self.connect(self.dataView.verticalScrollBar(), SIGNAL("valueChanged(int)"), self.syncVertical)
        self.connect(self.predictionsView.verticalScrollBar(), SIGNAL("valueChanged(int)"), self.syncVertical)
        
        splitter.addWidget(self.dataView)
        splitter.addWidget(self.predictionsView)
        splitter.setHandleWidth(3)
        splitter.setChildrenCollapsible(False)
        self.mainArea.layout().addWidget(splitter)
        
        self.spliter_restore_state = -1, 0
        self.dataModel = None
        self.predictionsModel = None
        
        self.resize(800, 600)
        
        self.handledAllSignalsFlag = False
Ejemplo n.º 47
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, "Predictions")

        self.callbackDeposit = []
        self.inputs = [("Examples", ExampleTable, self.setData),
                       ("Predictors", orange.Classifier, self.setPredictor,
                        Multiple)]
        self.outputs = [("Predictions", ExampleTable)]
        self.predictors = {}

        # saveble settings
        self.showProb = 1
        self.showClass = 1
        self.ShowAttributeMethod = 0
        self.sendOnChange = 1
        self.classes = []
        self.selectedClasses = []
        self.loadSettings()
        self.datalabel = "N/A"
        self.predictorlabel = "N/A"
        self.tasklabel = "N/A"
        self.precision = 2
        self.outvar = None  # current output variable (set by the first predictor/data set send in)

        self.data = None

        # GUI - Options

        # Options - classification
        ibox = OWGUI.widgetBox(self.controlArea, "Info")
        OWGUI.label(ibox, self, "Data: %(datalabel)s")
        OWGUI.label(ibox, self, "Predictors: %(predictorlabel)s")
        OWGUI.label(ibox, self, "Task: %(tasklabel)s")
        OWGUI.separator(self.controlArea)

        self.copt = OWGUI.widgetBox(self.controlArea,
                                    "Options (classification)")
        self.copt.setDisabled(1)
        OWGUI.checkBox(self.copt,
                       self,
                       'showProb',
                       "Show predicted probabilities",
                       callback=self.updateTableOutcomes)

        #        self.lbClasses = OWGUI.listBox(self.copt, self, selectionMode = QListWidget.MultiSelection, callback = self.updateTableOutcomes)

        self.lbcls = OWGUI.listBox(
            self.copt,
            self,
            "selectedClasses",
            "classes",
            callback=[self.updateTableOutcomes, self.checksendpredictions],
            selectionMode=QListWidget.MultiSelection)
        self.lbcls.setFixedHeight(50)

        OWGUI.spin(self.copt,
                   self,
                   "precision",
                   1,
                   6,
                   label="No. of decimals: ",
                   orientation=0,
                   callback=self.updateTableOutcomes)

        OWGUI.checkBox(
            self.copt,
            self,
            'showClass',
            "Show predicted class",
            callback=[self.updateTableOutcomes, self.checksendpredictions])

        # Options - regression
        # self.ropt = QVButtonGroup("Options (regression)", self.controlArea)
        # OWGUI.checkBox(self.ropt, self, 'showClass', "Show predicted class",
        #                callback=[self.updateTableOutcomes, self.checksendpredictions])
        # self.ropt.hide()

        OWGUI.separator(self.controlArea)

        self.att = OWGUI.widgetBox(self.controlArea, "Data attributes")
        OWGUI.radioButtonsInBox(self.att,
                                self,
                                'ShowAttributeMethod',
                                ['Show all', 'Hide all'],
                                callback=self.updateAttributes)
        self.att.setDisabled(1)
        OWGUI.rubber(self.controlArea)

        OWGUI.separator(self.controlArea)
        self.outbox = OWGUI.widgetBox(self.controlArea, "Output")

        self.commitBtn = OWGUI.button(self.outbox,
                                      self,
                                      "Send Predictions",
                                      callback=self.sendpredictions)
        OWGUI.checkBox(self.outbox, self, 'sendOnChange', 'Send automatically')

        self.outbox.setDisabled(1)

        # GUI - Table
        self.table = OWGUI.table(self.mainArea,
                                 selectionMode=QTableWidget.NoSelection)

        self.table.setItemDelegate(OWGUI.TableBarItem(self))

        self.header = self.table.horizontalHeader()
        self.vheader = self.table.verticalHeader()
        # manage sorting (not correct, does not handle real values)
        self.connect(self.header, SIGNAL("sectionPressed(int)"), self.sort)
        self.sortby = -1
        self.resize(800, 600)
Ejemplo n.º 48
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, "Confusion Matrix", 1)

        # inputs
        self.inputs = [("Evaluation Results", orngTest.ExperimentResults,
                        self.setTestResults, Default)]
        self.outputs = [("Selected Examples", ExampleTable, 8)]

        self.selectedLearner = []
        self.learnerNames = []
        self.selectionDirty = 0
        self.autoApply = True
        self.appendPredictions = True
        self.appendProbabilities = False
        self.shownQuantity = 0

        self.learnerList = OWGUI.listBox(self.controlArea,
                                         self,
                                         "selectedLearner",
                                         "learnerNames",
                                         box="Learners",
                                         callback=self.learnerChanged)
        self.learnerList.setMinimumHeight(100)
        OWGUI.separator(self.controlArea)

        OWGUI.comboBox(self.controlArea,
                       self,
                       "shownQuantity",
                       items=self.quantities,
                       box="Show",
                       callback=self.reprint)

        box = OWGUI.widgetBox(self.controlArea, "Selection", addSpace=True)
        OWGUI.button(box, self, "Correct", callback=self.selectCorrect)
        OWGUI.button(box, self, "Misclassified", callback=self.selectWrong)
        OWGUI.button(box, self, "None", callback=self.selectNone)

        box = OWGUI.widgetBox(self.controlArea, "Output")
        OWGUI.checkBox(box,
                       self,
                       "appendPredictions",
                       "Append class predictions",
                       callback=self.sendIf)
        OWGUI.checkBox(box,
                       self,
                       "appendProbabilities",
                       "Append predicted class probabilities",
                       callback=self.sendIf)
        applyButton = OWGUI.button(box, self, "Commit", callback=self.sendData)
        autoApplyCB = OWGUI.checkBox(box, self, "autoApply",
                                     "Commit automatically")
        OWGUI.setStopper(self, applyButton, autoApplyCB, "selectionDirty",
                         self.sendData)

        import sip
        sip.delete(self.mainArea.layout())
        self.layout = QGridLayout(self.mainArea)

        self.layout.addWidget(OWGUI.widgetLabel(self.mainArea, "Prediction"),
                              0, 1, Qt.AlignCenter)
        self.layout.addWidget(
            OWGUI.widgetLabel(self.mainArea, "Correct Class  "), 2, 0,
            Qt.AlignCenter)
        self.table = OWGUI.table(self.mainArea,
                                 rows=0,
                                 columns=0,
                                 selectionMode=QTableWidget.MultiSelection,
                                 addToLayout=0)
        self.layout.addWidget(self.table, 2, 1)
        self.layout.setColumnStretch(1, 100)
        self.layout.setRowStretch(2, 100)
        self.connect(self.table, SIGNAL("itemSelectionChanged()"), self.sendIf)

        self.resize(700, 450)
Ejemplo n.º 49
0
    def __init__(self, parent=None, signalManager=None):
        """Createur de widget."""

        # Appel du createur de widget (OWWidget).
        OWWidget.__init__(self, parent, signalManager, wantMainArea=0)
        
        # Definition des chaines d entree et de sortie...
        self.inputs = []
        self.outputs = [("LatinTextData", Segmentation)]
        
        # Initialisation des commandes
        self.autoSend = True
        self.auteur = list()
        self.piece = u'piece'
        self.titleLabels =  list()
        self.oeuvresSelectionnees = list()
        self.importesURLs = list()
        
        # Always end Textable widget settings with the following 3 lines...
        self.uuid = None
        self.loadSettings()
        self.uuid = getWidgetUuid(self)
        
        # Other attributes...
        self.segmentation = Input()
        self.titleSeg = None
        self.filteredTitleSeg = None
        self.filterValues = dict()
        self.base_url =     \
          u'http://www.thelatinlibrary.com'
        self.document_base_url =     \
          u'http://www.thelatinlibrary.com'
          
        # Next two instructions are helpers from TextableUtils. Corresponding
        # interface elements are declared here and actually drawn below (at
        # their position in the UI)...
        self.infoBox = InfoBox(widget=self.controlArea)
        self.sendButton = SendButton(
            widget=self.controlArea,
            master=self,
            callback=self.sendData,
            infoBoxAttribute=u'infoBox',
            sendIfPreCallback=self.updateGUI,
        )
	# Les etapes de recuperation suivantes sont inutiles desormais grace au OWLatinTest.py
        # Elles peuvent etre sorties des commentaires pour avoir une meilleure visualisation du rendu final du widget mais ne le rende pas reactif
	# Cette partie doit a present etre remplacee par un appel a la liste des auteurs creee dans OWLatinTest.py
        
        # #2)Recuperer la mainpage du site à la création du widget

        # link = "http://www.thelatinlibrary.com"
        # f = urllib2.urlopen(link)
        # mainpage = f.read()
        # #print mainpage

        # #3)Sur la mainpage, recuperer la liste deroulante des auteurs avec leurs liens

        # regex = r"<form name=myform>(.+ ?)"

        # if re.search(regex, mainpage):
           # match1 = re.search(regex, mainpage)
           # #print "%s" % (match1.group(0))
           # listederoulante = (match1.group(0))

        # else:
            # print "The regex pattern does not match."

        # #4)Dans la liste deroulante, recuperer les liens des pages des auteurs
            
        # regex = r"(?<=value=)(.+?)(?=>)"
        # matches = re.findall(regex, listederoulante)
        # #supprimer la derniere ligne en xml
        # #normaliser les noms de pages en supprimant les guillemets
        # #rajouter le nom de domaine pour que les urls soit complet
        # global urls
        # urls = list()
        # for matchA in matches[:-1]:
            # matchA = re.sub('"','',matchA)
            # linkauthorpage = "http://www.thelatinlibrary.com/%s" % (matchA)
            # urls.append(linkauthorpage)


        # #5)Dans la liste deroulante, recuperer les noms des auteurs

        # regex = r"(?<=>)(.+?)(?=<option)"
        # matches2 = re.findall(regex, listederoulante)
        # #supprimer la première ligne en xml
        # auteurs = list()
        # for matchB in matches2[1:]:
            # nomdauteur = "%s" % (matchB) 
            # auteurs.append(nomdauteur)
        
        #1)Creation des differents modules du widget
        self.infoBox = InfoBox(widget=self.controlArea)
        # GUI

        OWGUI.separator(self.controlArea)
        self.optionsBox = OWGUI.widgetBox(self.controlArea, "Options")

        #list authors
        OWGUI.comboBox(
            self.optionsBox,
            self,
            'auteur',
            items = auteurs,
            sendSelectedValue=True,
            label='Auteur',
            callback=self.sendButton.settingsChanged
        )
        #list pieces
        
        #recuperer les noms des pieces
        
        OWGUI.listBox(
            self.optionsBox,
            self,
            'piece',
            labels='piece',
            callback=self.sendButton.settingsChanged
        )

        OWGUI.separator(self.controlArea)


        self.infob = OWGUI.widgetLabel(self.optionsBox, '')
        self.resize(100,50)
        
        # Now Info box and Send button must be drawn...
        
        self.infoBox.draw()
        self.sendButton.draw()
        
        # Show the first pieces
        self.getPieces()

        # Send data if autoSend.
        self.sendButton.sendIf()
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, 'LearningCurveC')

        self.inputs = [("Data", ExampleTable, self.dataset), ("Learner", orange.Learner, self.learner, 0)]

        self.folds = 5     # cross validation folds
        self.steps = 10    # points in the learning curve
        self.scoringF = 0  # scoring function
        self.commitOnChange = 1 # compute curve on any change of parameters
        self.graphPointSize = 5 # size of points in the graphs
        self.graphDrawLines = 1 # draw lines between points in the graph
        self.graphShowGrid = 1  # show gridlines in the graph
        self.selectedLearners = [] 
        self.loadSettings()

        warnings.filterwarnings("ignore", ".*builtin attribute.*", orange.AttributeWarning)

        self.setCurvePoints() # sets self.curvePoints, self.steps equidistantpoints from 1/self.steps to 1
        self.scoring = [("Classification Accuracy", orngStat.CA), ("AUC", orngStat.AUC), ("BrierScore", orngStat.BrierScore), ("Information Score", orngStat.IS), ("Sensitivity", orngStat.sens), ("Specificity", orngStat.spec)]
        self.learners = [] # list of current learners from input channel, tuples (id, learner)
        self.data = None   # data on which to construct the learning curve
        self.curves = []   # list of evaluation results (one per learning curve point)
        self.scores = []   # list of current scores, learnerID:[learner scores]

        # GUI
        box = OWGUI.widgetBox(self.controlArea, "Info")
        self.infoa = OWGUI.widgetLabel(box, 'No data on input.')
        self.infob = OWGUI.widgetLabel(box, 'No learners.')

        ## class selection (classQLB)
        OWGUI.separator(self.controlArea)
        self.cbox = OWGUI.widgetBox(self.controlArea, "Learners")
        self.llb = OWGUI.listBox(self.cbox, self, "selectedLearners", selectionMode=QListWidget.MultiSelection, callback=self.learnerSelectionChanged)
        
        self.llb.setMinimumHeight(50)
        self.blockSelectionChanges = 0

        OWGUI.separator(self.controlArea)
        box = OWGUI.widgetBox(self.controlArea, "Evaluation Scores")
        scoringNames = [x[0] for x in self.scoring]
        OWGUI.comboBox(box, self, "scoringF", items=scoringNames,
                       callback=self.computeScores)

        OWGUI.separator(self.controlArea)
        box = OWGUI.widgetBox(self.controlArea, "Options")
        OWGUI.spin(box, self, 'folds', 2, 100, step=1,
                   label='Cross validation folds:  ',
                   callback=lambda: self.computeCurve(self.commitOnChange))
        OWGUI.spin(box, self, 'steps', 2, 100, step=1,
                   label='Learning curve points:  ',
                   callback=[self.setCurvePoints, lambda: self.computeCurve(self.commitOnChange)])

        OWGUI.checkBox(box, self, 'commitOnChange', 'Apply setting on any change')
        self.commitBtn = OWGUI.button(box, self, "Apply Setting", callback=self.computeCurve, disabled=1)

        # start of content (right) area
        tabs = OWGUI.tabWidget(self.mainArea)

        # graph widget
        tab = OWGUI.createTabPage(tabs, "Graph")
        self.graph = OWPlot(tab)
        self.graph.set_axis_autoscale(xBottom)
        self.graph.set_axis_autoscale(yLeft)
        tab.layout().addWidget(self.graph)
        self.setGraphGrid()

        # table widget
        tab = OWGUI.createTabPage(tabs, "Table")
        self.table = OWGUI.table(tab, selectionMode=QTableWidget.NoSelection)

        self.resize(550,200)
Ejemplo n.º 51
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, "Confusion Matrix", 1)

        # inputs
        self.inputs = [("Evaluation Results", orngTest.ExperimentResults,
                        self.setTestResults, Default)]
        self.outputs = [("Selected Examples", ExampleTable, 8)]

        self.selectedLearner = []
        self.learnerNames = []
        self.selectionDirty = 0
        self.autoApply = True
        self.appendPredictions = True
        self.appendProbabilities = False
        self.shownQuantity = 0

        self.learnerList = OWGUI.listBox(self.controlArea,
                                         self,
                                         "selectedLearner",
                                         "learnerNames",
                                         box="Learners",
                                         callback=self.learnerChanged)
        self.learnerList.setMinimumHeight(100)
        OWGUI.separator(self.controlArea)

        OWGUI.comboBox(self.controlArea,
                       self,
                       "shownQuantity",
                       items=self.quantities,
                       box="Show",
                       callback=self.reprint)

        box = OWGUI.widgetBox(self.controlArea, "Selection", addSpace=True)
        OWGUI.button(box, self, "Correct", callback=self.selectCorrect)
        OWGUI.button(box, self, "Misclassified", callback=self.selectWrong)
        OWGUI.button(box, self, "None", callback=self.selectNone)

        box = OWGUI.widgetBox(self.controlArea, "Output")
        OWGUI.checkBox(box,
                       self,
                       "appendPredictions",
                       "Append class predictions",
                       callback=self.sendIf)
        OWGUI.checkBox(box,
                       self,
                       "appendProbabilities",
                       "Append predicted class probabilities",
                       callback=self.sendIf)
        applyButton = OWGUI.button(box, self, "Commit", callback=self.sendData)
        autoApplyCB = OWGUI.checkBox(box, self, "autoApply",
                                     "Commit automatically")
        OWGUI.setStopper(self, applyButton, autoApplyCB, "selectionDirty",
                         self.sendData)

        import sip
        sip.delete(self.mainArea.layout())
        self.layout = QGridLayout(self.mainArea)

        self.layout.addWidget(OWGUI.widgetLabel(self.mainArea, "Prediction"),
                              0, 1, Qt.AlignCenter)
        self.layout.addWidget(
            OWGUI.widgetLabel(self.mainArea, "Correct Class  "), 2, 0,
            Qt.AlignCenter)
        self.table = OWGUI.table(self.mainArea,
                                 rows=0,
                                 columns=0,
                                 selectionMode=QTableWidget.MultiSelection,
                                 addToLayout=0)
        self.layout.addWidget(self.table, 2, 1)
        self.layout.setColumnStretch(1, 100)
        self.layout.setRowStretch(2, 100)
        self.connect(self.table, SIGNAL("itemSelectionChanged()"), self.sendIf)

        ##scPA
        # Get location of model file
        self.filePath = os.path.join(os.getcwd(), "ConfusionMat.txt")
        boxFile = OWGUI.widgetBox(self.controlArea,
                                  "File for saving results",
                                  addSpace=True,
                                  orientation=0)
        L1 = OWGUI.lineEdit(
            boxFile,
            self,
            "filePath",
            labelWidth=80,
            orientation="horizontal",
            tooltip=
            "Enter full file path to save the displayed results to a tab separated file."
        )
        L1.setMinimumWidth(200)
        button = OWGUI.button(boxFile,
                              self,
                              '...',
                              callback=self.browseFile,
                              disabled=0,
                              tooltip="Browse for a location...")
        button.setMaximumWidth(25)
        # Save the model
        OWGUI.button(self.controlArea,
                     self,
                     "&Save Results",
                     callback=self.saveRes)
        ##ecPA
        self.resize(700, 450)
    def __init__(self, parent = None, signalManager = None, name = "Select data"):
        OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0)  #initialize base class

        self.inputs = [("Data", ExampleTable, self.setData)]
        self.outputs = [("Matching Data", ExampleTable, Default), ("Unmatched Data", ExampleTable)]

        self.name2var = {}   # key: variable name, item: orange.Variable
        self.Conditions = []

        self.currentVar = None
        self.NegateCondition = False
        self.currentOperatorDict = {orange.VarTypes.Continuous: Operator(Operator.operatorsC[0], orange.VarTypes.Continuous),
                                    orange.VarTypes.Discrete: Operator(Operator.operatorsD[0],orange.VarTypes.Discrete),
                                    orange.VarTypes.String: Operator(Operator.operatorsS[0], orange.VarTypes.String)}
        self.Num1 = 0.0
        self.Num2 = 0.0
        self.Str1 = ""
        self.Str2 = ""
        self.attrSearchText = ""
        self.currentVals = []
        self.CaseSensitive = False
        self.updateOnChange = True
        self.purgeAttributes = True
        self.purgeClasses = True
        self.oldPurgeClasses = True

        self.loadedVarNames = []
        self.loadedConditions = []
        self.loadSettings()

        w = QWidget(self)
        self.controlArea.layout().addWidget(w)
        grid = QGridLayout()
        grid.setMargin(0)
        w.setLayout(grid)

        boxAttrCond = OWGUI.widgetBox(self, '', orientation = QGridLayout(), addToLayout = 0)
        grid.addWidget(boxAttrCond, 0,0,1,3)
        glac = boxAttrCond.layout()
        glac.setColumnStretch(0,2)
        glac.setColumnStretch(1,1)
        glac.setColumnStretch(2,2)

        boxAttr = OWGUI.widgetBox(self, 'Attribute', addToLayout = 0)
        glac.addWidget(boxAttr,0,0)
        self.lbAttr = OWGUI.listBox(boxAttr, self, callback = self.lbAttrChange)

        self.leSelect = OWGUI.lineEdit(boxAttr, self, "attrSearchText", label = "Search: ", orientation = "horizontal", callback = self.setLbAttr, callbackOnType = 1)

        boxOper = OWGUI.widgetBox(self, 'Operator')
        # operators 0: empty
        self.lbOperatosNone = OWGUI.listBox(boxOper, self)
        # operators 1: discrete
        self.lbOperatorsD = OWGUI.listBox(boxOper, self, callback = self.lbOperatorsChange)
        self.lbOperatorsD.hide()
        self.lbOperatorsD.addItems(Operator.operatorsD + [Operator.operatorDef])
        # operators 2: continuous
        self.lbOperatorsC = OWGUI.listBox(boxOper, self, callback = self.lbOperatorsChange)
        self.lbOperatorsC.hide()
        self.lbOperatorsC.addItems(Operator.operatorsC + [Operator.operatorDef])
        # operators 6: string
        self.lbOperatorsS = OWGUI.listBox(boxOper, self, callback = self.lbOperatorsChange)
        self.lbOperatorsS.hide()
        self.lbOperatorsS.addItems(Operator.operatorsS + [Operator.operatorDef])
        self.lbOperatorsDict = {0: self.lbOperatosNone,
                                orange.VarTypes.Continuous: self.lbOperatorsC,
                                orange.VarTypes.Discrete: self.lbOperatorsD,
                                orange.VarTypes.String: self.lbOperatorsS}

        glac.addWidget(boxOper,0,1)
        self.cbNot = OWGUI.checkBox(boxOper, self, "NegateCondition", "Negate")

        self.boxIndices = {}
        self.valuesStack = QStackedWidget(self)
        glac.addWidget(self.valuesStack, 0, 2)

        # values 0: empty
        boxVal = OWGUI.widgetBox(self, "Values", addToLayout = 0)
        self.boxIndices[0] = boxVal
        self.valuesStack.addWidget(boxVal)

        # values 1: discrete
        boxVal = OWGUI.widgetBox(self, "Values", addToLayout = 0)
        self.boxIndices[orange.VarTypes.Discrete] = boxVal
        self.valuesStack.addWidget(boxVal)
        self.lbVals = OWGUI.listBox(boxVal, self, callback = self.lbValsChange)

        # values 2: continuous between num and num
        boxVal = OWGUI.widgetBox(self, "Values", addToLayout = 0)
        self.boxIndices[orange.VarTypes.Continuous] = boxVal
        self.valuesStack.addWidget(boxVal)
        self.leNum1 = OWGUI.lineEdit(boxVal, self, "Num1", validator=QDoubleValidator(self))
        self.lblAndCon = OWGUI.widgetLabel(boxVal, "and")
        self.leNum2 = OWGUI.lineEdit(boxVal, self, "Num2", validator=QDoubleValidator(self))
        boxAttrStat = OWGUI.widgetBox(boxVal, "Statistics")
        self.lblMin = OWGUI.widgetLabel(boxAttrStat, "Min: ")
        self.lblAvg = OWGUI.widgetLabel(boxAttrStat, "Avg: ")
        self.lblMax = OWGUI.widgetLabel(boxAttrStat, "Max: ")
        self.lblDefined = OWGUI.widgetLabel(boxAttrStat, "Defined for ---- examples")
        OWGUI.rubber(boxAttrStat)

        # values 6: string between str and str
        boxVal = OWGUI.widgetBox(self, "Values", addToLayout = 0)
        self.boxIndices[orange.VarTypes.String] = boxVal
        self.valuesStack.addWidget(boxVal)
        self.leStr1 = OWGUI.lineEdit(boxVal, self, "Str1")
        self.lblAndStr = OWGUI.widgetLabel(boxVal, "and")
        self.leStr2 = OWGUI.lineEdit(boxVal, self, "Str2")
        self.cbCaseSensitive = OWGUI.checkBox(boxVal, self, "CaseSensitive", "Case sensitive")

        self.boxButtons = OWGUI.widgetBox(self, orientation = "horizontal")
        grid.addWidget(self.boxButtons, 1,0,1,3)
        self.btnNew = OWGUI.button(self.boxButtons, self, "Add", self.OnNewCondition)
        self.btnUpdate = OWGUI.button(self.boxButtons, self, "Modify", self.OnUpdateCondition)
        self.btnRemove = OWGUI.button(self.boxButtons, self, "Remove", self.OnRemoveCondition)
        self.btnOR = OWGUI.button(self.boxButtons, self, "OR", self.OnDisjunction)
        self.btnMoveUp = OWGUI.button(self.boxButtons, self, "Move Up", self.btnMoveUpClicked)
        self.btnMoveDown = OWGUI.button(self.boxButtons, self, "Move Down", self.btnMoveDownClicked)
        self.btnRemove.setEnabled(False)
        self.btnUpdate.setEnabled(False)
        self.btnMoveUp.setEnabled(False)
        self.btnMoveDown.setEnabled(False)


        boxCriteria = OWGUI.widgetBox(self, 'Data Selection Criteria', addToLayout = 0)
        grid.addWidget(boxCriteria, 2,0,1,3)
        self.criteriaTable = QTableWidget(boxCriteria)
        boxCriteria.layout().addWidget(self.criteriaTable)
        self.criteriaTable.setShowGrid(False)
        self.criteriaTable.setSelectionMode(QTableWidget.SingleSelection)
        self.criteriaTable.setColumnCount(2)
        self.criteriaTable.verticalHeader().setClickable(False)
        #self.criteriaTable.verticalHeader().setResizeEnabled(False,-1)
        self.criteriaTable.horizontalHeader().setClickable(False)
        self.criteriaTable.setHorizontalHeaderLabels(["Active", "Condition"])
        self.criteriaTable.resizeColumnToContents(0)
        self.criteriaTable.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.criteriaTable.horizontalHeader().setResizeMode(1, QHeaderView.Stretch)
        self.connect(self.criteriaTable, SIGNAL('cellClicked(int, int)'), self.currentCriteriaChange)

        boxDataIn = OWGUI.widgetBox(self, 'Data In', addToLayout = 0)
        grid.addWidget(boxDataIn, 3,0)
        self.dataInExamplesLabel = OWGUI.widgetLabel(boxDataIn, "num examples")
        self.dataInAttributesLabel = OWGUI.widgetLabel(boxDataIn, "num attributes")
        OWGUI.rubber(boxDataIn)

        boxDataOut = OWGUI.widgetBox(self, 'Data Out', addToLayout = 0)
        grid.addWidget(boxDataOut, 3,1)
        self.dataOutExamplesLabel = OWGUI.widgetLabel(boxDataOut, "num examples")
        self.dataOutAttributesLabel = OWGUI.widgetLabel(boxDataOut, "num attributes")
        OWGUI.rubber(boxDataOut)

        boxSettings = OWGUI.widgetBox(self, 'Commit', addToLayout = 0)
        grid.addWidget(boxSettings, 3,2)
        cb = OWGUI.checkBox(boxSettings, self, "purgeAttributes", "Remove unused values/attributes", box=None, callback=self.OnPurgeChange)
        self.purgeClassesCB = OWGUI.checkBox(OWGUI.indentedBox(boxSettings, sep=OWGUI.checkButtonOffsetHint(cb)), self, "purgeClasses", "Remove unused classes", callback=self.OnPurgeChange)
        OWGUI.checkBox(boxSettings, self, "updateOnChange", "Commit on change", box=None)
        btnUpdate = OWGUI.button(boxSettings, self, "Commit", self.setOutput, default=True)

        self.icons = self.createAttributeIconDict()
        self.setData(None)
        self.lbOperatorsD.setCurrentRow(0)
        self.lbOperatorsC.setCurrentRow(0)
        self.lbOperatorsS.setCurrentRow(0)
        self.resize(500,661)
        grid.setRowStretch(0, 10)
        grid.setRowStretch(2, 10)
Ejemplo n.º 53
0
    def __init__(self,parent=None, signalManager = None, name = "Impute"):
        OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0)

        self.inputs = [("Data", ExampleTable, self.setData, Default), ("Learner for Imputation", orange.Learner, self.setModel)]
        self.outputs = [("Data", ExampleTable), ("Imputer", orange.ImputerConstructor)]

        self.attrIcons = self.createAttributeIconDict()

        self.defaultMethod = 0
        self.selectedAttr = 0
        self.indiType = 0
        self.imputeClass = 0
        self.autosend = 1
        self.methods = {}
        self.dataChanged = False

        self.model = self.data = None

        self.indiValue = ""
        self.indiValCom = 0

        self.loadSettings()

        bgTreat = OWGUI.radioButtonsInBox(self.controlArea, self, "defaultMethod", self.defaultMethods,
                                          "Default imputation method", callback=self.sendIf,
                                          addSpace=True)

        self.indibox = OWGUI.widgetBox(self.controlArea, "Individual attribute settings", orientation="horizontal")#, addSpace=True)

        attrListBox = OWGUI.widgetBox(self.indibox)
        self.attrList = OWGUI.listBox(attrListBox, self, callback = self.individualSelected)
        self.attrList.setMinimumWidth(220)
        self.attrList.setItemDelegate(ImputeListItemDelegate(self, self.attrList))

        indiMethBox = OWGUI.widgetBox(self.indibox)
        indiMethBox.setFixedWidth(160)
        self.indiButtons = OWGUI.radioButtonsInBox(indiMethBox, self, "indiType", ["Default (above)", "Don't impute", "Avg/Most frequent", "Model-based", "Random", "Remove examples", "Value"], 1, callback=self.indiMethodChanged)
        self.indiValueCtrlBox = OWGUI.indentedBox(self.indiButtons)

        self.indiValueLineEdit = OWGUI.lineEdit(self.indiValueCtrlBox, self, "indiValue", callback = self.lineEditChanged)
        #self.indiValueLineEdit.hide()
        valid = QDoubleValidator(self)
        valid.setRange(-1e30, 1e30, 10)
        self.indiValueLineEdit.setValidator(valid)

        self.indiValueComboBox = OWGUI.comboBox(self.indiValueCtrlBox, self, "indiValCom", callback = self.valueComboChanged)
        self.indiValueComboBox.hide()
        OWGUI.rubber(indiMethBox)
        self.btAllToDefault = OWGUI.button(indiMethBox, self, "Set All to Default", callback = self.allToDefault)

        OWGUI.separator(self.controlArea)
        box = OWGUI.widgetBox(self.controlArea, "Class Imputation")#, addSpace=True)
        self.cbImputeClass = OWGUI.checkBox(box, self, "imputeClass", "Impute class values", callback=self.sendIf)

        OWGUI.separator(self.controlArea)
        snbox = OWGUI.widgetBox(self.controlArea, "Send data and imputer")
        self.btApply = OWGUI.button(snbox, self, "Apply", callback=self.sendDataAndImputer, default=True)
        OWGUI.checkBox(snbox, self, "autosend", "Send automatically", callback=self.enableAuto, disables = [(-1, self.btApply)])

        self.individualSelected(self.selectedAttr)
        self.btApply.setDisabled(self.autosend)
        self.setBtAllToDefault()
        self.resize(200,200)