Ejemplo n.º 1
0
    def __init__(self, parent=None, signalManager=None):
        self.callbackDeposit = []  # deposit for OWGUI callback functions
        OWWidget.__init__(self,
                          parent,
                          signalManager,
                          "Matrix Transformation",
                          wantMainArea=0,
                          resizingEnabled=0)
        self.inputs = [("Matrix", orange.SymMatrix, self.setMatrix, Default)]
        self.outputs = [("Matrix", orange.SymMatrix)]
        self.matrix = None
        self.normalizeMethod = self.invertMethod = 0
        self.loadSettings()
        ribg = OWGUI.radioButtonsInBox(self.controlArea,
                                       self,
                                       "normalizeMethod",
                                       self.normalizeMethods,
                                       "Normalization",
                                       callback=self.setNormalizeMode,
                                       addSpace=True)
        ribg = OWGUI.radioButtonsInBox(self.controlArea,
                                       self,
                                       "invertMethod",
                                       self.inversionMethods,
                                       "Inversion",
                                       callback=self.setInvertMode)

        OWGUI.rubber(self.controlArea)

        self.adjustSize()
Ejemplo n.º 2
0
    def __init__(self, parent=None, signalManager=None, name='Classification Tree'):
        OWWidget.__init__(self, parent, signalManager, name, wantMainArea=0, resizingEnabled=0)

        self.inputs = [("Data", ExampleTable, self.setData),
                       ("Preprocess", PreprocessedLearner, self.setPreprocessor)]

        self.outputs = [("Learner", Orange.classification.tree.TreeLearner),
                        ("Classification Tree", Orange.classification.tree.TreeClassifier), ]

        self.name = 'Classification Tree'
        self.estim = 0; self.relK = 5; self.relM = 100; self.limitRef = True
        self.bin = 0; self.subset = 0
        self.preLeafInstP = 2; self.preNodeInstP = 5; self.preNodeMajP = 95
        self.preLeafInst = 1; self.preNodeInst = 0; self.preNodeMaj = 0
        self.postMaj = 1; self.postMPruning = 1; self.postM = 2.0
        self.limitDepth = False; self.maxDepth = 100
        self.loadSettings()

        self.data = None
        self.preprocessor = None
        self.setLearner()

        OWGUI.lineEdit(self.controlArea, self, 'name', box='Learner/Classifier Name', tooltip='Name to be used by other widgets to identify your learner/classifier.')
        OWGUI.separator(self.controlArea)

        qBox = OWGUI.widgetBox(self.controlArea, 'Attribute selection criterion')

        self.qMea = OWGUI.comboBox(qBox, self, "estim", items=[m[0] for m in self.measures], callback=self.measureChanged)

        b1 = OWGUI.widgetBox(qBox, orientation="horizontal")
        OWGUI.separator(b1, 16, 0)
        b2 = OWGUI.widgetBox(b1)
        self.cbLimitRef, self.hbxRel1 = OWGUI.checkWithSpin(b2, self, "Limit the number of reference examples to ", 1, 1000, "limitRef", "relM")
        OWGUI.separator(b2)
        self.hbxRel2 = OWGUI.spin(b2, self, "relK", 1, 50, orientation="horizontal", label="Number of neighbours in ReliefF  ")

        OWGUI.separator(self.controlArea)

        OWGUI.radioButtonsInBox(self.controlArea, self, 'bin', self.binarizationOpts, "Binarization")
        OWGUI.separator(self.controlArea)

        self.measureChanged()

        self.pBox = OWGUI.widgetBox(self.controlArea, 'Pre-Pruning')

        self.preLeafInstBox, self.preLeafInstPBox = OWGUI.checkWithSpin(self.pBox, self, "Min. instances in leaves ", 1, 1000, "preLeafInst", "preLeafInstP")
        self.preNodeInstBox, self.preNodeInstPBox = OWGUI.checkWithSpin(self.pBox, self, "Stop splitting nodes with less instances than ", 1, 1000, "preNodeInst", "preNodeInstP")
        self.preNodeMajBox, self.preNodeMajPBox = OWGUI.checkWithSpin(self.pBox, self, "Stop splitting nodes with a majority class of (%)", 1, 100, "preNodeMaj", "preNodeMajP")
        self.cbLimitDepth, self.maxDepthBox = OWGUI.checkWithSpin(self.pBox, self, "Stop splitting nodes at depth", 0, 1000, "limitDepth", "maxDepth")
        OWGUI.separator(self.controlArea)
        self.mBox = OWGUI.widgetBox(self.controlArea, 'Post-Pruning')

        OWGUI.checkBox(self.mBox, self, 'postMaj', 'Recursively merge leaves with same majority class')
        self.postMPruningBox, self.postMPruningPBox = OWGUI.checkWithSpin(self.mBox, self, "Pruning with m-estimate, m=", 0, 1000, 'postMPruning', 'postM')

        OWGUI.separator(self.controlArea)
        self.btnApply = OWGUI.button(self.controlArea, self, "&Apply", callback=self.setLearner, disabled=0, default=True)

        OWGUI.rubber(self.controlArea)
        self.resize(200, 200)
Ejemplo n.º 3
0
    def __init__(self, parent=None):
        OWWidget.__init__(self, parent, title='X Learner')

        self.method= 0
        self.maxi = 1
        self.cheat = 0
        self.autoApply = True

        self.settingsChanged = False
        
        OWGUI.radioButtonsInBox(self.controlArea, self, "method",
                       ["Vanishing", "Disappearing", "Invisibilisation"],
                       box="Minimization technique", 
                       callback = self.applyIf)
        OWGUI.separator(self.controlArea)

        box = OWGUI.widgetBox(self.controlArea, "Settings")
        OWGUI.checkBox(box, self, "maxi", "Post-maximize", callback = self.applyIf)
        OWGUI.checkBox(box, self, "cheat", "Quasi-cheating", callback = self.applyIf)
        OWGUI.separator(self.controlArea)

        box = OWGUI.widgetBox(self.controlArea, "Apply")
        applyButton = OWGUI.button(box, self, "Apply", callback = self.apply)
        autoApplyCB = OWGUI.checkBox(box, self, "autoApply", "Apply automatically")

        OWGUI.setStopper(self, applyButton, autoApplyCB, "settingsChanged", self.apply)        
        
        self.adjustSize()
Ejemplo n.º 4
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.º 5
0
    def addHistogramControls(self, parent=None):
        # set default settings
        self.spinLowerThreshold = 0
        self.spinLowerChecked = False
        self.spinUpperThreshold = 0
        self.spinUpperChecked = False
        self.netOption = 0
        self.dstWeight = 0
        self.kNN = 0
        self.andor = 0
        self.matrix = None
        self.excludeLimit = 2
        self.percentil = 0

        self.graph = None
        self.graph_matrix = None

        if parent is None:
            parent = self.controlArea

        boxGeneral = OWGUI.widgetBox(parent, box="Distance boundaries")

        ribg = OWGUI.widgetBox(boxGeneral, None, orientation="horizontal", addSpace=False)
        OWGUI.lineEdit(ribg, self, "spinLowerThreshold", "Lower", orientation='horizontal', callback=self.changeLowerSpin, valueType=float, enterPlaceholder=True, controlWidth=100)
        OWGUI.lineEdit(ribg, self, "spinUpperThreshold", "Upper    ", orientation='horizontal', callback=self.changeUpperSpin, valueType=float, enterPlaceholder=True, controlWidth=100)
        ribg.layout().addStretch(1)
        #ribg = OWGUI.radioButtonsInBox(boxGeneral, self, "andor", [], orientation='horizontal', callback = self.generateGraph)
        #OWGUI.appendRadioButton(ribg, self, "andor", "OR", callback = self.generateGraph)
        #b = OWGUI.appendRadioButton(ribg, self, "andor", "AND", callback = self.generateGraph)
        #b.setEnabled(False)
        #ribg.hide(False)

        ribg = OWGUI.widgetBox(boxGeneral, None, orientation="horizontal", addSpace=False)
        OWGUI.spin(ribg, self, "kNN", 0, 1000, 1, label="kNN   ", orientation='horizontal', callback=self.generateGraph, callbackOnReturn=1, controlWidth=100)
        OWGUI.doubleSpin(ribg, self, "percentil", 0, 100, 0.1, label="Percentile", orientation='horizontal', callback=self.setPercentil, callbackOnReturn=1, controlWidth=100)
        ribg.layout().addStretch(1)
        # Options
        self.attrColor = ""
        ribg = OWGUI.radioButtonsInBox(parent, self, "netOption", [], "Options", callback=self.generateGraph)
        OWGUI.appendRadioButton(ribg, self, "netOption", "All vertices", callback=self.generateGraph)
        hb = OWGUI.widgetBox(ribg, None, orientation="horizontal", addSpace=False)
        OWGUI.appendRadioButton(ribg, self, "netOption", "Large components only. Min nodes:", insertInto=hb, callback=self.generateGraph)
        OWGUI.spin(hb, self, "excludeLimit", 2, 100, 1, callback=(lambda h=True: self.generateGraph(h)))
        OWGUI.appendRadioButton(ribg, self, "netOption", "Largest connected component only", callback=self.generateGraph)
        OWGUI.appendRadioButton(ribg, self, "netOption", "Connected component with vertex")
        self.attribute = None
        self.attributeCombo = OWGUI.comboBox(parent, self, "attribute", box="Filter attribute", orientation='horizontal')#, callback=self.setVertexColor)

        ribg = OWGUI.radioButtonsInBox(parent, self, "dstWeight", [], "Distance -> Weight", callback=self.generateGraph)
        hb = OWGUI.widgetBox(ribg, None, orientation="horizontal", addSpace=False)
        OWGUI.appendRadioButton(ribg, self, "dstWeight", "Weight := distance", insertInto=hb, callback=self.generateGraph)
        OWGUI.appendRadioButton(ribg, self, "dstWeight", "Weight := 1 - distance", insertInto=hb, callback=self.generateGraph)

        self.label = ''
        self.searchString = OWGUI.lineEdit(self.attributeCombo.box, self, "label", callback=self.setSearchStringTimer, callbackOnType=True)
        self.searchStringTimer = QTimer(self)
        self.connect(self.searchStringTimer, SIGNAL("timeout()"), self.generateGraph)

        if str(self.netOption) != '3':
            self.attributeCombo.box.setEnabled(False)
Ejemplo n.º 6
0
    def __init__(self, parent=None, signalManager=None, name = "WordNgram"):
        OWWidget.__init__(self,parent,signalManager,name)
        self.inputs = [("Example Table", ExampleTable, self.dataset)]
        self.outputs = [("Example Table", ExampleTable)]

        self.recentFiles=[]
        self.fileIndex = 0
        self.loadSettings()
        self.stopwords = None
        self.size = 0
        self.measure = 0
        self.threshold = 0
        self.data = None
        self.measureDict = {0: 'FREQ', 1: 'MI', 2: 'DICE', 3: 'CHI', 4: 'LL'}

        #GUI        
        optionBox = OWGUI.widgetBox(self.controlArea, "", "horizontal") #QHGroupBox('', self.controlArea)
        OWGUI.radioButtonsInBox(optionBox, self, "size", box = "No. of words", btnLabels = ["2", "3", "4", "Named entities"], addSpace = True, callback = self.radioChanged)
        self.ambox = OWGUI.radioButtonsInBox(optionBox, self, "measure", box = "Association measure", btnLabels = ["Frequency", "Mutual information", "Dice coefficient", "Chi square", "Log likelihood"], addSpace = True)
        self.ambox.setEnabled(self.size - 3)
        box = OWGUI.widgetBox(optionBox, "") #QVGroupBox('', optionBox)
        OWGUI.lineEdit(box, self, "threshold", orientation="horizontal", valueType=float, box="Threshold")

        stopbox = OWGUI.widgetBox(box, "Stopwords File")
        stophbox = OWGUI.widgetBox(stopbox, orientation="horizontal") #1)
        self.filecombo = OWGUI.comboBox(stophbox, self, "fileIndex", callback = self.loadFile)
        OWGUI.button(stophbox, self, '...', callback = self.browseFile)
        OWGUI.button(self.controlArea, self, "Apply", self.apply)
        self.lblFeatureNo = OWGUI.widgetLabel(self.controlArea, "\nNo. of features: ") #QLabel("\nNo. of features: ", self.controlArea)
        OWGUI.rubber(self.controlArea)
        self.adjustSize()

        if self.recentFiles:
            self.loadFile()
Ejemplo n.º 7
0
    def __init__(self, parent=None, signalManager = None, name='Classification Tree'):
        OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0, resizingEnabled = 0)

        self.inputs = [("Examples", ExampleTable, self.setData), ("Preprocess", PreprocessedLearner, self.setPreprocessor)]
        self.outputs = [("Learner", orange.TreeLearner),("Classification Tree", orange.TreeClassifier)]

        self.name = 'Classification Tree'
        self.estim = 0; self.relK = 5; self.relM = 100; self.limitRef = True
        self.bin = 0; self.subset = 0
        self.preLeafInstP = 2; self.preNodeInstP = 5; self.preNodeMajP = 95
        self.preLeafInst = 1; self.preNodeInst = 0; self.preNodeMaj = 0
        self.postMaj = 1; self.postMPruning = 1; self.postM = 2.0
        self.limitDepth = False; self.maxDepth = 100
        self.loadSettings()

        self.data = None
        self.preprocessor = None
        self.setLearner()

        OWGUI.lineEdit(self.controlArea, self, 'name', box='Learner/Classifier Name', tooltip='Name to be used by other widgets to identify your learner/classifier.')
        OWGUI.separator(self.controlArea)

        qBox = OWGUI.widgetBox(self.controlArea, 'Attribute selection criterion')

        self.qMea = OWGUI.comboBox(qBox, self, "estim", items = [m[0] for m in self.measures], callback = self.measureChanged)

        b1 = OWGUI.widgetBox(qBox, orientation = "horizontal")
        OWGUI.separator(b1, 16, 0)
        b2 = OWGUI.widgetBox(b1)
        self.cbLimitRef, self.hbxRel1 = OWGUI.checkWithSpin(b2, self, "Limit the number of reference examples to ", 1, 1000, "limitRef", "relM")
        OWGUI.separator(b2)
        self.hbxRel2 = OWGUI.spin(b2, self, "relK", 1, 50, orientation="horizontal", label="Number of neighbours in ReliefF  ")
 
        OWGUI.separator(self.controlArea)

        OWGUI.radioButtonsInBox(self.controlArea, self, 'bin', self.binarizationOpts, "Binarization")
        OWGUI.separator(self.controlArea)

        self.measureChanged()

        self.pBox = OWGUI.widgetBox(self.controlArea, 'Pre-Pruning')

        self.preLeafInstBox, self.preLeafInstPBox = OWGUI.checkWithSpin(self.pBox, self, "Min. instances in leaves ", 1, 1000, "preLeafInst", "preLeafInstP")
        self.preNodeInstBox, self.preNodeInstPBox = OWGUI.checkWithSpin(self.pBox, self, "Stop splitting nodes with less instances than ", 1, 1000, "preNodeInst", "preNodeInstP")
        self.preNodeMajBox, self.preNodeMajPBox = OWGUI.checkWithSpin(self.pBox, self, "Stop splitting nodes with a majority class of (%)", 1, 100, "preNodeMaj", "preNodeMajP")
        self.cbLimitDepth, self.maxDepthBox = OWGUI.checkWithSpin(self.pBox, self, "Stop splitting nodes at depth", 0, 1000, "limitDepth", "maxDepth")
        OWGUI.separator(self.controlArea)
        self.mBox = OWGUI.widgetBox(self.controlArea, 'Post-Pruning')

        OWGUI.checkBox(self.mBox, self, 'postMaj', 'Recursively merge leaves with same majority class')
        self.postMPruningBox, self.postMPruningPBox = OWGUI.checkWithSpin(self.mBox, self, "Pruning with m-estimate, m=", 0, 1000, 'postMPruning', 'postM')

        OWGUI.separator(self.controlArea)
        self.btnApply = OWGUI.button(self.controlArea, self, "&Apply", callback = self.setLearner, disabled=0)
        
        OWGUI.rubber(self.controlArea)
        self.resize(200,200)
    def defineGUI(self):

        # Set the number of hidden neurons throught the GUI
        OWGUI.lineEdit(self.controlArea, self, 'name', box='Learner/Classifier Name', \
                       tooltip='Name to be used by other widgets to identify your learner/classifier.<br>This should be a unique name!')

        OWGUI.lineEdit(self.controlArea, self, 'nHiddenGUI', box='The number of hidden neurons', \
        tooltip='The number of neurons in each hidden layer should be given as a comma separated string. \n\
For example, 2,3,4 will create 3 hidden layers (5 layers in total, including in and out),\n\
with 2, 3 and 4 neurons respectively. If no value is given, the default, which is one layer of 5 neurons, \n\
will be used. ')

        # Set the training function throught the GUI 
        # CVANNOPTALGDICT = {"FANN_TRAIN_BACKPROP":0, "FANN_TRAIN_RPROP":1}
        self.trainingBox=b=OWGUI.widgetBox(self.controlArea,"Training function")
        self.trainingRadio = OWGUI.radioButtonsInBox(b, self, "optAlgGUI", btnLabels= \
        ["TRAIN_BACKPROP - Backpropagation", \
        "TRAIN_RPROP - iRPROP algorithm (Recommended)"],callback = self.changedOptAlg)

        #CVANNSTOPCRITDICT = {"ITER":1, "EPS":2}
        sc = OWGUI.widgetBox(self.controlArea,"Stop criteria")
        self.trainingRadio = OWGUI.radioButtonsInBox(sc, self, "stopCritGUI", btnLabels= \
        ["Max number of Iterations", \
         "Epsilon"], callback = self.OnChangedStopCrit) 

        OWGUI.lineEdit(OWGUI.indentedBox(sc), self, 'stopValueGUI', 'Value:', orientation="horizontal", tooltip="Value to use as stop Criteria")

        self.priorBox = OWGUI.lineEdit(b, self, 'priorsGUI', box='Class weights', \
                       tooltip='Ex: POS:2 , NEG:1')
        b=OWGUI.widgetBox(self.controlArea, "Scaling", addSpace = True)
        self.scaleDataBox=OWGUI.checkBox(b, self, "scaleDataGUI", "Scale Data", tooltip="Scales the training data, and the input examples",callback = self.setLearnerVars)
        self.scaleClassBox=OWGUI.checkBox(b, self, "scaleClassGUI", "Scale Class variable", tooltip="Scales the class variable of training data, and the output predictions",callback = self.setLearnerVars)

        # Apply the settings and send the learner to the output channel
        OWGUI.button(self.controlArea, self,"&Apply settings", callback=self.applySettings)

        # Get desired location of model file
        boxFile = OWGUI.widgetBox(self.controlArea, "Path for saving Model", addSpace = True, orientation=0)
        L1 = OWGUI.lineEdit(boxFile, self, "modelFile", labelWidth=80,  orientation = "horizontal", \
        tooltip = "Once a model is created (connect this widget with a data widget), \nit can be saved by giving a \
file name here and clicking the save button.\nPlease observe that model names should not contain an extention.")
        L1.setMinimumWidth(200)
        button = OWGUI.button(boxFile, self, '...', callback = self.browseFile, disabled=0,tooltip = "Choose the dir where to save. After chosen, add a name for the model file!")
        button.setMaximumWidth(25)

        # Save the model
        OWGUI.button(self.controlArea, self,"&Save model to file", callback=self.saveModel)
        self.setLearnerVars()
        self.applySettings()
        self.adjustSize()
Ejemplo n.º 9
0
 def addHistogramControls(self, parent=None):
     # set default settings
     self.spinLowerThreshold = 0
     self.spinLowerChecked = False
     self.spinUpperThreshold = 0
     self.spinUpperChecked = False
     self.netOption = 0
     self.dstWeight = 0
     self.kNN = 0
     self.andor = 0
     self.matrix = None
     self.excludeLimit = 1
     self.percentil = 0
     
     if parent is None:
         parent = self.controlArea
         
     boxGeneral = OWGUI.widgetBox(parent, box = "Distance boundaries")
     
     OWGUI.lineEdit(boxGeneral, self, "spinLowerThreshold", "Lower:", orientation='horizontal', callback=self.changeLowerSpin, valueType=float)
     OWGUI.lineEdit(boxGeneral, self, "spinUpperThreshold", "Upper:", orientation='horizontal', callback=self.changeUpperSpin, valueType=float)
     ribg = OWGUI.radioButtonsInBox(boxGeneral, self, "andor", [], orientation='horizontal', callback = self.generateGraph)
     OWGUI.appendRadioButton(ribg, self, "andor", "OR", callback = self.generateGraph)
     b = OWGUI.appendRadioButton(ribg, self, "andor", "AND", callback = self.generateGraph)
     b.setEnabled(False)
     OWGUI.spin(boxGeneral, self, "kNN", 0, 1000, 1, label="kNN:", orientation='horizontal', callback=self.generateGraph)
     OWGUI.doubleSpin(boxGeneral, self, "percentil", 0, 100, 0.1, label="Percentil:", orientation='horizontal', callback=self.setPercentil, callbackOnReturn=1)
     
     # Options
     self.attrColor = ""
     ribg = OWGUI.radioButtonsInBox(parent, self, "netOption", [], "Options", callback = self.generateGraph)
     OWGUI.appendRadioButton(ribg, self, "netOption", "All vertices", callback = self.generateGraph)
     OWGUI.appendRadioButton(ribg, self, "netOption", "Exclude small components", callback = self.generateGraph)
     OWGUI.spin(OWGUI.indentedBox(ribg), self, "excludeLimit", 1, 100, 1, label="Less vertices than: ", callback = (lambda h=True: self.generateGraph(h)))
     OWGUI.appendRadioButton(ribg, self, "netOption", "Largest connected component only", callback = self.generateGraph)
     OWGUI.appendRadioButton(ribg, self, "netOption", "Connected component with vertex")
     self.attribute = None
     self.attributeCombo = OWGUI.comboBox(ribg, self, "attribute", box = "Filter attribute")#, callback=self.setVertexColor)
     
     ribg = OWGUI.radioButtonsInBox(parent, self, "dstWeight", [], "Distance -> Weight", callback = self.generateGraph)
     OWGUI.appendRadioButton(ribg, self, "dstWeight", "Weight := distance", callback = self.generateGraph)
     OWGUI.appendRadioButton(ribg, self, "dstWeight", "Weight := 1 - distance", callback = self.generateGraph)
     
     self.label = ''
     self.searchString = OWGUI.lineEdit(self.attributeCombo.box, self, "label", callback=self.setSearchStringTimer, callbackOnType=True)
     self.searchStringTimer = QTimer(self)
     self.connect(self.searchStringTimer, SIGNAL("timeout()"), self.generateGraph)
     
     if str(self.netOption) != '3':
         self.attributeCombo.box.setEnabled(False)
Ejemplo n.º 10
0
    def __init__(self, parent=None):
        OWWidget.__init__(self, parent, title="Listbox")

        self.method = 0

        OWGUI.radioButtonsInBox(
            self.controlArea,
            self,
            "method",
            box="Probability estimation",
            btnLabels=["Relative", "Laplace", "m-estimate"],
            tooltips=["Relative frequency of the event", "Laplace-corrected estimate", "M-estimate of probability"],
        )
        self.adjustSize()
 def __init__(self, parent=None, signalManager = None):
     self.callbackDeposit = [] # deposit for OWGUI callback functions
     OWWidget.__init__(self, parent, signalManager, "Matrix Transformation", wantMainArea = 0, resizingEnabled = 0)
     self.inputs = [("Matrix", orange.SymMatrix, self.setMatrix, Default)]
     self.outputs = [("Matrix", orange.SymMatrix)]
     self.matrix = None
     self.normalizeMethod = self.invertMethod = 0
     self.loadSettings()
     ribg = OWGUI.radioButtonsInBox(self.controlArea, self, "normalizeMethod", self.normalizeMethods, "Normalization", callback = self.setNormalizeMode, addSpace=True)
     ribg = OWGUI.radioButtonsInBox(self.controlArea, self, "invertMethod", self.inversionMethods, "Inversion", callback = self.setInvertMode)
     
     OWGUI.rubber(self.controlArea)
     
     self.adjustSize()
Ejemplo n.º 12
0
 def addHistogramControls(self, parent=None):
     # set default settings
     self.spinLowerThreshold = 0
     self.spinLowerChecked = False
     self.spinUpperThreshold = 0
     self.spinUpperChecked = False
     self.netOption = 0
     self.dstWeight = 0
     self.kNN = 0
     self.andor = 0
     self.matrix = None
     self.excludeLimit = 1
     self.percentil = 0
     
     if parent is None:
         parent = self.controlArea
         
     boxGeneral = OWGUI.widgetBox(parent, box = "Distance boundaries")
     
     OWGUI.lineEdit(boxGeneral, self, "spinLowerThreshold", "Lower:", orientation='horizontal', callback=self.changeLowerSpin, valueType=float)
     OWGUI.lineEdit(boxGeneral, self, "spinUpperThreshold", "Upper:", orientation='horizontal', callback=self.changeUpperSpin, valueType=float)
     ribg = OWGUI.radioButtonsInBox(boxGeneral, self, "andor", [], orientation='horizontal', callback = self.generateGraph)
     OWGUI.appendRadioButton(ribg, self, "andor", "OR", callback = self.generateGraph)
     b = OWGUI.appendRadioButton(ribg, self, "andor", "AND", callback = self.generateGraph)
     b.setEnabled(False)
     OWGUI.spin(boxGeneral, self, "kNN", 0, 1000, 1, label="kNN:", orientation='horizontal', callback=self.generateGraph)
     OWGUI.doubleSpin(boxGeneral, self, "percentil", 0, 100, 0.1, label="Percentil:", orientation='horizontal', callback=self.setPercentil, callbackOnReturn=1)
     
     # Options
     self.attrColor = ""
     ribg = OWGUI.radioButtonsInBox(parent, self, "netOption", [], "Options", callback = self.generateGraph)
     OWGUI.appendRadioButton(ribg, self, "netOption", "All vertices", callback = self.generateGraph)
     OWGUI.appendRadioButton(ribg, self, "netOption", "Exclude small components", callback = self.generateGraph)
     OWGUI.spin(OWGUI.indentedBox(ribg), self, "excludeLimit", 1, 100, 1, label="Less vertices than: ", callback = (lambda h=True: self.generateGraph(h)))
     OWGUI.appendRadioButton(ribg, self, "netOption", "Largest connected component only", callback = self.generateGraph)
     OWGUI.appendRadioButton(ribg, self, "netOption", "Connected component with vertex")
     self.attribute = None
     self.attributeCombo = OWGUI.comboBox(ribg, self, "attribute", box = "Filter attribute")#, callback=self.setVertexColor)
     
     ribg = OWGUI.radioButtonsInBox(parent, self, "dstWeight", [], "Distance -> Weight", callback = self.generateGraph)
     OWGUI.appendRadioButton(ribg, self, "dstWeight", "Weight := distance", callback = self.generateGraph)
     OWGUI.appendRadioButton(ribg, self, "dstWeight", "Weight := 1 - distance", callback = self.generateGraph)
     
     self.label = ''
     self.searchString = OWGUI.lineEdit(self.attributeCombo.box, self, "label", callback=self.setSearchStringTimer, callbackOnType=True)
     self.searchStringTimer = QTimer(self)
     self.connect(self.searchStringTimer, SIGNAL("timeout()"), self.generateGraph)
     
     if str(self.netOption) != '3':
         self.attributeCombo.box.setEnabled(False)
Ejemplo n.º 13
0
    def __init__(self, parent=None):
        BaseEditor.__init__(self, parent)
        self.discInd = 0
        self.numberOfIntervals = 3
        #        box = OWGUI.widgetBox(self, "Discretize")
        rb = OWGUI.radioButtonsInBox(self,
                                     self,
                                     "discInd", [],
                                     box="Discretize",
                                     callback=self.onChange)
        for label, _, _ in self.DISCRETIZERS[:-1]:
            OWGUI.appendRadioButton(rb, self, "discInd", label)
        self.sliderBox = OWGUI.widgetBox(
            OWGUI.indentedBox(rb,
                              sep=OWGUI.checkButtonOffsetHint(rb.buttons[-1])),
            "Num. of intervals (for equal width/frequency)")
        OWGUI.hSlider(self.sliderBox,
                      self,
                      "numberOfIntervals",
                      callback=self.onChange,
                      minValue=1)
        OWGUI.appendRadioButton(rb, self, "discInd", self.DISCRETIZERS[-1][0])
        OWGUI.rubber(rb)

        self.updateSliderBox()
Ejemplo n.º 14
0
    def __init__(self, parent=None, signalManager=None):
        self.callbackDeposit = []  # deposit for OWGUI callback functions
        OWWidget.__init__(self,
                          parent,
                          signalManager,
                          "Distance File",
                          wantMainArea=0,
                          resizingEnabled=0)

        self.inputs = [("Examples", ExampleTable, self.getExamples, Default)]
        self.outputs = [("Distance Matrix", orange.SymMatrix)]

        self.recentFiles = []
        self.fileIndex = 0
        self.takeAttributeNames = False
        self.data = None
        self.matrix = None
        self.invertDistances = 0
        self.normalizeMethod = 0
        self.invertMethod = 0
        self.loadSettings()
        self.labels = None

        box = OWGUI.widgetBox(self.controlArea, "Data File", addSpace=True)
        hbox = OWGUI.widgetBox(box, orientation=0)
        self.filecombo = OWGUI.comboBox(hbox,
                                        self,
                                        "fileIndex",
                                        callback=self.loadFile)
        self.filecombo.setMinimumWidth(250)
        button = OWGUI.button(hbox, self, '...', callback=self.browseFile)
        button.setMaximumWidth(25)
        self.rbInput = OWGUI.radioButtonsInBox(
            self.controlArea,
            self,
            "takeAttributeNames",
            ["Use examples as items", "Use attribute names"],
            "Items from input data",
            callback=self.relabel)

        self.rbInput.setDisabled(True)
        #
        #        Moved to SymMatrixTransform widget
        #
        #        ribg = OWGUI.radioButtonsInBox(self.controlArea, self, "normalizeMethod", [], "Normalize method", callback = self.setNormalizeMode)
        #        OWGUI.appendRadioButton(ribg, self, "normalizeMethod", "None", callback = self.setNormalizeMode)
        #        OWGUI.appendRadioButton(ribg, self, "normalizeMethod", "To interval [0,1]", callback = self.setNormalizeMode)
        #        OWGUI.appendRadioButton(ribg, self, "normalizeMethod", "Sigmoid function: 1 / (1 + e^x)", callback = self.setNormalizeMode)
        #
        #        ribg = OWGUI.radioButtonsInBox(self.controlArea, self, "invertMethod", [], "Invert method", callback = self.setInvertMode)
        #        OWGUI.appendRadioButton(ribg, self, "invertMethod", "None", callback = self.setInvertMode)
        #        OWGUI.appendRadioButton(ribg, self, "invertMethod", "-X", callback = self.setInvertMode)
        #        OWGUI.appendRadioButton(ribg, self, "invertMethod", "1 - X", callback = self.setInvertMode)
        #        OWGUI.appendRadioButton(ribg, self, "invertMethod", "Max - X", callback = self.setInvertMode)
        #        OWGUI.appendRadioButton(ribg, self, "invertMethod", "1 / X", callback = self.setInvertMode)

        self.adjustSize()

        if self.recentFiles:
            self.loadFile()
Ejemplo n.º 15
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self,
                          parent,
                          signalManager,
                          "Concatenate",
                          wantMainArea=0)
        self.inputs = [("Primary Table", orange.ExampleTable, self.setData),
                       ("Additional Tables", orange.ExampleTable,
                        self.setMoreData, Multiple)]
        self.outputs = [("Examples", ExampleTable)]

        self.mergeAttributes = 0

        self.primary = None
        self.additional = {}

        bg = self.bgMerge = OWGUI.radioButtonsInBox(self.controlArea,
                                                    self,
                                                    "mergeAttributes", [],
                                                    "Domains merging",
                                                    callback=self.apply)
        OWGUI.widgetLabel(
            bg, "When there is no primary table, the domain should be:")
        OWGUI.appendRadioButton(bg, self, "mergeAttributes",
                                "Union of attributes appearing in all tables")
        OWGUI.appendRadioButton(bg, self, "mergeAttributes",
                                "Intersection of attributes in all tables")
        OWGUI.widgetLabel(
            bg,
            "The resulting table will have class only if there is no conflict between input classes."
        )

        self.adjustSize()
Ejemplo n.º 16
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, "FeatureConstructor")
        # To enable the use of primary table, uncomment the next line  and comment the following one
        # self.inputs = [("Primary Table", dataUtilities.DataTable, self.setData), ("Additional Tables", dataUtilities.DataTable, self.setMoreData, Multiple)]
        self.inputs = [("Tables", orange.ExampleTable, self.setMoreData, Multiple)]

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

        self.mergeAttributes = 0
        self.primary = None
        self.additional = {}

        bg = self.bgMerge = OWGUI.radioButtonsInBox(
            self.controlArea, self, "mergeAttributes", [], "Domains merging", callback=self.apply
        )
        OWGUI.widgetLabel(bg, "")  # "When there is no primary table, the domain should be")
        OWGUI.appendRadioButton(bg, self, "mergeAttributes", "Union of attributes appearing in all tables")
        OWGUI.appendRadioButton(bg, self, "mergeAttributes", "Intersection of attributes in all tables")
        # OWGUI.widgetLabel(bg, "The resulting table will have class only if there is no conflict betwen input classes.")

        infoBox = OWGUI.widgetBox(self, "Concatenate status")
        self.infoStatus = OWGUI.widgetLabel(infoBox, "")

        self.viewBT = OWGUI.button(
            self.controlArea,
            self,
            "&View converted incompatible attributes",
            callback=self.viewIncompatible,
            disabled=1,
        )

        self.adjustSize()
Ejemplo n.º 17
0
    def __init__(self, parent=None):
        OWWidget.__init__(self, parent, title='Listbox')

        self.method = 0

        OWGUI.radioButtonsInBox(
            self.controlArea,
            self,
            "method",
            box="Probability estimation",
            btnLabels=["Relative", "Laplace", "m-estimate"],
            tooltips=[
                "Relative frequency of the event",
                "Laplace-corrected estimate", "M-estimate of probability"
            ])
        self.adjustSize()
Ejemplo n.º 18
0
    def __init__(self, parent=None):
        BaseEditor.__init__(self, parent)

        self.measureInd = 0
        self.selectBy = 0
        self.bestN = 10
        self.bestP = 10

        box = OWGUI.radioButtonsInBox(self,
                                      self,
                                      "selectBy", [],
                                      "Feature selection",
                                      callback=self.onChange)

        OWGUI.comboBox(box,
                       self,
                       "measureInd",
                       items=[name for (name, _) in self.MEASURES],
                       label="Measure",
                       callback=self.onChange)

        hbox1 = OWGUI.widgetBox(box, orientation="horizontal", margin=0)
        rb1 = OWGUI.appendRadioButton(box,
                                      self,
                                      "selectBy",
                                      "Best",
                                      insertInto=hbox1,
                                      callback=self.onChange)
        self.spin1 = OWGUI.spin(OWGUI.widgetBox(hbox1),
                                self,
                                "bestN",
                                1,
                                10000,
                                step=1,
                                controlWidth=75,
                                callback=self.onChange,
                                posttext="features")
        OWGUI.rubber(hbox1)

        hbox2 = OWGUI.widgetBox(box, orientation="horizontal", margin=0)
        rb2 = OWGUI.appendRadioButton(box,
                                      self,
                                      "selectBy",
                                      "Best",
                                      insertInto=hbox2,
                                      callback=self.onChange)
        self.spin2 = OWGUI.spin(OWGUI.widgetBox(hbox2),
                                self,
                                "bestP",
                                1,
                                100,
                                step=1,
                                controlWidth=75,
                                callback=self.onChange,
                                posttext="% features")
        OWGUI.rubber(hbox2)

        self.updateSpinStates()

        OWGUI.rubber(box)
Ejemplo n.º 19
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, 'Network Clustering')

        self.inputs = [("Network", orngNetwork.Network, self.setNetwork,
                        Default)]
        self.outputs = [("Network", orngNetwork.Network)]

        self.net = None
        self.method = 0
        self.iterationHistory = 0
        self.autoApply = 0

        self.loadSettings()

        ribg = OWGUI.radioButtonsInBox(self.controlArea,
                                       self,
                                       "method", [],
                                       "Method",
                                       callback=self.cluster)
        OWGUI.appendRadioButton(
            ribg,
            self,
            "method",
            "Label propagation clustering (Raghavan et al., 2007)",
            callback=self.cluster)
        OWGUI.checkBox(OWGUI.indentedBox(ribg),
                       self,
                       "iterationHistory",
                       "Append clustering data on each iteration",
                       callback=self.cluster)
        self.info = OWGUI.widgetLabel(self.controlArea, ' ')
        autoApplyCB = OWGUI.checkBox(self.controlArea, self, "autoApply",
                                     "Commit automatically")
        OWGUI.button(self.controlArea, self, "Commit", callback=self.cluster)
Ejemplo n.º 20
0
 def __init__(self, parent=None, signalManager=None, name="Ensemble"):
     OWWidget.__init__(self, parent, signalManager, name, wantMainArea=False)
     
     self.inputs = [("Learner", orange.Learner, self.setLearner), ("Data", ExampleTable, self.setData)]
     self.outputs = [("Learner", orange.Learner), ("Classifier", orange.Classifier)]
     
     self.method = 0
     self.t = 10
     
     self.loadSettings()
     
     box = OWGUI.radioButtonsInBox(self.controlArea, self, "method",
                                   [name for name, _ in self.METHODS], 
                                   box="Ensemble",
                                   callback=self.onChange)
     
     i_box = OWGUI.indentedBox(box, sep=OWGUI.checkButtonOffsetHint(box.buttons[0]))
     
     OWGUI.spin(i_box, self, "t", min=1, max=100, step=1, label="Number of created classifiers:")
     OWGUI.rubber(self.controlArea)
     OWGUI.button(self.controlArea, self, "&Apply", callback=self.commit)
     
     self.data = None
     self.learner = None
     
     self.resize(100, 100)
Ejemplo n.º 21
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, "FeatureConstructor")
        self.inputs = [("Primary Table", orange.ExampleTable, self.setData),
                       ("Additional Tables", orange.ExampleTable,
                        self.setMoreData, Multiple)]
        self.outputs = [("Examples", ExampleTable)]

        self.mergeAttributes = 0
        self.dataSourceSelected = 1
        self.addIdAs = 0
        self.dataSourceName = "clusterId"

        self.primary = None
        self.additional = {}

        self.loadSettings()

        bg = self.bgMerge = OWGUI.radioButtonsInBox(self.controlArea,
                                                    self,
                                                    "mergeAttributes", [],
                                                    "Domains merging",
                                                    callback=self.apply)
        OWGUI.widgetLabel(
            bg, "When there is no primary table, the domain should be")
        OWGUI.appendRadioButton(bg, self, "mergeAttributes",
                                "Union of attributes appearing in all tables")
        OWGUI.appendRadioButton(bg, self, "mergeAttributes",
                                "Intersection of attributes in all tables")
        OWGUI.widgetLabel(
            bg,
            "The resulting table will have class only if there is no conflict betwen input classes."
        )

        box = OWGUI.widgetBox(self.controlArea, "Data source IDs")
        cb = OWGUI.checkBox(box, self, "dataSourceSelected",
                            "Append data source IDs")
        self.classificationBox = ib = OWGUI.widgetBox(box)
        le = OWGUI.lineEdit(ib,
                            self,
                            "dataSourceName",
                            "Name" + "  ",
                            orientation='horizontal',
                            valueType=str)
        OWGUI.separator(ib, height=4)
        aa = OWGUI.comboBox(
            ib,
            self,
            "addIdAs",
            label="Place" + "  ",
            orientation='horizontal',
            items=["Class attribute", "Attribute", "Meta attribute"])
        cb.disables.append(ib)
        cb.makeConsistent()
        OWGUI.separator(box)
        OWGUI.button(box, self, "Apply Changes", callback=self.apply)

        self.adjustSize()
Ejemplo n.º 22
0
    def __init__(self, parent=None, signalManager=None, name="Distance File", inputItems=True):
        self.callbackDeposit = [] # deposit for OWGUI callback functions
        OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0, resizingEnabled = 1)
        
        if inputItems: 
            self.inputs = [("Data", ExampleTable, self.getExamples, Default)]
            
        self.outputs = [("Distances", orange.SymMatrix)]

        self.recentFiles=[]
        self.fileIndex = 0
        self.takeAttributeNames = False
        self.data = None
        self.matrix = None
        self.invertDistances = 0
        self.normalizeMethod = 0
        self.invertMethod = 0
        self.loadSettings()
        self.labels = None
        
        
        self.dataFileBox = OWGUI.widgetBox(self.controlArea, "Data File", addSpace=True)
        hbox = OWGUI.widgetBox(self.dataFileBox, orientation = 0)
        self.filecombo = OWGUI.comboBox(hbox, self, "fileIndex", callback = self.loadFile)
        self.filecombo.setMinimumWidth(250)
        button = OWGUI.button(hbox, self, '...', callback = self.browseFile)
        button.setIcon(self.style().standardIcon(QStyle.SP_DirOpenIcon))
        button.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed)
        
        if inputItems: 
            self.rbInput = OWGUI.radioButtonsInBox(self.controlArea, self,
                            "takeAttributeNames", ["Use examples as items", 
                            "Use attribute names"], "Items from input data", 
                            callback = self.relabel)
            
            self.rbInput.setDisabled(True)
    #
#        Moved to SymMatrixTransform widget
#
#        ribg = OWGUI.radioButtonsInBox(self.controlArea, self, "normalizeMethod", [], "Normalize method", callback = self.setNormalizeMode)
#        OWGUI.appendRadioButton(ribg, self, "normalizeMethod", "None", callback = self.setNormalizeMode)
#        OWGUI.appendRadioButton(ribg, self, "normalizeMethod", "To interval [0,1]", callback = self.setNormalizeMode)
#        OWGUI.appendRadioButton(ribg, self, "normalizeMethod", "Sigmoid function: 1 / (1 + e^x)", callback = self.setNormalizeMode)
#        
#        ribg = OWGUI.radioButtonsInBox(self.controlArea, self, "invertMethod", [], "Invert method", callback = self.setInvertMode)
#        OWGUI.appendRadioButton(ribg, self, "invertMethod", "None", callback = self.setInvertMode)
#        OWGUI.appendRadioButton(ribg, self, "invertMethod", "-X", callback = self.setInvertMode)
#        OWGUI.appendRadioButton(ribg, self, "invertMethod", "1 - X", callback = self.setInvertMode)
#        OWGUI.appendRadioButton(ribg, self, "invertMethod", "Max - X", callback = self.setInvertMode)
#        OWGUI.appendRadioButton(ribg, self, "invertMethod", "1 / X", callback = self.setInvertMode)
        
        OWGUI.rubber(self.controlArea)
        
        self.adjustSize()

        if self.recentFiles:
            self.loadFile()
Ejemplo n.º 23
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self,parent,signalManager,"Preprocess")
        self.inputs = [("Example Table", ExampleTable, self.dataset)]
        self.outputs = [("Distance Matrix", orange.SymMatrix)]
        self.data = None
        self.distanceType = 0
        self.nDocuments = "N/A"; self.nWords = "N/A"
        self.loadSettings()

        box = OWGUI.widgetBox(self.controlArea, "Info", addSpace = True)
        OWGUI.label(box, self, "Documents: %(nDocuments)s")
        OWGUI.label(box, self, "Words: %(nWords)s")

        OWGUI.radioButtonsInBox(self.controlArea, self, "distanceType", box = "Matrix type",
            btnLabels = ["Similarity [cos(fi)]", "Distance [1/cos(fi)]"], addSpace = True)
        OWGUI.button(self.controlArea, self, "Apply", self.apply)
        OWGUI.rubber(self.controlArea)
        self.adjustSize()
Ejemplo n.º 24
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self,parent,signalManager,"LetterNgram")
        self.inputs = [("Example Table", ExampleTable, self.dataset)]
        self.outputs = [("Example Table", ExampleTable)]

        self.size = 0
        self.data = None
        
        self.loadSettings()
        
        OWGUI.radioButtonsInBox(self.controlArea, self, "size", box = "Ngram size", btnLabels = ["2", "3", "4"], addSpace = True)
        OWGUI.button(self.controlArea, self, "Apply", self.apply)
        self.lblFeatureNo = OWGUI.widgetLabel(self.controlArea, "\nNo. of features: ") # QLabel("\nNo. of features: ", self.controlArea)
        self.adjustSize()
        
        box = OWGUI.widgetBox(self.controlArea, "Text attribute", addSpace = True)
        self.textAttributePos = None
        self.attributesCombo = OWGUI.comboBox(box, self, "textAttributePos", callback = self.setTextAttribute)
        OWGUI.rubber(self.controlArea)
Ejemplo n.º 25
0
    def __init__(self, parent=None):
        BaseEditor.__init__(self, parent)
        self.contInd = 0

        b = OWGUI.radioButtonsInBox(self,
                                    self,
                                    "contInd",
                                    [name for name, _ in self.CONTINUIZERS],
                                    box="Continuize",
                                    callback=self.onChange)
        OWGUI.rubber(b)
Ejemplo n.º 26
0
    def __init__(self, parent):
        BaseEditor.__init__(self, parent)

        self.methodInd = 0
        b = OWGUI.radioButtonsInBox(self,
                                    self,
                                    "methodInd",
                                    [label for label, _ in self.IMPUTERS],
                                    box="Impute",
                                    callback=self.onChange)
        OWGUI.rubber(b)
Ejemplo n.º 27
0
    def __init__(self, parent=None):
        OWWidget.__init__(self, parent, title='X Learner')

        self.method = 0
        self.maxi = 1
        self.cheat = 0
        self.autoApply = True

        self.settingsChanged = False

        OWGUI.radioButtonsInBox(
            self.controlArea,
            self,
            "method", ["Vanishing", "Disappearing", "Invisibilisation"],
            box="Minimization technique",
            callback=self.applyIf)
        OWGUI.separator(self.controlArea)

        box = OWGUI.widgetBox(self.controlArea, "Settings")
        OWGUI.checkBox(box,
                       self,
                       "maxi",
                       "Post-maximize",
                       callback=self.applyIf)
        OWGUI.checkBox(box,
                       self,
                       "cheat",
                       "Quasi-cheating",
                       callback=self.applyIf)
        OWGUI.separator(self.controlArea)

        box = OWGUI.widgetBox(self.controlArea, "Apply")
        applyButton = OWGUI.button(box, self, "Apply", callback=self.apply)
        autoApplyCB = OWGUI.checkBox(box, self, "autoApply",
                                     "Apply automatically")

        OWGUI.setStopper(self, applyButton, autoApplyCB, "settingsChanged",
                         self.apply)

        self.adjustSize()
Ejemplo n.º 28
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.º 29
0
    def __init__(self,parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "Concatenate",
                          wantMainArea=False, resizingEnabled=False)
        self.inputs = [("Primary Data", orange.ExampleTable, self.setData),
                       ("Additional Data", orange.ExampleTable, self.setMoreData, Multiple)]
        self.outputs = [("Data", ExampleTable)]

        self.mergeAttributes = 0
        self.dataSourceSelected = 1
        self.addIdAs = 0
        self.dataSourceName = "clusterId"

        self.primary = None
        self.additional = {}
        
        self.loadSettings()
        
        bg = self.bgMerge = OWGUI.radioButtonsInBox(self.controlArea, self, "mergeAttributes", [], "Domains merging", callback = self.apply)
        OWGUI.widgetLabel(bg, "When there is no primary table, the domain should be")
        OWGUI.appendRadioButton(bg, self, "mergeAttributes", "Union of attributes appearing in all tables")
        OWGUI.appendRadioButton(bg, self, "mergeAttributes", "Intersection of attributes in all tables")
        bg.layout().addSpacing(6)
        label = OWGUI.widgetLabel(bg, "The resulting table will have class only if there is no conflict between input classes.")
        label.setWordWrap(True)

        OWGUI.separator(self.controlArea)
        box = OWGUI.widgetBox(self.controlArea, "Data source IDs", addSpace=True)
        cb = OWGUI.checkBox(box, self, "dataSourceSelected", "Append data source IDs")
        self.classificationBox = ib = OWGUI.indentedBox(box, sep=OWGUI.checkButtonOffsetHint(cb))

        form = QFormLayout(
            spacing=8, labelAlignment=Qt.AlignLeft, formAlignment=Qt.AlignLeft,
            fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow
        )
        ib.layout().addLayout(form)

        form.addRow("Name",
                    OWGUI.lineEdit(ib, self, "dataSourceName", valueType=str))

        aa = OWGUI.comboBox(ib, self, "addIdAs", items=["Class attribute", "Attribute", "Meta attribute"])
        cb.disables.append(ib)
        cb.makeConsistent()
        form.addRow("Place", aa)

        OWGUI.button(self.controlArea, self, "Apply Changes", callback = self.apply, default=True)
        
        OWGUI.rubber(self.controlArea)

        self.adjustSize()
        
        self.dataReport = None
Ejemplo n.º 30
0
    def __init__(self, parent=None):
        BaseEditor.__init__(self, parent)
        self.methodInd = 0
        self.sampleN = 100
        self.sampleP = 25

        box = OWGUI.radioButtonsInBox(self,
                                      self,
                                      "methodInd", [],
                                      box="Sample",
                                      callback=self.onChange)

        w1 = OWGUI.widgetBox(box, orientation="horizontal", margin=0)
        rb1 = OWGUI.appendRadioButton(box,
                                      self,
                                      "methodInd",
                                      "Sample",
                                      insertInto=w1)
        self.sb1 = OWGUI.spin(OWGUI.widgetBox(w1),
                              self,
                              "sampleN",
                              min=1,
                              max=100000,
                              step=1,
                              controlWidth=75,
                              callback=self.onChange,
                              posttext="data instances")
        OWGUI.rubber(w1)

        w2 = OWGUI.widgetBox(box, orientation="horizontal", margin=0)
        rb2 = OWGUI.appendRadioButton(box,
                                      self,
                                      "methodInd",
                                      "Sample",
                                      insertInto=w2)
        self.sb2 = OWGUI.spin(OWGUI.widgetBox(w2),
                              self,
                              "sampleP",
                              min=1,
                              max=100,
                              step=1,
                              controlWidth=75,
                              callback=self.onChange,
                              posttext="% data instances")
        OWGUI.rubber(w2)

        self.updateSpinStates()

        OWGUI.rubber(box)
Ejemplo n.º 31
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self,parent,signalManager,"BagofWords")
        self.inputs = [("Example Table", ExampleTable, self.dataset)]
        self.outputs = [("Bag-of-Words", ExampleTable)]

        self.TFIDF = 0
        self.norm = 0
        self.nDocuments = "N/A"; self.nStrAttributes = "N/A"; self.nWords = "N/A"
        self.textAttribute = None
        self.data = None
        
        self.loadSettings()

        box = OWGUI.widgetBox(self.controlArea, "Info", addSpace = True)
        OWGUI.label(box, self, "Documents: %(nDocuments)s")
        OWGUI.label(box, self, "String attributes: %(nStrAttributes)s")
        OWGUI.label(box, self, "Words: %(nWords)s")

        OWGUI.radioButtonsInBox(self.controlArea, self, "TFIDF", ["None", "log(1/f)"], "TFIDF", addSpace = True)
        OWGUI.radioButtonsInBox(self.controlArea, self, "norm", ["None", "L1 (Sum of elements)", "L2 (Euclidean)"], "Normalization", addSpace = True)
        
        self.attributesCombo = OWGUI.comboBox(self.controlArea, self, "textAttribute", box="Text attribute", callback=self.apply)
        OWGUI.rubber(self.controlArea)
        self.adjustSize()        
Ejemplo n.º 32
0
    def defineGUI(self):        

        OWGUI.lineEdit(self.controlArea, self, 'name', box='Learner/Classifier Name', \
                       tooltip='Name to be used by other widgets to identify your learner/classifier.<br>This should be a unique name!')

        OWGUI.separator(self.controlArea, 0, 30)

        self.bBox = self.controlArea# QGroupBox('Model parameters for the Random Forest algorithm',self.controlArea)
        #self.bBox.setTitle('Model parameters for the Random Forest algorithm')

        OWGUI.lineEdit(self.bBox, self, 'nActVars', box='The number of active attributes', \
                       tooltip='The number of randomly sampled attributes at each node.\nThe default value 0, sets the number of samples \nto the square root of the total number of samples.')
        OWGUI.lineEdit(self.bBox, self, 'maxDepth', box='Maximum branching depth.', \
                       tooltip='The maximal number of nodes along one branch')
        OWGUI.lineEdit(self.bBox, self, 'minSample', box='Minimum number of samples', \
                       tooltip='The number of samples at which to stop branching.')

        self.trainingBox=b=QButtonGroup(self.bBox)#"Termination criteria", self.bBox)
        self.trainingBox=b=OWGUI.widgetBox(self.bBox, "Termination criteria")
        self.trainingRadio = OWGUI.radioButtonsInBox(b, self, "termCrit", btnLabels= \
                             ["Number of trees in the forest", "Out of bag error to achive before termination          "])
        OWGUI.lineEdit(self.bBox, self, 'nTrees', box='The number of trees', \
                       tooltip='This is the termination criteria used if "Number of trees in the forest" is checked')
        OWGUI.lineEdit(self.bBox, self, 'forestAcc', box='OOB error', \
                       tooltip='This is the termination criteria used if "Out of bag error" is checked')
        self.priorBox = OWGUI.lineEdit(self.bBox, self, 'priorsGUI', box='Class weights ', \
                       tooltip='Ex: POS:0.8 , NEG:0.2')
        #OWGUI.separator(self.bBox, 0, 5)
        #OWGUI.checkBox(self.bBox, self, 'stratify','Stratify',  tooltip='Stratify?')
        OWGUI.checkBox(self.bBox, self, 'useBuiltInMissValHandling','Use surrogate nodes for missing value handling',  tooltip='Use the RF built in missing value handling (as originally implemented by Breiman and Cutler) instead of the AZorange imputer. The training will be more time consuming and the model larger.')

        # Apply the settings and send the learner to the output channel
        OWGUI.button(self.controlArea, self,"&Apply settings", callback=self.applySettings)

        # Get desired location of model file
        boxFile = OWGUI.widgetBox(self.controlArea, "Path for saving Model", addSpace = True, orientation=0)
        L1 = OWGUI.lineEdit(boxFile, self, "modelFile", labelWidth=80,  orientation = "horizontal", \
        tooltip = "Once a model is created (connect this widget with a data widget), \nit can be saved by giving a \
file name here and clicking the save button.\nPlease observe that model names should not contain an extention.")
        L1.setMinimumWidth(200)
        button = OWGUI.button(boxFile, self, '...', callback = self.browseFile, disabled=0,tooltip = "Choose the dir where to save. After chosen, add a name for the model file!")
        button.setMaximumWidth(25)

        # Save the model
        OWGUI.button(self.controlArea, self,"&Save model to file", callback=self.saveModel)

        self.resize(200,400)
Ejemplo n.º 33
0
    def __init__(self, graph, extraButtons = [], defaultName="graph", parent=None, saveMatplotlib=None):
        OWBaseWidget.__init__(self, parent, None, "Image settings", modal = TRUE, resizingEnabled = 0)

        self.graph = graph
        self.selectedSize = 0
        self.customX = 400
        self.customY = 400
        self.saveAllSizes = 0
        self.penWidthFactor = 1
        self.lastSaveDirName = "./"
        self.defaultName = defaultName

        self.loadSettings()

        self.setLayout(QVBoxLayout(self))
        self.space = OWGUI.widgetBox(self)
        self.layout().setMargin(8)
        #self.layout().addWidget(self.space)

        box = OWGUI.widgetBox(self.space, "Image Size")

        global _have_qwt
        if _have_qwt and isinstance(graph, QwtPlot):
            size = OWGUI.radioButtonsInBox(box, self, "selectedSize", ["Current size", "400 x 400", "600 x 600", "800 x 800", "Custom:"], callback = self.updateGUI)
            self.customXEdit = OWGUI.lineEdit(OWGUI.indentedBox(box), self, "customX", "Width: ", orientation = "horizontal", valueType = int)
            self.customYEdit = OWGUI.lineEdit(OWGUI.indentedBox(box), self, "customY", "Height:", orientation = "horizontal", valueType = int)
            OWGUI.comboBoxWithCaption(self.space, self, "penWidthFactor", label = 'Factor:   ', box = " Pen width multiplication factor ",  tooltip = "Set the pen width factor for all curves in the plot\n(Useful for example when the lines in the plot look to thin)\nDefault: 1", sendSelectedValue = 1, valueType = int, items = range(1,20))
        elif isinstance(graph, QGraphicsScene) or isinstance(graph, QGraphicsView) or (_have_gl and isinstance(graph, QGLWidget)):
            OWGUI.widgetLabel(box, "Image size will be set automatically.")

        box = OWGUI.widgetBox(self.space, 1)
        #self.printButton =          OWGUI.button(self.space, self, "Print", callback = self.printPic)
        self.saveImageButton =      OWGUI.button(box, self, "Save Image", callback = self.saveImage)

        # If None we try to determine if save can succeed automatically
        if saveMatplotlib is None:
            saveMatplotlib = self.canSaveToMatplotlib(graph)

        if saveMatplotlib and not (_have_gl and isinstance(graph, QGLWidget)):
            self.saveMatplotlibButton = OWGUI.button(box, self, "Save Graph as matplotlib Script", callback = self.saveToMatplotlib)
        for (text, funct) in extraButtons:
            butt = OWGUI.button(box, self, text, callback = funct)
            self.connect(butt, SIGNAL("clicked()"), self.accept)        # also connect the button to accept so that we close the dialog
        OWGUI.button(box, self, "Cancel", callback = self.reject)

        self.resize(250,300)
        self.updateGUI()
Ejemplo n.º 34
0
    def __init__(self,parent=None, signalManager = None, name = "Continuizer"):
        OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0)

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

        self.multinomialTreatment = 0
        self.targetValue = 0
        self.continuousTreatment = 0
        self.classTreatment = 0
        self.zeroBased = 1
        self.autosend = 0
        self.dataChanged = False
        self.loadSettings()

        bgMultiTreatment = OWGUI.widgetBox(self.controlArea, "Multinomial attributes")
        OWGUI.radioButtonsInBox(bgMultiTreatment, self, "multinomialTreatment", btnLabels=[x[0] for x in self.multinomialTreats], callback=self.sendDataIf)

        self.controlArea.layout().addSpacing(4)

        bgMultiTreatment = OWGUI.widgetBox(self.controlArea, "Continuous attributes")
        OWGUI.radioButtonsInBox(bgMultiTreatment, self, "continuousTreatment", btnLabels=[x[0] for x in self.continuousTreats], callback=self.sendDataIf)

        self.controlArea.layout().addSpacing(4)

        bgClassTreatment = OWGUI.widgetBox(self.controlArea, "Discrete class attribute")
        self.ctreat = OWGUI.radioButtonsInBox(bgClassTreatment, self, "classTreatment", btnLabels=[x[0] for x in self.classTreats], callback=self.sendDataIf)
#        hbox = OWGUI.widgetBox(bgClassTreatment, orientation = "horizontal")
#        OWGUI.separator(hbox, 19, 4)
        hbox = OWGUI.indentedBox(bgClassTreatment, sep=OWGUI.checkButtonOffsetHint(self.ctreat.buttons[-1]), orientation="horizontal")
        self.cbTargetValue = OWGUI.comboBox(hbox, self, "targetValue", label="Target Value ", items=[], orientation="horizontal", callback=self.cbTargetSelected)
        def setEnabled(*args):
            self.cbTargetValue.setEnabled(self.classTreatment == 3)
        self.connect(self.ctreat.group, SIGNAL("buttonClicked(int)"), setEnabled)
        setEnabled() 

        self.controlArea.layout().addSpacing(4)

        zbbox = OWGUI.widgetBox(self.controlArea, "Value range")
        OWGUI.radioButtonsInBox(zbbox, self, "zeroBased", btnLabels=self.valueRanges, callback=self.sendDataIf)

        self.controlArea.layout().addSpacing(4)

        snbox = OWGUI.widgetBox(self.controlArea, "Send data")
        OWGUI.button(snbox, self, "Send data", callback=self.sendData, default=True)
        OWGUI.checkBox(snbox, self, "autosend", "Send automatically", callback=self.enableAuto)
        self.data = None
        self.sendPreprocessor()
        self.resize(150,300)
    def __init__(self,parent=None, signalManager = None, name = "Continuizer"):
        OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0)

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

        self.multinomialTreatment = 0
        self.targetValue = 0
        self.continuousTreatment = 0
        self.classTreatment = 0
        self.zeroBased = 1
        self.autosend = 0
        self.dataChanged = False
        self.loadSettings()

        bgMultiTreatment = OWGUI.widgetBox(self.controlArea, "Multinomial attributes")
        OWGUI.radioButtonsInBox(bgMultiTreatment, self, "multinomialTreatment", btnLabels=[x[0] for x in self.multinomialTreats], callback=self.sendDataIf)

        self.controlArea.layout().addSpacing(4)

        bgMultiTreatment = OWGUI.widgetBox(self.controlArea, "Continuous attributes")
        OWGUI.radioButtonsInBox(bgMultiTreatment, self, "continuousTreatment", btnLabels=[x[0] for x in self.continuousTreats], callback=self.sendDataIf)

        self.controlArea.layout().addSpacing(4)

        bgClassTreatment = OWGUI.widgetBox(self.controlArea, "Discrete class attribute")
        self.ctreat = OWGUI.radioButtonsInBox(bgClassTreatment, self, "classTreatment", btnLabels=[x[0] for x in self.classTreats], callback=self.sendDataIf)
#        hbox = OWGUI.widgetBox(bgClassTreatment, orientation = "horizontal")
#        OWGUI.separator(hbox, 19, 4)
        hbox = OWGUI.indentedBox(bgClassTreatment, sep=OWGUI.checkButtonOffsetHint(self.ctreat.buttons[-1]), orientation="horizontal")
        self.cbTargetValue = OWGUI.comboBox(hbox, self, "targetValue", label="Target Value ", items=[], orientation="horizontal", callback=self.cbTargetSelected)
        def setEnabled(*args):
            self.cbTargetValue.setEnabled(self.classTreatment == 3)
        self.connect(self.ctreat.group, SIGNAL("buttonClicked(int)"), setEnabled)
        setEnabled() 

        self.controlArea.layout().addSpacing(4)

        zbbox = OWGUI.widgetBox(self.controlArea, "Value range")
        OWGUI.radioButtonsInBox(zbbox, self, "zeroBased", btnLabels=self.valueRanges, callback=self.sendDataIf)

        self.controlArea.layout().addSpacing(4)

        snbox = OWGUI.widgetBox(self.controlArea, "Send data")
        OWGUI.button(snbox, self, "Send data", callback=self.sendData, default=True)
        OWGUI.checkBox(snbox, self, "autosend", "Send automatically", callback=self.enableAuto)
        self.data = None
        self.sendPreprocessor()
        self.resize(150,300)
Ejemplo n.º 36
0
 def __init__(self, parent=None, signalManager=None):
     OWWidget.__init__(self, parent, signalManager, 'Network Clustering')
     
     self.inputs = [("Network", orngNetwork.Network, self.setNetwork, Default)]
     self.outputs = [("Network", orngNetwork.Network)]
     
     self.net = None
     self.method = 0
     self.iterationHistory = 0
     self.autoApply = 0
     
     self.loadSettings()
     
     ribg = OWGUI.radioButtonsInBox(self.controlArea, self, "method", [], "Method", callback = self.cluster)
     OWGUI.appendRadioButton(ribg, self, "method", "Label propagation clustering (Raghavan et al., 2007)", callback = self.cluster)
     OWGUI.checkBox(OWGUI.indentedBox(ribg), self, "iterationHistory", "Append clustering data on each iteration", callback = self.cluster)
     self.info = OWGUI.widgetLabel(self.controlArea, ' ')
     autoApplyCB = OWGUI.checkBox(self.controlArea, self, "autoApply", "Commit automatically")
     OWGUI.button(self.controlArea, self, "Commit", callback=self.cluster)
Ejemplo n.º 37
0
    def __init__(self, graph, extraButtons = [], defaultName="graph", parent=None):
        OWBaseWidget.__init__(self, parent, None, "Image settings", modal = TRUE, resizingEnabled = 0)

        self.graph = graph
        self.selectedSize = 0
        self.customX = 400
        self.customY = 400
        self.saveAllSizes = 0
        self.penWidthFactor = 1
        self.lastSaveDirName = "./"
        self.defaultName = defaultName

        self.loadSettings()

        self.setLayout(QVBoxLayout(self))
        self.space = OWGUI.widgetBox(self)
        self.layout().setMargin(8)
        #self.layout().addWidget(self.space)

        box = OWGUI.widgetBox(self.space, "Image Size")

        global _have_qwt
        if _have_qwt and isinstance(graph, QwtPlot):
            size = OWGUI.radioButtonsInBox(box, self, "selectedSize", ["Current size", "400 x 400", "600 x 600", "800 x 800", "Custom:"], callback = self.updateGUI)
            self.customXEdit = OWGUI.lineEdit(OWGUI.indentedBox(box), self, "customX", "Width: ", orientation = "horizontal", valueType = int)
            self.customYEdit = OWGUI.lineEdit(OWGUI.indentedBox(box), self, "customY", "Height:", orientation = "horizontal", valueType = int)
            OWGUI.comboBoxWithCaption(self.space, self, "penWidthFactor", label = 'Factor:   ', box = " Pen width multiplication factor ",  tooltip = "Set the pen width factor for all curves in the plot\n(Useful for example when the lines in the plot look to thin)\nDefault: 1", sendSelectedValue = 1, valueType = int, items = range(1,20))
        elif isinstance(graph, QGraphicsScene) or isinstance(graph, QGraphicsView) or (_have_gl and isinstance(graph, QGLWidget)):
            OWGUI.widgetLabel(box, "Image size will be set automatically.")

        box = OWGUI.widgetBox(self.space, 1)
        #self.printButton =          OWGUI.button(self.space, self, "Print", callback = self.printPic)
        self.saveImageButton =      OWGUI.button(box, self, "Save Image", callback = self.saveImage)
        if not (_have_gl and isinstance(graph, QGLWidget)):
            self.saveMatplotlibButton = OWGUI.button(box, self, "Save Graph as matplotlib Script", callback = self.saveToMatplotlib)
        for (text, funct) in extraButtons:
            butt = OWGUI.button(box, self, text, callback = funct)
            self.connect(butt, SIGNAL("clicked()"), self.accept)        # also connect the button to accept so that we close the dialog
        OWGUI.button(box, self, "Cancel", callback = self.reject)

        self.resize(250,300)
        self.updateGUI()
Ejemplo n.º 38
0
    def __init__(self,
                 parent=None,
                 signalManager=None,
                 name='AttributeDistance'):
        self.callbackDeposit = []  # deposit for OWGUI callback functions
        OWWidget.__init__(self,
                          parent,
                          signalManager,
                          name,
                          wantMainArea=0,
                          resizingEnabled=0)

        self.inputs = [("Examples", ExampleTable, self.dataset)]
        self.outputs = [("Distance Matrix", orange.SymMatrix)]

        self.data = None

        self.classInteractions = 0
        self.loadSettings()
        rb = OWGUI.radioButtonsInBox(self.controlArea,
                                     self,
                                     "classInteractions", [],
                                     "Distance",
                                     callback=self.toggleClass)
        OWGUI.widgetLabel(
            rb,
            "Measures on discrete attributes\n   (continuous attributes are discretized into five intervals)"
        )
        for b in self.discMeasures:
            OWGUI.appendRadioButton(rb, self, "classInteractions", b)

        OWGUI.widgetLabel(
            rb, "\n" +
            "Measures on continuous attributes\n   (discrete attributes are treated as ordinal)"
        )
        for b in self.contMeasures:
            OWGUI.appendRadioButton(rb, self, "classInteractions", b)

        OWGUI.rubber(self.controlArea)
        self.resize(215, 50)
Ejemplo n.º 39
0
    def __init__(self, parent=None, signalManager = None, name='AttributeDistance'):
        self.callbackDeposit = [] # deposit for OWGUI callback functions
        OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0, resizingEnabled = 0)

        self.inputs = [("Data", ExampleTable, self.dataset)]
        self.outputs = [("Distances", orange.SymMatrix)]

        self.data = None

        self.classInteractions = 0
        self.loadSettings()
        rb = OWGUI.radioButtonsInBox(self.controlArea, self, "classInteractions", [], "Distance", callback=self.toggleClass)
        OWGUI.widgetLabel(rb, "Measures on discrete attributes\n   (continuous attributes are discretized into five intervals)")
        for b in self.discMeasures:
            OWGUI.appendRadioButton(rb, self, "classInteractions", b)
        
        OWGUI.widgetLabel(rb, "\n"+"Measures on continuous attributes\n   (discrete attributes are treated as ordinal)")
        for b in self.contMeasures:
            OWGUI.appendRadioButton(rb, self, "classInteractions", b)
            
        OWGUI.rubber(self.controlArea)
        self.resize(215,50)
Ejemplo n.º 40
0
    def defineGUI(self):

        # Set the precision throught the GUI 
        OWGUI.lineEdit(self.controlArea, self, 'name', box='Learner/Classifier Name', \
                       tooltip='Name to be used by other widgets to identify your learner/classifier.<br>This should be a unique name!')

        OWGUI.lineEdit(self.controlArea, self, 'precision', box='Precision', \
        tooltip='Desired precision.')

        # Set the number of components of PLS throught the GUI 
        OWGUI.lineEdit(self.controlArea, self, 'k', box='The number of components (factors)', \
        tooltip='The number of components to include.')

        # Set the training PLS methodGUI throught the GUI 
        self.trainingBox=b=OWGUI.widgetBox(self.controlArea, "PLS method")
        self.trainingRadio = OWGUI.radioButtonsInBox(b, self, "methodGUI", btnLabels= \
        ["KERNEL - The NIPALS-kernel method.", \
        "SIMPLS - The SIMPLS method.", \
        "PLS1 - The original PLS method."])

        # Apply the settings and send the learner to the output channel
        OWGUI.button(self.controlArea, self,"&Apply settings", callback=self.applySettings)

        #Refresh Learner Parameters
        #OWGUI.button(self.controlArea, self,"&Refresh parameters", callback=self.refreshParams)
        
        # Set location of model file
        boxFile = OWGUI.widgetBox(self.controlArea, "Path for saving Model", addSpace = True, orientation=0)
        L1 = OWGUI.lineEdit(boxFile, self, "modelPath", labelWidth=80,  orientation = "horizontal", tooltip = "Once a model is created (connect this widget with a data widget), \nit can be saved by giving a \
file name here and clicking the save button.")
        L1.setMinimumWidth(200)
        button = OWGUI.button(boxFile, self, '...', callback = self.browseFile, disabled=0,tooltip = "Choose the dir where to save. After chosen, add a name for the model file!")
        button.setMaximumWidth(25)

        # Save the model
        OWGUI.button(self.controlArea, self,"&Save PLS model", callback=self.saveModel)

        self.adjustSize()
Ejemplo n.º 41
0
    def __init__(self,parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "Concatenate", wantMainArea=0)
        self.inputs = [("Primary Data", orange.ExampleTable, self.setData), ("Additional Data", orange.ExampleTable, self.setMoreData, Multiple)]
        self.outputs = [("Data", ExampleTable)]

        self.mergeAttributes = 0
        self.dataSourceSelected = 1
        self.addIdAs = 0
        self.dataSourceName = "clusterId"

        self.primary = None
        self.additional = {}
        
        self.loadSettings()
        
        bg = self.bgMerge = OWGUI.radioButtonsInBox(self.controlArea, self, "mergeAttributes", [], "Domains merging", callback = self.apply)
        OWGUI.widgetLabel(bg, "When there is no primary table, the domain should be")
        OWGUI.appendRadioButton(bg, self, "mergeAttributes", "Union of attributes appearing in all tables")
        OWGUI.appendRadioButton(bg, self, "mergeAttributes", "Intersection of attributes in all tables")
        OWGUI.widgetLabel(bg, "The resulting table will have class only if there is no conflict between input classes.")

        OWGUI.separator(self.controlArea)
        box = OWGUI.widgetBox(self.controlArea, "Data source IDs", addSpace=True)
        cb = OWGUI.checkBox(box, self, "dataSourceSelected", "Append data source IDs")
        self.classificationBox = ib = OWGUI.indentedBox(box, sep=OWGUI.checkButtonOffsetHint(cb))
        le = OWGUI.lineEdit(ib, self, "dataSourceName", "Name" + "  ", orientation='horizontal', valueType = str)
        OWGUI.separator(ib, height = 4)
        aa = OWGUI.comboBox(ib, self, "addIdAs", label = "Place" + "  ", orientation = 'horizontal', items = ["Class attribute", "Attribute", "Meta attribute"])
        cb.disables.append(ib)
        cb.makeConsistent()
        
        OWGUI.button(self.controlArea, self, "Apply Changes", callback = self.apply, default=True)
        
        OWGUI.rubber(self.controlArea)

        self.adjustSize()
        
        self.dataReport = None
Ejemplo n.º 42
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, 'Nx Clustering')

        self.inputs = [("Network", Orange.network.Graph,
                        self.setNetwork, Default)]
        self.outputs = [("Network", Orange.network.Graph)]

        self.net = None
        self.method = 0
        self.iterationHistory = 0
        self.autoApply = 0
        self.iterations = 1000
        self.hop_attenuation = 0.1
        self.loadSettings()

        OWGUI.spin(self.controlArea, self, "iterations", 1,
                   100000, 1, label="Iterations: ")
        ribg = OWGUI.radioButtonsInBox(self.controlArea, self, "method",
                                       [], "Method", callback=self.cluster)
        OWGUI.appendRadioButton(ribg, self, "method",
                        "Label propagation clustering (Raghavan et al., 2007)",
                        callback=self.cluster)

        OWGUI.appendRadioButton(ribg, self, "method",
                        "Label propagation clustering (Leung et al., 2009)",
                        callback=self.cluster)
        OWGUI.doubleSpin(OWGUI.indentedBox(ribg), self, "hop_attenuation",
                         0, 1, 0.01, label="Hop attenuation (delta): ")

        self.info = OWGUI.widgetLabel(self.controlArea, ' ')
        OWGUI.checkBox(self.controlArea, self, "iterationHistory",
                       "Append clustering data on each iteration",
                       callback=self.cluster)
        OWGUI.checkBox(self.controlArea, self, "autoApply",
                       "Commit automatically")
        OWGUI.button(self.controlArea, self, "Commit",
                     callback=lambda b=True: self.cluster(b))
Ejemplo n.º 43
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, "FeatureConstructor")
        #To enable the use of primary table, uncomment the next line  and comment the following one
        #self.inputs = [("Primary Table", dataUtilities.DataTable, self.setData), ("Additional Tables", dataUtilities.DataTable, self.setMoreData, Multiple)]
        self.inputs = [("Tables", orange.ExampleTable, self.setMoreData,
                        Multiple)]

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

        self.mergeAttributes = 0
        self.primary = None
        self.additional = {}

        bg = self.bgMerge = OWGUI.radioButtonsInBox(self.controlArea,
                                                    self,
                                                    "mergeAttributes", [],
                                                    "Domains merging",
                                                    callback=self.apply)
        OWGUI.widgetLabel(
            bg, "")  # "When there is no primary table, the domain should be")
        OWGUI.appendRadioButton(bg, self, "mergeAttributes",
                                "Union of attributes appearing in all tables")
        OWGUI.appendRadioButton(bg, self, "mergeAttributes",
                                "Intersection of attributes in all tables")
        #OWGUI.widgetLabel(bg, "The resulting table will have class only if there is no conflict betwen input classes.")

        infoBox = OWGUI.widgetBox(self, "Concatenate status")
        self.infoStatus = OWGUI.widgetLabel(infoBox, '')

        self.viewBT = OWGUI.button(self.controlArea,
                                   self,
                                   "&View converted incompatible attributes",
                                   callback=self.viewIncompatible,
                                   disabled=1)

        self.adjustSize()
Ejemplo n.º 44
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.º 45
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, 'k-Means Clustering')

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

        #set default settings
        self.K = 2
        self.optimized = True
        self.optimizationFrom = 2
        self.optimizationTo = 5
        self.scoring = 0
        self.distanceMeasure = 0
        self.initializationType = 0
        self.restarts = 1
        self.classifySelected = 1
        self.addIdAs = 0
        self.runAnyChange = 1
        self.classifyName = "Cluster"

        self.settingsChanged = False

        self.loadSettings()

        self.data = None  # holds input data
        self.km = None    # holds clustering object

        # GUI definition
        # settings

        box = OWGUI.widgetBox(self.controlArea, "Clusters (k)",
                              addSpace=True, spacing=0)
#        left, top, right, bottom = box.getContentsMargins()
#        box.setContentsMargins(left, 0, right, 0)
        bg = OWGUI.radioButtonsInBox(box, self, "optimized", [],
                                     callback=self.setOptimization)

        fixedBox = OWGUI.widgetBox(box, orientation="horizontal",
                                   margin=0, spacing=bg.layout().spacing())

        button = OWGUI.appendRadioButton(bg, self, "optimized", "Fixed",
                                         insertInto=fixedBox,
                                         tooltip="Fixed number of clusters")

        button.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        fixedBox.layout().setAlignment(button, Qt.AlignLeft)
        self.fixedSpinBox = OWGUI.spin(OWGUI.widgetBox(fixedBox), self, "K",
                                       min=2, max=30,
                                       tooltip="Fixed number of clusters",
                                       callback=self.update,
                                       callbackOnReturn=True)

        optimizedBox = OWGUI.widgetBox(box, margin=0,
                                       spacing=bg.layout().spacing())
        button = OWGUI.appendRadioButton(bg, self, "optimized", "Optimized",
                                         insertInto=optimizedBox)

        box = OWGUI.indentedBox(optimizedBox,
                                sep=OWGUI.checkButtonOffsetHint(button))

        box.layout().setSpacing(0)
        self.optimizationBox = box

        OWGUI.spin(box, self, "optimizationFrom", label="From",
                   min=2, max=99,
                   tooltip="Minimum number of clusters to try",
                   callback=self.updateOptimizationFrom,
                   callbackOnReturn=True)

        OWGUI.spin(box, self, "optimizationTo", label="To",
                   min=3, max=100,
                   tooltip="Maximum number of clusters to try",
                   callback=self.updateOptimizationTo,
                   callbackOnReturn=True)

        OWGUI.comboBox(box, self, "scoring", label="Scoring",
                       orientation="horizontal",
                       items=[m[0] for m in self.scoringMethods],
                       callback=self.update)

        box = OWGUI.widgetBox(self.controlArea, "Settings", addSpace=True)

        OWGUI.comboBox(box, self, "distanceMeasure", label="Distance measures",
                       items=[name for name, _ in self.distanceMeasures],
                       tooltip=None,
                       indent=20,
                       callback=self.update)

        cb = OWGUI.comboBox(box, self, "initializationType",
                            label="Initialization",
                            items=[name for name, _ in self.initializations],
                            tooltip=None,
                            indent=20,
                            callback=self.update)

        OWGUI.spin(cb.box, self, "restarts", label="Restarts",
                   orientation="horizontal",
                   min=1,
                   max=100 if not orngDebugging.orngDebuggingEnabled else 5,
                   callback=self.update,
                   callbackOnReturn=True)

        box = OWGUI.widgetBox(self.controlArea, "Cluster IDs", addSpace=True)
        cb = OWGUI.checkBox(box, self, "classifySelected",
                            "Append cluster indices")

        box = OWGUI.indentedBox(box, sep=OWGUI.checkButtonOffsetHint(cb))

        form = QWidget()
        le = OWGUI.lineEdit(form, self, "classifyName", None,
                            orientation="horizontal",
                            valueType=str)

        cc = OWGUI.comboBox(form, self, "addIdAs", label=" ",
                            orientation="horizontal",
                            items=["Class attribute",
                                   "Attribute",
                                   "Meta attribute"])

        layout = QFormLayout()
        layout.setSpacing(8)
        layout.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow)
        layout.setLabelAlignment(Qt.AlignLeft | Qt.AlignJustify)
        layout.addRow("Name  ", le)
        layout.addRow("Place  ", cc)

        form.setLayout(layout)
        box.layout().addWidget(form)
        left, top, right, bottom = layout.getContentsMargins()
        layout.setContentsMargins(0, top, right, bottom)

        cb.disables.append(box)
        cb.makeConsistent()

        box = OWGUI.widgetBox(self.controlArea, "Run")
        cb = OWGUI.checkBox(box, self, "runAnyChange", "Run after any change")
        self.runButton = b = OWGUI.button(box, self, "Run Clustering",
                                          callback=self.run)

        OWGUI.setStopper(self, b, cb, "settingsChanged", callback=self.run)

        OWGUI.rubber(self.controlArea)

        # display of clustering results
        self.optimizationReportBox = OWGUI.widgetBox(self.mainArea)
        self.tableBox = OWGUI.widgetBox(self.optimizationReportBox,
                                        "Optimization Report")
        self.table = OWGUI.table(self.tableBox,
                                 selectionMode=QTableWidget.SingleSelection)

        self.table.setHorizontalScrollMode(QTableWidget.ScrollPerPixel)
        self.table.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.table.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.table.setColumnCount(3)
        self.table.setHorizontalHeaderLabels(["k", "Best", "Score"])
        self.table.verticalHeader().hide()
        self.table.horizontalHeader().setStretchLastSection(True)

        self.table.setItemDelegateForColumn(
            2, OWGUI.TableBarItem(self, self.table))

        self.table.setItemDelegateForColumn(
            1, OWGUI.IndicatorItemDelegate(self))

        self.table.setSizePolicy(QSizePolicy.MinimumExpanding,
                                 QSizePolicy.MinimumExpanding)

        self.connect(self.table,
                     SIGNAL("itemSelectionChanged()"),
                     self.tableItemSelected)

        self.setSizePolicy(QSizePolicy.Preferred,
                           QSizePolicy.Preferred)

        self.mainArea.setSizePolicy(QSizePolicy.MinimumExpanding,
                                    QSizePolicy.MinimumExpanding)

        OWGUI.rubber(self.topWidgetPart)

        self.updateOptimizationGui()
Ejemplo n.º 46
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()
Ejemplo n.º 47
0
    def __init__(self, parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "FileEngage", wantMainArea = 0, resizingEnabled = 1)

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

        self.recentFiles=["(none)"]
        self.symbolDC = "?"
        self.symbolDK = "~"
        self.createNewOn = 1
        self.domain = None
        self.loadedFile = ""
        self.showAdvanced = 0
        self.loadSettings()

        box = OWGUI.widgetBox(self.controlArea, "Data File", addSpace = True, orientation=0)
        self.filecombo = QComboBox(box)
        self.filecombo.setMinimumWidth(150)
        box.layout().addWidget(self.filecombo)
        button = OWGUI.button(box, self, '...', callback = self.browseFile, disabled=0)# browse file important function
        button.setIcon(self.style().standardIcon(QStyle.SP_DirOpenIcon))
        button.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed)
        
        self.reloadBtn = OWGUI.button(box, self, "Reload", callback = self.reload, default=True)
        self.reloadBtn.setIcon(self.style().standardIcon(QStyle.SP_BrowserReload))
        self.reloadBtn.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        
        box = OWGUI.widgetBox(self.controlArea, "Info", addSpace = True)
        self.infoa = OWGUI.widgetLabel(box, 'No data loaded.')
        self.infob = OWGUI.widgetLabel(box, ' ')
        self.warnings = OWGUI.widgetLabel(box, ' ')
        
        #Set word wrap so long warnings won't expand the widget
        self.warnings.setWordWrap(True)
        self.warnings.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.MinimumExpanding)
        
        smallWidget = OWGUI.collapsableWidgetBox(self.controlArea, "Advanced settings", self, "showAdvanced", callback=self.adjustSize0)
        
        box = OWGUI.widgetBox(smallWidget, "Missing Value Symbols")
#       OWGUI.widgetLabel(box, "Symbols for missing values in tab-delimited files (besides default ones)")
        
        hbox = OWGUI.indentedBox(box)
        OWGUI.lineEdit(hbox, self, "symbolDC", "Don't care:", labelWidth=80, orientation="horizontal", tooltip="Default values: '~' or '*'")
        OWGUI.lineEdit(hbox, self, "symbolDK", "Don't know:", labelWidth=80, orientation="horizontal", tooltip="Default values: empty fields (space), '?' or 'NA'")

        smallWidget.layout().addSpacing(8)
        OWGUI.radioButtonsInBox(smallWidget, self, "createNewOn", box="New Attributes",
                       label = "Create a new attribute when existing attribute(s) ...",
                       btnLabels = ["Have mismatching order of values",
                                    "Have no common values with the new (recommended)",
                                    "Miss some values of the new attribute",
                                    "... Always create a new attribute"
                               ])
        
        OWGUI.rubber(smallWidget)
        smallWidget.updateControls()
        
        OWGUI.rubber(self.controlArea)
        
        # remove missing data set names
        def exists(path):
            if not os.path.exists(path):
                dirpath, basename = os.path.split(path)
                return os.path.exists(os.path.join("./", basename))
            else:
                return True
        self.recentFiles = filter(exists, self.recentFiles)
        self.setFileList()

        if len(self.recentFiles) > 0 and exists(self.recentFiles[0]):
            self.openFile(self.recentFiles[0], 0, self.symbolDK, self.symbolDC)

        self.connect(self.filecombo, SIGNAL('activated(int)'), self.selectFile)
Ejemplo n.º 48
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.º 49
0
    def __init__(self, parent=None, signalManager=None,
                 title="CSV File Import"):
        OWWidget.__init__(self, parent, signalManager, title,
                          wantMainArea=False, noReport=True)

        self.symbol_DC = ""
        self.symbol_DK = ""

        #: List of recent opened files.
        self.recent_files = []
        #: Current selected file name
        self.selected_file = None
        #: Variable reuse flag
        self.create_new_on = 2
        #: Display advanced var reuse options
        self.show_advanced = False

        self.loadSettings()

        self.recent_files = filter(os.path.exists, self.recent_files)

        self._loader = None
        self._invalidated = False
        self._datareport = None

        layout = QHBoxLayout()
        OWGUI.widgetBox(self.controlArea, "File", orientation=layout)

        icons = standard_icons(self)

        self.recent_combo = QComboBox(
            self, objectName="recent_combo",
            toolTip="Recent files.",
            activated=self.activate_recent
        )
        cb_append_file_list(self.recent_combo, self.recent_files)

        self.recent_combo.insertSeparator(self.recent_combo.count())
        self.recent_combo.addItem(u"Browse documentation data sets…")

        self.browse_button = QPushButton(
            u"…",
            icon=icons.dir_open_icon, toolTip="Browse filesystem",
            clicked=self.browse
        )

        self.reload_button = QPushButton(
            "Reload", icon=icons.reload_icon,
            toolTip="Reload the selected file", clicked=self.reload,
            default=True
        )

        layout.addWidget(self.recent_combo, 2)
        layout.addWidget(self.browse_button)
        layout.addWidget(self.reload_button)

        ###########
        # Info text
        ###########
        box = OWGUI.widgetBox(self.controlArea, "Info", addSpace=True)
        self.infoa = OWGUI.widgetLabel(box, "No data loaded.")
        self.infob = OWGUI.widgetLabel(box, " ")
        self.warnings = OWGUI.widgetLabel(box, " ")

        # Set word wrap so long warnings won't expand the widget
        self.warnings.setWordWrap(True)
        self.warnings.setSizePolicy(QSizePolicy.Ignored,
                                    QSizePolicy.MinimumExpanding)

        advanced = QGroupBox(
            "Advanced Settings", checkable=True, checked=self.show_advanced
        )
        advanced.setLayout(QVBoxLayout())

        def set_group_visible(groupbox, state):
            layout = groupbox.layout()
            for i in range(layout.count()):
                item = layout.itemAt(i)
                widget = item.widget()
                if widget is not None:
                    widget.setVisible(state)
            groupbox.setFlat(not state)

        def toogle_advanced(state):
            self.show_advanced = state
            set_group_visible(advanced, state)
            self.layout().activate()
            QApplication.instance().processEvents()
            QTimer.singleShot(0, self.adjustSize)

        advanced.toggled.connect(toogle_advanced)

        self.taboptions = QWidget()
        self.taboptions.setLayout(QVBoxLayout())
        box = QGroupBox("Missing Value Symbols", flat=True)
        form = QFormLayout(fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow)
        form.addRow(
            "Don't care:",
            OWGUI.lineEdit(None, self, "symbol_DC",
                           tooltip="Default values: '~' or '*'"))
        form.addRow(
            "Don't know:",
            OWGUI.lineEdit(None, self, "symbol_DK",
                           tooltip="Default values: empty fields (space), "
                                   "'?' or 'NA'"))
        box.setLayout(form)
        advanced.layout().addWidget(box)

        rb = OWGUI.radioButtonsInBox(
            advanced, self, "create_new_on",
            box="New Attributes",
            callback=self._invalidate,
            label=u"Create a new attribute when existing attribute(s) …",
            btnLabels=[u"Have mismatching order of values",
                       u"Have no common values with the new (recommended)",
                       u"Miss some values of the new attribute",
                       u"… Always create a new attribute"]
        )
        rb.setFlat(True)
        self.controlArea.layout().addWidget(advanced)

        button_box = QDialogButtonBox(orientation=Qt.Horizontal)
        self.import_options_button = QPushButton(
            u"Import Options…", enabled=False
        )
        self.import_options_button.pressed.connect(self._activate_import_dialog)
        button_box.addButton(
            self.import_options_button, QDialogButtonBox.ActionRole
        )
        button_box.addButton(
            QPushButton("&Report", pressed=self.reportAndFinish),
            QDialogButtonBox.ActionRole
        )
        self.controlArea.layout().addWidget(button_box)

        OWGUI.rubber(self.controlArea)

        set_group_visible(advanced, self.show_advanced)

        if self.recent_files and self.recent_files[0] == self.selected_file:
            QTimer.singleShot(
                0, lambda: self.activate_recent(0)
            )
        else:
            self.selected_file = None
            self.recent_combo.setCurrentIndex(-1)
Ejemplo n.º 50
0
    def __init__(self,
                 parent=None,
                 signalManager=None,
                 title="CSV File Import"):
        OWWidget.__init__(self,
                          parent,
                          signalManager,
                          title,
                          wantMainArea=False,
                          noReport=True)

        self.symbol_DC = ""
        self.symbol_DK = ""

        #: List of recent opened files.
        self.recent_files = []
        #: Current selected file name
        self.selected_file = None
        #: Variable reuse flag
        self.create_new_on = 2
        #: Display advanced var reuse options
        self.show_advanced = False

        self.loadSettings()

        self.recent_files = filter(os.path.exists, self.recent_files)

        self._loader = None
        self._invalidated = False
        self._datareport = None

        layout = QHBoxLayout()
        OWGUI.widgetBox(self.controlArea, "File", orientation=layout)

        icons = standard_icons(self)

        self.recent_combo = QComboBox(self,
                                      objectName="recent_combo",
                                      toolTip="Recent files.",
                                      activated=self.activate_recent)
        cb_append_file_list(self.recent_combo, self.recent_files)

        self.recent_combo.insertSeparator(self.recent_combo.count())
        self.recent_combo.addItem(u"Browse documentation data sets…")

        self.browse_button = QPushButton(u"…",
                                         icon=icons.dir_open_icon,
                                         toolTip="Browse filesystem",
                                         clicked=self.browse)

        self.reload_button = QPushButton("Reload",
                                         icon=icons.reload_icon,
                                         toolTip="Reload the selected file",
                                         clicked=self.reload,
                                         default=True)

        layout.addWidget(self.recent_combo, 2)
        layout.addWidget(self.browse_button)
        layout.addWidget(self.reload_button)

        ###########
        # Info text
        ###########
        box = OWGUI.widgetBox(self.controlArea, "Info", addSpace=True)
        self.infoa = OWGUI.widgetLabel(box, "No data loaded.")
        self.infob = OWGUI.widgetLabel(box, " ")
        self.warnings = OWGUI.widgetLabel(box, " ")

        # Set word wrap so long warnings won't expand the widget
        self.warnings.setWordWrap(True)
        self.warnings.setSizePolicy(QSizePolicy.Ignored,
                                    QSizePolicy.MinimumExpanding)

        advanced = QGroupBox("Advanced Settings",
                             checkable=True,
                             checked=self.show_advanced)
        advanced.setLayout(QVBoxLayout())

        def set_group_visible(groupbox, state):
            layout = groupbox.layout()
            for i in range(layout.count()):
                item = layout.itemAt(i)
                widget = item.widget()
                if widget is not None:
                    widget.setVisible(state)
            groupbox.setFlat(not state)

        def toogle_advanced(state):
            self.show_advanced = state
            set_group_visible(advanced, state)
            self.layout().activate()
            QApplication.instance().processEvents()
            QTimer.singleShot(0, self.adjustSize)

        advanced.toggled.connect(toogle_advanced)

        self.taboptions = QWidget()
        self.taboptions.setLayout(QVBoxLayout())
        box = QGroupBox("Missing Value Symbols", flat=True)
        form = QFormLayout(fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow)
        form.addRow(
            "Don't care:",
            OWGUI.lineEdit(None,
                           self,
                           "symbol_DC",
                           tooltip="Default values: '~' or '*'"))
        form.addRow(
            "Don't know:",
            OWGUI.lineEdit(None,
                           self,
                           "symbol_DK",
                           tooltip="Default values: empty fields (space), "
                           "'?' or 'NA'"))
        box.setLayout(form)
        advanced.layout().addWidget(box)

        rb = OWGUI.radioButtonsInBox(
            advanced,
            self,
            "create_new_on",
            box="New Attributes",
            callback=self._invalidate,
            label=u"Create a new attribute when existing attribute(s) …",
            btnLabels=[
                u"Have mismatching order of values",
                u"Have no common values with the new (recommended)",
                u"Miss some values of the new attribute",
                u"… Always create a new attribute"
            ])
        rb.setFlat(True)
        self.controlArea.layout().addWidget(advanced)

        button_box = QDialogButtonBox(orientation=Qt.Horizontal)
        self.import_options_button = QPushButton(u"Import Options…",
                                                 enabled=False)
        self.import_options_button.pressed.connect(
            self._activate_import_dialog)
        button_box.addButton(self.import_options_button,
                             QDialogButtonBox.ActionRole)
        button_box.addButton(
            QPushButton("&Report", pressed=self.reportAndFinish),
            QDialogButtonBox.ActionRole)
        self.controlArea.layout().addWidget(button_box)

        OWGUI.rubber(self.controlArea)

        set_group_visible(advanced, self.show_advanced)

        if self.recent_files and self.recent_files[0] == self.selected_file:
            QTimer.singleShot(0, lambda: self.activate_recent(0))
        else:
            self.selected_file = None
            self.recent_combo.setCurrentIndex(-1)
Ejemplo n.º 51
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.º 52
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, "File", wantMainArea=0)

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

        self.recentFiles = []
        self.symbolDC = "?"
        self.symbolDK = "~"
        self.createNewOn = 1
        self.domain = None
        self.loadedFile = ""
        self.showAdvanced = 0
        self.loadSettings()

        self.dataReport = None

        box = OWGUI.widgetBox(self.controlArea,
                              "Data File",
                              addSpace=True,
                              orientation="horizontal")
        self.filecombo = QComboBox(box)
        self.filecombo.setMinimumWidth(150)
        self.filecombo.activated[int].connect(self.selectFile)

        box.layout().addWidget(self.filecombo)
        button = OWGUI.button(box, self, '...', callback=self.browse)
        button.setIcon(self.style().standardIcon(QStyle.SP_DirOpenIcon))
        button.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed)

        self.reloadBtn = OWGUI.button(box,
                                      self,
                                      "Reload",
                                      callback=self.reload,
                                      default=True)

        self.reloadBtn.setIcon(self.style().standardIcon(
            QStyle.SP_BrowserReload))
        self.reloadBtn.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)

        box = OWGUI.widgetBox(self.controlArea, "Info", addSpace=True)
        self.infoa = OWGUI.widgetLabel(box, 'No data loaded.')
        self.infob = OWGUI.widgetLabel(box, ' ')
        self.warnings = OWGUI.widgetLabel(box, ' ')

        #Set word wrap so long warnings won't expand the widget
        self.warnings.setWordWrap(True)
        self.warnings.setSizePolicy(QSizePolicy.Ignored,
                                    QSizePolicy.MinimumExpanding)

        smallWidget = OWGUI.collapsableWidgetBox(self.controlArea,
                                                 "Advanced settings",
                                                 self,
                                                 "showAdvanced",
                                                 callback=self.adjustSize0)

        box = QGroupBox("Missing Value Symbols")
        form = QFormLayout(fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow)

        form.addRow(
            "Don't care:",
            OWGUI.lineEdit(None,
                           self,
                           "symbolDC",
                           tooltip="Default values: '~' or '*'"))
        form.addRow(
            "Don't know:",
            OWGUI.lineEdit(None,
                           self,
                           "symbolDK",
                           tooltip="Default values: empty fields (space), "
                           "'?' or 'NA'"))
        box.setLayout(form)
        smallWidget.layout().addWidget(box)
        smallWidget.layout().addSpacing(8)

        OWGUI.radioButtonsInBox(
            smallWidget,
            self,
            "createNewOn",
            box="New Attributes",
            label="Create a new attribute when existing attribute(s) ...",
            btnLabels=[
                "Have mismatching order of values",
                "Have no common values with the new (recommended)",
                "Miss some values of the new attribute",
                "... Always create a new attribute"
            ])

        OWGUI.rubber(smallWidget)
        smallWidget.updateControls()

        OWGUI.rubber(self.controlArea)

        # remove missing data set names
        def exists(path):
            if not os.path.exists(path):
                dirpath, basename = os.path.split(path)
                return os.path.exists(os.path.join("./", basename))
            else:
                return True

        self.recentFiles = filter(exists, self.recentFiles)
        self.setFileList()

        if len(self.recentFiles) > 0 and exists(self.recentFiles[0]):
            self.openFile(self.recentFiles[0])
Ejemplo n.º 53
0
    def __init__(self, parent=None, signalManager=None, name="SVM"):
        OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0, resizingEnabled = 0)
        
        self.inputs = [("Data", ExampleTable, self.setData),
                       ("Preprocess", PreprocessedLearner, self.setPreprocessor)]
        self.outputs = [("Learner", orange.Learner, Default),
                        ("Classifier", orange.Classifier, Default),
                        ("Support Vectors", ExampleTable)]

        self.kernel_type = 2
        self.gamma = 0.0
        self.coef0 = 0.0
        self.degree = 3
        self.C = 1.0
        self.p = 0.1
        self.eps = 1e-3
        self.nu = 0.5
        self.shrinking = 1
        self.probability=1
        self.useNu=0
        self.nomogram=0
        self.normalization=1
        self.data = None
        self.selFlag=False
        self.preprocessor = None
        self.name="SVM"

        OWGUI.lineEdit(self.controlArea, self, 'name', 
                       box='Learner/Classifier Name', 
                       tooltip='Name to be used by other widgets to identify your learner/classifier.')
        OWGUI.separator(self.controlArea)

        b = OWGUI.radioButtonsInBox(self.controlArea, self, "useNu", [], 
                                    box="SVM Type", 
                                    orientation = QGridLayout(), 
                                    addSpace=True)
        
        b.layout().addWidget(OWGUI.appendRadioButton(b, self, "useNu", "C-SVM",
                                                     addToLayout=False),
                             0, 0, Qt.AlignLeft)
        
        b.layout().addWidget(QLabel("Cost (C)", b), 0, 1, Qt.AlignRight)
        b.layout().addWidget(OWGUI.doubleSpin(b, self, "C", 0.1, 512.0, 0.1,
                                decimals=2,
                                addToLayout=False,
                                callback=lambda *x: self.setType(0),
                                alignment=Qt.AlignRight,
                                tooltip= "Cost for a mis-classified training instance."),
                             0, 2)
        
        b.layout().addWidget(OWGUI.appendRadioButton(b, self, "useNu", u"ν-SVM",
                                                     addToLayout=False),
                             1, 0, Qt.AlignLeft)

        b.layout().addWidget(QLabel(u"Complexity bound (\u03bd)", b), 1, 1, Qt.AlignRight)
        b.layout().addWidget(OWGUI.doubleSpin(b, self, "nu", 0.05, 1.0, 0.05,
                                tooltip="Lower bound on the ratio of support vectors",
                                addToLayout=False,
                                callback=lambda *x: self.setType(1),
                                alignment=Qt.AlignRight),
                             1, 2)
        
        self.kernelBox=b = OWGUI.widgetBox(self.controlArea, "Kernel")
        self.kernelradio = OWGUI.radioButtonsInBox(b, self, "kernel_type",
                                        btnLabels=[u"Linear,   x∙y",
                                                   u"Polynomial,   (g x∙y + c)^d",
                                                   u"RBF,   exp(-g|x-y|²)",
                                                   u"Sigmoid,   tanh(g x∙y + c)"],
                                        callback=self.changeKernel)

        OWGUI.separator(b)
        self.gcd = OWGUI.widgetBox(b, orientation="horizontal")
        self.leg = OWGUI.doubleSpin(self.gcd, self, "gamma",0.0,10.0,0.0001,
                                decimals=5,
                                label="  g: ",
                                orientation="horizontal",
                                callback=self.changeKernel,
                                alignment=Qt.AlignRight)
        
        self.led = OWGUI.doubleSpin(self.gcd, self, "coef0", 0.0,10.0,0.0001,
                                label="  c: ",
                                orientation="horizontal",
                                callback=self.changeKernel,
                                alignment=Qt.AlignRight)
        
        self.lec = OWGUI.doubleSpin(self.gcd, self, "degree", 0.0,10.0,0.5,
                                label="  d: ",
                                orientation="horizontal",
                                callback=self.changeKernel,
                                alignment=Qt.AlignRight)

        OWGUI.separator(self.controlArea)
        
        self.optionsBox=b=OWGUI.widgetBox(self.controlArea, "Options",
                                          addSpace=True)
        
        OWGUI.doubleSpin(b,self, "eps", 0.0005, 1.0, 0.0005,
                         label=u"Numerical tolerance",
                         labelWidth = 180,
                         orientation="horizontal",
                         tooltip="Numerical tolerance of termination criterion.",
                         alignment=Qt.AlignRight)

        self.probBox = OWGUI.checkBox(b,self, "probability",
                                      label="Estimate class probabilities",
                                      tooltip="Create classifiers that support class probability estimation."
                                      )
        
        OWGUI.checkBox(b, self, "normalization",
                       label="Normalize data", 
                       tooltip="Use data normalization")

        self.paramButton=OWGUI.button(self.controlArea, self, "Automatic parameter search",
                                      callback=self.parameterSearch,
                                      tooltip="Automatically searches for parameters that optimize classifier accuracy", 
                                      debuggingEnabled=0)
        
        self.paramButton.setDisabled(True)

        OWGUI.button(self.controlArea, self,"&Apply", 
                     callback=self.applySettings, 
                     default=True)
        
        OWGUI.rubber(self.controlArea)
        
        self.loadSettings()
        self.changeKernel()
        self.searching=False
        self.applySettings()
Ejemplo n.º 54
0
    def defineGUI(self):
        OWGUI.lineEdit(self.controlArea, self, 'name', box='Name', \
                       tooltip='Name to be used by other widgets to identify your classifier.<br>This should be a unique name!')

        # Queue radio buttons
        self.queueBox = OWGUI.radioButtonsInBox(self.controlArea,
                                                self,
                                                "outputSel",
                                                box="Output mode",
                                                btnLabels=self.outputModes,
                                                callback=self.changeOutputMode)

        # Queue radio buttons
        self.queueBox = OWGUI.radioButtonsInBox(self.controlArea,
                                                self,
                                                "queueType",
                                                box="Execution Mode",
                                                btnLabels=self.queueTypes,
                                                callback=None)

        # create table with selectable ML methods
        self.colNames = ["ML method", "Enabled"]
        mainRight = OWGUI.widgetBox(self.controlArea, "ML methods selection")
        mainRight.setSizePolicy(
            QSizePolicy(QSizePolicy.MinimumExpanding,
                        QSizePolicy.MinimumExpanding))

        self.mlTable = OWGUI.table(self.controlArea,
                                   rows=0,
                                   columns=0,
                                   selectionMode=QTableWidget.MultiSelection,
                                   addToLayout=1)
        self.mlTable.verticalHeader().hide()
        self.mlTable.setSelectionMode(QTableWidget.NoSelection)
        self.mlTable.setColumnCount(len(self.colNames))
        self.mlTable.setHorizontalHeaderLabels(self.colNames)

        # Set location of statistics file
        boxFile = OWGUI.widgetBox(self.controlArea,
                                  "Path for saving the results",
                                  addSpace=True,
                                  orientation=0)
        L1 = OWGUI.lineEdit(
            boxFile,
            self,
            "statPath",
            labelWidth=80,
            orientation="horizontal",
            tooltip="Please use full path to results file to be created.")
        L1.setMinimumWidth(200)
        button = OWGUI.button(boxFile,
                              self,
                              '...',
                              callback=self.setStatSaveDir,
                              disabled=0,
                              tooltip="Choose the dir where to save.")
        button.setMaximumWidth(25)

        # Apply the settings and send the model to the output channel
        OWGUI.button(self.controlArea,
                     self,
                     "&Apply settings",
                     callback=self.Apply)

        # Set location of model file
        self.boxFile = OWGUI.widgetBox(self.controlArea,
                                       "Path for saving Model",
                                       addSpace=True,
                                       orientation=0)
        self.L1 = OWGUI.lineEdit(
            self.boxFile,
            self,
            "modelFile",
            labelWidth=80,
            orientation="horizontal",
            tooltip=
            "Once a model is created (connect this widget with a data widget), \nit can be saved by giving a file name here and clicking the save button."
        )
        self.L1.setMinimumWidth(200)
        self.button = OWGUI.button(
            self.boxFile,
            self,
            '...',
            callback=self.setModelSavePath,
            disabled=0,
            tooltip=
            "Choose the dir where to save. After chosen, add a name for the model file!"
        )
        self.button.setMaximumWidth(25)

        # Save the model
        self.saveButton = OWGUI.button(self.controlArea,
                                       self,
                                       "&Save model",
                                       callback=self.saveModel)

        # Statistics show
        statBox = OWGUI.widgetBox(self.mainArea,
                                  "Statistics",
                                  addSpace=True,
                                  orientation=0)
        self.statInfoBox = OWGUI.widgetLabel(statBox, '')

        # Save the model
        OWGUI.button(self.mainArea,
                     self,
                     "&Save statistics",
                     callback=self.saveStat)

        self.fillMLtable()

        self.changeOutputMode()
        self.adjustSize()
Ejemplo n.º 55
0
    def __init__(self,
                 parent=None,
                 signalManager=None,
                 name="Multi Dimensional Scaling"):
        OWWidget.__init__(self, parent, signalManager, name, wantGraph=True)

        self.inputs = [("Distances", orange.SymMatrix, self.cmatrix),
                       ("Data Subset", ExampleTable, self.cselected)]
        self.outputs = [("Data", ExampleTable)]

        self.StressFunc = 3
        self.minStressDelta = 5e-5
        self.maxIterations = 5000
        self.maxImprovment = 10
        self.autoSendSelection = 0
        self.toolbarSelection = 0
        self.selectionOptions = 0
        self.computeStress = 1
        self.ReDraw = 1
        self.NumIter = 1
        self.RefreshMode = 0
        self.applyLSMT = 0

        self.stressFunc = [("Kruskal stress", orngMDS.KruskalStress),
                           ("Sammon stress", orngMDS.SammonStress),
                           ("Signed Sammon stress", orngMDS.SgnSammonStress),
                           ("Signed relative stress", orngMDS.SgnRelStress)]

        self.graph = MDSGraph(self.mainArea)
        self.mainArea.layout().addWidget(self.graph)

        self.loadSettings()

        tabs = OWGUI.tabWidget(self.controlArea)

        mds = OWGUI.createTabPage(tabs, "MDS")
        graph = OWGUI.createTabPage(tabs, "Graph")

        # MDS Tab
        init = OWGUI.widgetBox(mds, "Initialization")
        OWGUI.button(init, self, "Randomize", self.randomize)
        OWGUI.button(init, self, "Jitter", self.jitter)
        OWGUI.button(init, self, "Torgerson", self.torgerson)

        opt = OWGUI.widgetBox(mds, "Optimization")

        self.startButton = OWGUI.button(opt, self, "Optimize", self.testStart)
        OWGUI.button(opt, self, "Single Step", self.smacofStep)
        box = OWGUI.widgetBox(opt, "Stress Function")
        OWGUI.comboBox(box,
                       self,
                       "StressFunc",
                       items=[a[0] for a in self.stressFunc],
                       callback=self.updateStress)

        OWGUI.radioButtonsInBox(
            opt, self, "RefreshMode",
            ["Every step", "Every 10 steps", "Every 100 steps"],
            "Refresh During Optimization")

        self.stopping = OWGUI.widgetBox(opt, "Stopping Conditions")

        OWGUI.hSlider(OWGUI.widgetBox(self.stopping,
                                      "Min. stress change",
                                      flat=True),
                      self,
                      "minStressDelta",
                      minValue=5e-5,
                      maxValue=1e-2,
                      step=5e-5,
                      labelFormat="%.5f",
                      intOnly=0)

        OWGUI.hSlider(OWGUI.widgetBox(self.stopping,
                                      "Max. number of steps",
                                      flat=True),
                      self,
                      "maxIterations",
                      minValue=10,
                      maxValue=5000,
                      step=10,
                      labelFormat="%i")

        # Graph Tab
        OWGUI.hSlider(graph,
                      self,
                      "graph.PointSize",
                      box="Point Size",
                      minValue=1,
                      maxValue=20,
                      callback=self.graph.updateData)

        self.colorCombo = OWGUI.comboBox(graph,
                                         self,
                                         "graph.ColorAttr",
                                         box="Color",
                                         callback=self.graph.updateData)
        self.sizeCombo = OWGUI.comboBox(graph,
                                        self,
                                        "graph.SizeAttr",
                                        box="Size",
                                        callback=self.graph.updateData)
        self.shapeCombo = OWGUI.comboBox(graph,
                                         self,
                                         "graph.ShapeAttr",
                                         box="Shape",
                                         callback=self.graph.updateData)
        self.nameCombo = OWGUI.comboBox(graph,
                                        self,
                                        "graph.NameAttr",
                                        box="Label",
                                        callback=self.graph.updateData)

        box = OWGUI.widgetBox(graph, "Distances & Stress")

        OWGUI.checkBox(box,
                       self,
                       "graph.ShowStress",
                       "Show similar pairs",
                       callback=self.graph.updateLinesRepaint)
        b2 = OWGUI.widgetBox(box)
        OWGUI.widgetLabel(b2, "Proportion of connected pairs")
        OWGUI.separator(b2, height=3)
        OWGUI.hSlider(b2,
                      self,
                      "graph.proportionGraphed",
                      minValue=0,
                      maxValue=20,
                      callback=self.graph.updateLinesRepaint,
                      tooltip=("Proportion of connected pairs (Maximum of "
                               "1000 lines will be drawn"))
        OWGUI.checkBox(box,
                       self,
                       "graph.differentWidths",
                       "Show distance by line width",
                       callback=self.graph.updateLinesRepaint)
        OWGUI.checkBox(box,
                       self,
                       "graph.stressByTransparency",
                       "Show stress by transparency",
                       callback=self.graph.updateData)
        OWGUI.checkBox(box,
                       self,
                       "graph.stressBySize",
                       "Show stress by symbol size",
                       callback=self.updateStressBySize)
        self.updateStressBySize(True)

        OWGUI.checkBox(graph,
                       self,
                       "graph.useAntialiasing",
                       label="Use antialiasing",
                       box="Antialiasing",
                       tooltip="Use antialiasing for beter quality graphics",
                       callback=self.graph.updateData)

        self.zoomToolbar = OWToolbars.ZoomSelectToolbar(
            self, graph, self.graph, self.autoSendSelection)

        self.connect(self.zoomToolbar.buttonSendSelections,
                     SIGNAL("clicked()"), self.sendSelections)
        self.graph.autoSendSelectionCallback = \
            lambda: self.autoSendSelection and self.sendSelections()

        OWGUI.checkBox(graph, self, "autoSendSelection", "Auto send selected")
        OWGUI.radioButtonsInBox(graph,
                                self,
                                "selectionOptions", [
                                    "Don't append", "Append coordinates",
                                    "Append coordinates as meta"
                                ],
                                box="Append coordinates",
                                callback=self.sendIf)

        mds.setSizePolicy(QSizePolicy(QSizePolicy.Maximum,
                                      QSizePolicy.Maximum))
        graph.setSizePolicy(
            QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum))

        self.controlArea.setMinimumWidth(250)

        OWGUI.rubber(mds)
        OWGUI.rubber(graph)

        infoBox = OWGUI.widgetBox(mds, "Info")
        self.infoA = OWGUI.widgetLabel(infoBox, "Avg. stress:")
        self.infoB = OWGUI.widgetLabel(infoBox, "Num. steps")

        self.connect(self.graphButton, SIGNAL("clicked()"),
                     self.graph.saveToFile)

        self.resize(900, 630)

        self.done = True
        self.data = None
        self.selectedInputExamples = []
        self.selectedInput = []
    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