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

        self.method = 0

        self.removeRedundant = self.removeContinuous = self.addNoise = self.classOnly = True
        self.removeClasses = False

        box = OWGUI.widgetBox(self.controlArea, "Redundant values")
        remRedCB = OWGUI.checkBox(box, self, "removeRedundant",
                                  "Remove redundant values")
        iBox = OWGUI.indentedBox(box)
        OWGUI.checkBox(iBox, self, "removeContinuous",
                       "Reduce continuous attributes")
        OWGUI.checkBox(iBox, self, "removeClasses", "Reduce class attribute")
        remRedCB.disables.append(iBox)

        OWGUI.separator(self.controlArea)

        box = OWGUI.widgetBox(self.controlArea, "Noise")
        noiseCB = OWGUI.checkBox(box, self, "addNoise", "Add noise to data")
        classNoiseCB = OWGUI.checkBox(OWGUI.indentedBox(box), self,
                                      "classOnly", "Add noise to class only")
        noiseCB.disables.append(classNoiseCB)

        self.adjustSize()
Ejemplo n.º 2
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, 'PurgeDomain', wantMainArea=False)
        self.settingsList=["removeValues", "removeAttributes", "removeClassAttribute", "removeClasses", "autoSend", "sortValues", "sortClasses"]

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

        self.data = None

        self.preRemoveValues = self.removeValues = 1
        self.removeAttributes = 1
        self.removeClassAttribute = 1
        self.preRemoveClasses = self.removeClasses = 1
        self.autoSend = 1
        self.dataChanged = False

        self.sortValues = self.sortClasses = True

        self.loadSettings()

        self.removedAttrs = self.reducedAttrs = self.resortedAttrs = self.classAttr = "-"

        boxAt = OWGUI.widgetBox(self.controlArea, "Attributes", addSpace=True)
        OWGUI.checkBox(boxAt, self, 'sortValues', 'Sort attribute values', callback = self.optionsChanged)
        rua = OWGUI.checkBox(boxAt, self, "removeAttributes", "Remove attributes with less than two values", callback = self.removeAttributesChanged)

        ruv = OWGUI.checkBox(OWGUI.indentedBox(boxAt, sep=OWGUI.checkButtonOffsetHint(rua)), self, "removeValues", "Remove unused attribute values", callback = self.optionsChanged)
        rua.disables = [ruv]
        rua.makeConsistent()


        boxAt = OWGUI.widgetBox(self.controlArea, "Classes", addSpace=True)
        OWGUI.checkBox(boxAt, self, 'sortClasses', 'Sort classes', callback = self.optionsChanged)
        rua = OWGUI.checkBox(boxAt, self, "removeClassAttribute", "Remove class attribute if there are less than two classes", callback = self.removeClassesChanged)
        ruv = OWGUI.checkBox(OWGUI.indentedBox(boxAt, sep=OWGUI.checkButtonOffsetHint(rua)), self, "removeClasses", "Remove unused class values", callback = self.optionsChanged)
        rua.disables = [ruv]
        rua.makeConsistent()


        box3 = OWGUI.widgetBox(self.controlArea, 'Statistics', addSpace=True)
        OWGUI.label(box3, self, "Removed attributes: %(removedAttrs)s")
        OWGUI.label(box3, self, "Reduced attributes: %(reducedAttrs)s")
        OWGUI.label(box3, self, "Resorted attributes: %(resortedAttrs)s")
        OWGUI.label(box3, self, "Class attribute: %(classAttr)s")
        
        box2 = OWGUI.widgetBox(self.controlArea, "Send")
        btSend = OWGUI.button(box2, self, "Send data", callback = self.process, default=True)
        cbAutoSend = OWGUI.checkBox(box2, self, "autoSend", "Send automatically")

        OWGUI.setStopper(self, btSend, cbAutoSend, "dataChanged", self.process)
        
        OWGUI.rubber(self.controlArea)
Ejemplo n.º 3
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, 'PurgeDomain', wantMainArea=False)
        self.settingsList=["removeValues", "removeAttributes", "removeClassAttribute", "removeClasses", "autoSend", "sortValues", "sortClasses"]

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

        self.data = None

        self.preRemoveValues = self.removeValues = 1
        self.removeAttributes = 1
        self.removeClassAttribute = 1
        self.preRemoveClasses = self.removeClasses = 1
        self.autoSend = 1
        self.dataChanged = False

        self.sortValues = self.sortClasses = True

        self.loadSettings()

        self.removedAttrs = self.reducedAttrs = self.resortedAttrs = self.classAttr = "-"

        boxAt = OWGUI.widgetBox(self.controlArea, "Attributes", addSpace=True)
        OWGUI.checkBox(boxAt, self, 'sortValues', 'Sort attribute values', callback = self.optionsChanged)
        rua = OWGUI.checkBox(boxAt, self, "removeAttributes", "Remove attributes with less than two values", callback = self.removeAttributesChanged)

        ruv = OWGUI.checkBox(OWGUI.indentedBox(boxAt, sep=OWGUI.checkButtonOffsetHint(rua)), self, "removeValues", "Remove unused attribute values", callback = self.optionsChanged)
        rua.disables = [ruv]
        rua.makeConsistent()


        boxAt = OWGUI.widgetBox(self.controlArea, "Classes", addSpace=True)
        OWGUI.checkBox(boxAt, self, 'sortClasses', 'Sort classes', callback = self.optionsChanged)
        rua = OWGUI.checkBox(boxAt, self, "removeClassAttribute", "Remove class attribute if there are less than two classes", callback = self.removeClassesChanged)
        ruv = OWGUI.checkBox(OWGUI.indentedBox(boxAt, sep=OWGUI.checkButtonOffsetHint(rua)), self, "removeClasses", "Remove unused class values", callback = self.optionsChanged)
        rua.disables = [ruv]
        rua.makeConsistent()


        box3 = OWGUI.widgetBox(self.controlArea, 'Statistics', addSpace=True)
        OWGUI.label(box3, self, "Removed attributes: %(removedAttrs)s")
        OWGUI.label(box3, self, "Reduced attributes: %(reducedAttrs)s")
        OWGUI.label(box3, self, "Resorted attributes: %(resortedAttrs)s")
        OWGUI.label(box3, self, "Class attribute: %(classAttr)s")
        
        box2 = OWGUI.widgetBox(self.controlArea, "Send")
        btSend = OWGUI.button(box2, self, "Send data", callback = self.process, default=True)
        cbAutoSend = OWGUI.checkBox(box2, self, "autoSend", "Send automatically")

        OWGUI.setStopper(self, btSend, cbAutoSend, "dataChanged", self.process)
        
        OWGUI.rubber(self.controlArea)
Ejemplo n.º 4
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.º 5
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.º 6
0
    def __init__(self,parent=None, signalManager = None, name = "Impute"):
        OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0)

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

        self.attrIcons = self.createAttributeIconDict()

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

        self.model = self.data = None

        self.indiValue = ""
        self.indiValCom = 0

        self.loadSettings()

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

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

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

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

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

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

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

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

        self.individualSelected(self.selectedAttr)
        self.btApply.setDisabled(self.autosend)
        self.setBtAllToDefault()
        self.resize(200,200)
Ejemplo n.º 7
0
    def __init__(self, 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.º 8
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.º 9
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()
    def __init__ (self, parent=None, signalManager = None, name = "Logistic regression"):
        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), ("Classifier", orange.Classifier), ("Features", list)]

        from orngTree import TreeLearner
        imputeByModel = orange.ImputerConstructor_model()
        imputeByModel.learnerDiscrete = TreeLearner(measure = "infoGain", minSubset = 50)
        imputeByModel.learnerContinuous = TreeLearner(measure = "retis", minSubset = 50)
        self.imputationMethods = [imputeByModel, orange.ImputerConstructor_average(), orange.ImputerConstructor_minimal(), orange.ImputerConstructor_maximal(), None]
        self.imputationMethodsStr = ["Classification/Regression trees", "Average values", "Minimal value", "Maximal value", "None (skip examples)"]

        self.name = "Logistic regression"
        self.univariate = 0
        self.stepwiseLR = 0
        self.addCrit = 10
        self.removeCrit = 10
        self.numAttr = 10
        self.limitNumAttr = False
        self.zeroPoint = 0
        self.imputation = 1

        self.data = None
        self.preprocessor = None

        self.loadSettings()

        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)

        box = OWGUI.widgetBox(self.controlArea, "Attribute selection")

        stepwiseCb = OWGUI.checkBox(box, self, "stepwiseLR", "Stepwise attribute selection")
        ibox = OWGUI.indentedBox(box, sep=OWGUI.checkButtonOffsetHint(stepwiseCb))
        addCritSpin = OWGUI.spin(ibox, self, "addCrit", 1, 50, label="Add threshold [%]", labelWidth=155, tooltip="Requested significance for adding an attribute")
        remCritSpin = OWGUI.spin(ibox, self, "removeCrit", 1, 50, label="Remove threshold [%]", labelWidth=155, tooltip="Requested significance for removing an attribute")
        limitAttSpin = OWGUI.checkWithSpin(ibox, self, "Limit number of attributes to ", 1, 100, "limitNumAttr", "numAttr", step=1, labelWidth=155, tooltip="Maximum number of attributes. Algorithm stops when it selects specified number of attributes.")
        stepwiseCb.disables += [addCritSpin, remCritSpin, limitAttSpin]
        stepwiseCb.makeConsistent()
        
        OWGUI.separator(self.controlArea)

        self.imputationCombo = OWGUI.comboBox(self.controlArea, self, "imputation", box="Imputation of unknown values", items=self.imputationMethodsStr)
        OWGUI.separator(self.controlArea)

        applyButton = OWGUI.button(self.controlArea, self, "&Apply", callback=self.applyLearner, default=True)

        OWGUI.rubber(self.controlArea)
        #self.adjustSize()

        self.applyLearner()
Ejemplo n.º 11
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.º 12
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.º 13
0
    def __init__(self,parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "Itemsets explorer")

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

        self.showWholeItemsets = 1
        self.treeDepth = 2
        self.autoSend = True
        self.dataChanged = False
        self.purgeAttributes = True
        self.purgeClasses = True

        self.nItemsets = self.nSelectedItemsets = self.nSelectedExamples = ""
        self.loadSettings()

        self.treeItemsets = QTreeWidget(self.mainArea)
        self.mainArea.layout().addWidget(self.treeItemsets)
        self.treeItemsets.setSelectionMode (QTreeWidget.ExtendedSelection)
        self.treeItemsets.setHeaderLabels(["Itemsets", "Examples"])
        self.treeItemsets.setAllColumnsShowFocus ( 1)
        self.treeItemsets.setAlternatingRowColors(1) 
        self.treeItemsets.setColumnCount(2) 
        self.connect(self.treeItemsets,SIGNAL("itemSelectionChanged()"),self. selectionChanged)

        box = OWGUI.widgetBox(self.controlArea, "Info", addSpace = True)
        OWGUI.label(box, self, "Number of itemsets: %(nItemsets)s")
        OWGUI.label(box, self, "Selected itemsets: %(nSelectedItemsets)s")
        OWGUI.label(box, self, "Selected examples: %(nSelectedExamples)s")

        box = OWGUI.widgetBox(self.controlArea, "Tree", addSpace = True)
        OWGUI.spin(box, self, "treeDepth", label = "Tree depth", min = 1, max = 10, step = 1, callback = self.populateTree, callbackOnReturn = True)
        OWGUI.checkBox(box, self, "showWholeItemsets", "Display whole itemsets", callback = self.setWholeItemsets)
        OWGUI.button(box, self, "Expand All", callback = lambda: self.treeItemsets.expandAll())
        OWGUI.button(box, self, "Collapse", callback = lambda: self.treeItemsets.collapseAll())

        OWGUI.rubber(self.controlArea)

        boxSettings = OWGUI.widgetBox(self.controlArea, 'Send selection')
        OWGUI.checkBox(boxSettings, self, "purgeAttributes", "Purge attribute values/attributes", box=None, callback=self.purgeChanged)
        self.purgeClassesCB = OWGUI.checkBox(OWGUI.indentedBox(boxSettings), self, "purgeClasses", "Purge class attribute", callback=self.purgeChanged)
        if not self.purgeAttributes:
            self.purgeClassesCB.setEnabled(False)
            self.oldPurgeClasses = False

        cbSendAuto = OWGUI.checkBox(boxSettings, self, "autoSend", "Send immediately", box=None)
        btnUpdate = OWGUI.button(boxSettings, self, "Send", self.sendData, default=True)
        OWGUI.setStopper(self, btnUpdate, cbSendAuto, "dataChanged", self.sendData)

        self.itemsets= None
    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.º 15
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.º 16
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.º 17
0
    def __init__(self, parent=None):
        OWWidget.__init__(self, parent, title='Listbox')

        self.method = 0

        self.removeRedundant = self.removeContinuous = self.addNoise = self.classOnly = True
        self.removeClasses = False

        box = OWGUI.widgetBox(self.controlArea, "Redundant values")
        remRedCB = OWGUI.checkBox(box, self, "removeRedundant", "Remove redundant values")
        iBox = OWGUI.indentedBox(box)
        OWGUI.checkBox(iBox, self, "removeContinuous", "Reduce continuous attributes")
        OWGUI.checkBox(iBox, self, "removeClasses", "Reduce class attribute")
        remRedCB.disables.append(iBox)

        OWGUI.separator(self.controlArea)

        box = OWGUI.widgetBox(self.controlArea, "Noise")        
        noiseCB = OWGUI.checkBox(box, self, "addNoise", "Add noise to data")
        classNoiseCB = OWGUI.checkBox(OWGUI.indentedBox(box), self, "classOnly", "Add noise to class only")
        noiseCB.disables.append(classNoiseCB)

        self.adjustSize()
    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.º 19
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)
Ejemplo n.º 20
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)
    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.º 22
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.º 23
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.º 24
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.º 25
0
    def __init__(self, parent=None, signalManager=None, name="SOM visualizer"):
        OWWidget.__init__(self, parent, signalManager, name)
        self.inputs = [("SOMMap", orngSOM.SOMMap, self.setSomMap),
                       ("Examples", ExampleTable, self.data)]
        self.outputs = [("Examples", ExampleTable)]

        self.labelNodes = 0
        self.commitOnChange = 0
        self.backgroundCheck = 1
        self.backgroundMode = 0
        self.histogram = 1
        self.attribute = 0
        self.discHistMode = 0
        self.targetValue = 0
        self.contHistMode = 0
        self.inputSet = 0

        self.somMap = None
        self.examples = None
        self.selectionChanged = False

        ##        layout = QVBoxLayout(self.mainArea) #,QVBoxLayout.TopToBottom,0)
        self.scene = SOMScene(self, self)
        self.sceneView = QGraphicsView(self.scene, self.mainArea)
        self.sceneView.viewport().setMouseTracking(True)

        self.mainArea.layout().addWidget(self.sceneView)

        self.loadSettings()
        call = lambda: self.scene.redrawSom()

        histTab = mainTab = self.controlArea

        self.mainTab = mainTab
        self.histTab = histTab

        self.backgroundBox = OWGUI.widgetBox(mainTab, "Background")
        #OWGUI.checkBox(self.backgroundBox, self, "backgroundCheck","Show background", callback=self.setBackground)
        b = OWGUI.radioButtonsInBox(self.backgroundBox,
                                    self,
                                    "scene.drawMode",
                                    self.drawModes,
                                    callback=self.setBackground)
        b.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed))
        self.componentCombo = OWGUI.comboBox(OWGUI.indentedBox(b),
                                             self,
                                             "scene.component",
                                             callback=self.setBackground)
        self.componentCombo.setEnabled(self.scene.drawMode == 2)
        OWGUI.checkBox(self.backgroundBox,
                       self,
                       "scene.showGrid",
                       "Show grid",
                       callback=self.scene.updateGrid)
        #b=OWGUI.widgetBox(mainTab, "Histogram")
        #OWGUI.separator(mainTab)

        b = OWGUI.widgetBox(mainTab,
                            "Histogram")  ##QVButtonGroup("Histogram", mainTab)
        #        b.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed))
        OWGUI.checkBox(b,
                       self,
                       "histogram",
                       "Show histogram",
                       callback=self.setHistogram)
        OWGUI.radioButtonsInBox(OWGUI.indentedBox(b),
                                self,
                                "inputSet",
                                ["Use training set", "Use input subset"],
                                callback=self.setHistogram)
        #OWGUI.separator(mainTab)

        b1 = OWGUI.widgetBox(mainTab)  ##QVBox(mainTab)
        #        b1.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed))
        b = OWGUI.hSlider(b1,
                          self,
                          "scene.objSize",
                          "Plot size",
                          10,
                          100,
                          step=10,
                          ticks=10,
                          callback=call)
        #        b.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed))
        #OWGUI.checkBox(b1, self, "labelNodes", "Node Labeling", callback=self.canvas.updateLabels)
        #OWGUI.separator(b1)

        b1 = OWGUI.widgetBox(b1, "Tooltip Info")
        OWGUI.checkBox(b1,
                       self,
                       "scene.showToolTip",
                       "Show tooltip",
                       callback=self.scene.updateToolTips)
        OWGUI.checkBox(b1,
                       self,
                       "scene.includeCodebook",
                       "Include codebook vector",
                       callback=self.scene.updateToolTips)
        b1.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed))
        #OWGUI.separator(mainTab)

        self.histogramBox = OWGUI.widgetBox(histTab, "Coloring")
        self.attributeCombo = OWGUI.comboBox(self.histogramBox,
                                             self,
                                             "attribute",
                                             callback=self.setHistogram)

        self.discTab = OWGUI.radioButtonsInBox(
            OWGUI.indentedBox(self.histogramBox),
            self,
            "discHistMode",
            ["Pie chart", "Majority value", "Majority value prob."],
            box=1,
            callback=self.setHistogram)
        self.discTab.setSizePolicy(
            QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed))
        #self.targetValueCombo=OWGUI.comboBox(b, self, "targetValue", callback=self.setHistogram)
        ##        QVBox(discTab)
        ##        b=QVButtonGroup(contTab)
        ##        b.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed))
        self.contTab = OWGUI.radioButtonsInBox(
            OWGUI.indentedBox(self.histogramBox),
            self,
            "contHistMode", ["Default", "Average value"],
            box=1,
            callback=self.setHistogram)
        self.contTab.setSizePolicy(
            QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed))
        ##        QVBox(contTab)

        ##        OWGUI.rubber(mainTab)

        b = OWGUI.widgetBox(self.controlArea, "Selection")
        OWGUI.button(b,
                     self,
                     "&Invert selection",
                     callback=self.scene.invertSelection)
        button = OWGUI.button(b, self, "&Commit", callback=self.commit)
        check = OWGUI.checkBox(b, self, "commitOnChange", "Commit on change")
        OWGUI.setStopper(self, button, check, "selectionChanged", self.commit)

        OWGUI.separator(self.controlArea)
        OWGUI.button(self.controlArea,
                     self,
                     "&Save Graph",
                     callback=self.saveGraph,
                     debuggingEnabled=0)

        self.selectionList = []
        self.ctrlPressed = False
        ##        self.setFocusPolicy(QWidget.StrongFocus)
        self.resize(800, 500)
    def __init__(self, parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "Predictions")

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

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

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

        # GUI - Options

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

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

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

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

        OWGUI.separator(self.controlArea)

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

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

        self.outbox.setDisabled(1)

        ## GUI table

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

        self.inputs = [
            ("Graph with Data", orange.Graph, self.setGraph),
            ("Data Subset", orange.ExampleTable, self.setExampleSubset),
        ]
        self.outputs = [("Selected Data", ExampleTable), ("Selected Graph", orange.Graph)]

        self.markerAttributes = []
        self.tooltipAttributes = []
        self.attributes = []
        self.autoSendSelection = False
        self.graphShowGrid = 1  # show gridlines in the graph

        self.markNConnections = 2
        self.markNumber = 0
        self.markProportion = 0
        self.markSearchString = ""
        self.markDistance = 2
        self.frSteps = 1
        self.hubs = 0
        self.color = 0
        self.nVertices = (
            self.nMarked
        ) = (
            self.nSelected
        ) = self.nHidden = self.nShown = self.nEdges = self.verticesPerEdge = self.edgesPerVertex = self.diameter = 0
        self.optimizeWhat = 1
        self.stopOptimization = 0

        self.loadSettings()

        self.visualize = None

        self.graph = OWIntemsetCanvas(self, self.mainArea, "Network")

        # start of content (right) area
        self.box = QVBoxLayout(self.mainArea)
        self.box.addWidget(self.graph)

        self.tabs = QTabWidget(self.controlArea)

        self.displayTab = QVGroupBox(self)
        self.mainTab = self.displayTab
        self.markTab = QVGroupBox(self)
        self.infoTab = QVGroupBox(self)
        self.protoTab = QVGroupBox(self)

        self.tabs.insertTab(self.displayTab, "Display")
        self.tabs.insertTab(self.markTab, "Mark")
        self.tabs.insertTab(self.infoTab, "Info")
        self.tabs.insertTab(self.protoTab, "Prototypes")
        OWGUI.separator(self.controlArea)

        self.optimizeBox = OWGUI.radioButtonsInBox(self.mainTab, self, "optimizeWhat", [], "Optimize", addSpace=False)
        OWGUI.button(self.optimizeBox, self, "Random", callback=self.random)
        self.frButton = OWGUI.button(self.optimizeBox, self, "Fruchterman Reingold", callback=self.fr, toggleButton=1)
        OWGUI.spin(self.optimizeBox, self, "frSteps", 1, 10000, 1, label="Iterations: ")
        OWGUI.button(self.optimizeBox, self, "F-R Radial", callback=self.frRadial)
        OWGUI.button(self.optimizeBox, self, "Circular Original", callback=self.circularOriginal)
        OWGUI.button(self.optimizeBox, self, "Circular Crossing Reduction", callback=self.circularCrossingReduction)

        self.showLabels = 0
        OWGUI.checkBox(self.mainTab, self, "showLabels", "Show labels", callback=self.showLabelsClick)

        self.labelsOnMarkedOnly = 0
        OWGUI.checkBox(
            self.mainTab, self, "labelsOnMarkedOnly", "Show labels on marked nodes only", callback=self.labelsOnMarked
        )

        OWGUI.separator(self.mainTab)

        OWGUI.button(self.mainTab, self, "Show degree distribution", callback=self.showDegreeDistribution)
        OWGUI.button(self.mainTab, self, "Save network", callback=self.saveNetwork)

        ib = OWGUI.widgetBox(self.markTab, "Info", addSpace=True)
        OWGUI.label(ib, self, "Vertices (shown/hidden): %(nVertices)i (%(nShown)i/%(nHidden)i)")
        OWGUI.label(ib, self, "Selected and marked vertices: %(nSelected)i - %(nMarked)i")

        ribg = OWGUI.radioButtonsInBox(self.markTab, self, "hubs", [], "Method", callback=self.setHubs, addSpace=True)
        OWGUI.appendRadioButton(ribg, self, "hubs", "Mark vertices given in the input signal")

        OWGUI.appendRadioButton(ribg, self, "hubs", "Find vertices which label contain")
        self.ctrlMarkSearchString = OWGUI.lineEdit(
            OWGUI.indentedBox(ribg), self, "markSearchString", callback=self.setSearchStringTimer, callbackOnType=True
        )
        self.searchStringTimer = QTimer(self)
        self.connect(self.searchStringTimer, SIGNAL("timeout()"), self.setHubs)

        OWGUI.appendRadioButton(ribg, self, "hubs", "Mark neighbours of focused vertex")
        OWGUI.appendRadioButton(ribg, self, "hubs", "Mark neighbours of selected vertices")
        ib = OWGUI.indentedBox(ribg, orientation=0)
        self.ctrlMarkDistance = OWGUI.spin(
            ib, self, "markDistance", 0, 100, 1, label="Distance ", callback=(lambda h=2: self.setHubs(h))
        )

        self.ctrlMarkFreeze = OWGUI.button(ib, self, "&Freeze", value="graph.freezeNeighbours", toggleButton=True)

        OWGUI.widgetLabel(ribg, "Mark  vertices with ...")
        OWGUI.appendRadioButton(ribg, self, "hubs", "at least N connections")
        OWGUI.appendRadioButton(ribg, self, "hubs", "at most N connections")
        self.ctrlMarkNConnections = OWGUI.spin(
            OWGUI.indentedBox(ribg),
            self,
            "markNConnections",
            0,
            1000000,
            1,
            label="N ",
            callback=(lambda h=4: self.setHubs(h)),
        )

        OWGUI.appendRadioButton(ribg, self, "hubs", "more connections than any neighbour")
        OWGUI.appendRadioButton(ribg, self, "hubs", "more connections than avg neighbour")

        OWGUI.appendRadioButton(ribg, self, "hubs", "most connections")
        ib = OWGUI.indentedBox(ribg)
        self.ctrlMarkNumber = OWGUI.spin(
            ib,
            self,
            "markNumber",
            0,
            1000000,
            1,
            label="Number of vertices" + ": ",
            callback=(lambda h=8: self.setHubs(h)),
        )
        OWGUI.widgetLabel(ib, "(More vertices are marked in case of ties)")

        ib = QHGroupBox("Selection", self.markTab)
        btnM2S = OWGUI.button(ib, self, "", callback=self.markedToSelection)
        btnM2S.setPixmap(QPixmap(dlg_mark2sel))
        QToolTip.add(btnM2S, "Add Marked to Selection")
        btnS2M = OWGUI.button(ib, self, "", callback=self.markedFromSelection)
        btnS2M.setPixmap(QPixmap(dlg_sel2mark))
        QToolTip.add(btnS2M, "Remove Marked from Selection")
        btnSIM = OWGUI.button(ib, self, "", callback=self.setSelectionToMarked)
        btnSIM.setPixmap(QPixmap(dlg_selIsmark))
        QToolTip.add(btnSIM, "Set Selection to Marked")

        self.hideBox = QHGroupBox("Hide vertices", self.markTab)
        btnSEL = OWGUI.button(self.hideBox, self, "", callback=self.hideSelected)
        btnSEL.setPixmap(QPixmap(dlg_selected))
        QToolTip.add(btnSEL, "Selected")
        btnUN = OWGUI.button(self.hideBox, self, "", callback=self.hideAllButSelected)
        btnUN.setPixmap(QPixmap(dlg_unselected))
        QToolTip.add(btnUN, "Unselected")
        OWGUI.button(self.hideBox, self, "Show", callback=self.showAllNodes)

        T = OWToolbars.NavigateSelectToolbar
        self.zoomSelectToolbar = OWToolbars.NavigateSelectToolbar(
            self,
            self.controlArea,
            self.graph,
            self.autoSendSelection,
            buttons=(
                T.IconZoom,
                T.IconZoomExtent,
                T.IconZoomSelection,
                ("", "", "", None, None, 0, "navigate"),
                T.IconPan,
                (
                    "Move selection",
                    "buttonMoveSelection",
                    "activateMoveSelection",
                    QPixmap(OWToolbars.dlg_select),
                    Qt.arrowCursor,
                    1,
                    "select",
                ),
                T.IconRectangle,
                T.IconPolygon,
                ("", "", "", None, None, 0, "select"),
                T.IconSendSelection,
            ),
        )

        ib = OWGUI.widgetBox(self.infoTab, "General", addSpace=True)
        OWGUI.label(ib, self, "Number of vertices: %(nVertices)i")
        OWGUI.label(ib, self, "Number of edges: %(nEdges)i")
        OWGUI.label(ib, self, "Vertices per edge: %(verticesPerEdge).2f")
        OWGUI.label(ib, self, "Edges per vertex: %(edgesPerVertex).2f")
        OWGUI.label(ib, self, "Diameter: %(diameter)i")

        self.insideView = 0
        self.insideViewNeighbours = 2
        self.insideSpin = OWGUI.spin(
            self.protoTab,
            self,
            "insideViewNeighbours",
            1,
            6,
            1,
            label="Inside view (neighbours): ",
            checked="insideView",
            checkCallback=self.insideview,
            callback=self.insideviewneighbours,
        )
        # OWGUI.button(self.protoTab, self, "Clustering", callback=self.clustering)
        OWGUI.button(self.protoTab, self, "Collapse", callback=self._collapse)

        self.icons = self.createAttributeIconDict()
        self.setHubs()

        self.resize(850, 700)
Ejemplo n.º 29
0
    def __init__(self, parent=None, signalManager = None, name='TreeViewer2D'):
        OWWidget.__init__(self, parent, signalManager, name, wantGraph=True)
        self.root = None
        self.selectedNode = None

        self.inputs = [("Classification Tree", orange.TreeClassifier, self.ctree)]
        self.outputs = [("Examples", ExampleTable)]

        #set default settings
        self.ZoomAutoRefresh = 0
        self.AutoArrange = 0
        self.ToolTipsEnabled = 1
        self.MaxTreeDepth = 5; self.MaxTreeDepthB = 0
        self.LineWidth = 5; self.LineWidthMethod = 2
        self.NodeSize = 5
        self.MaxNodeWidth = 150
        self.LimitNodeWidth = True
        self.NodeInfo = [0, 1]

        self.Zoom = 5
        self.VSpacing = 5; self.HSpacing = 5
        self.TruncateText = 1
        
        self.loadSettings()
        self.NodeInfo.sort()

# Changed when the GUI was simplified - added here to override any saved settings
        self.VSpacing = 1; self.HSpacing = 1
        self.ToolTipsEnabled = 1
        self.LineWidth = 15  # Also reset when the LineWidthMethod is changed!
        
        # GUI definition
#        self.tabs = OWGUI.tabWidget(self.controlArea)

        # GENERAL TAB
        # GeneralTab = OWGUI.createTabPage(self.tabs, "General")
#        GeneralTab = TreeTab = OWGUI.createTabPage(self.tabs, "Tree")
#        NodeTab = OWGUI.createTabPage(self.tabs, "Node")

        GeneralTab = NodeTab = TreeTab = self.controlArea
        
        self.infBox = OWGUI.widgetBox(GeneralTab, 'Info', sizePolicy = QSizePolicy(QSizePolicy.Minimum , QSizePolicy.Fixed ), addSpace=True)
        self.infoa = OWGUI.widgetLabel(self.infBox, 'No tree.')
        self.infob = OWGUI.widgetLabel(self.infBox, " ")

        self.sizebox = OWGUI.widgetBox(GeneralTab, "Size", addSpace=True)
        OWGUI.hSlider(self.sizebox, self, 'Zoom', label='Zoom', minValue=1, maxValue=10, step=1,
                      callback=self.toggleZoomSlider, ticks=1)
        OWGUI.separator(self.sizebox)
        
        cb, sb = OWGUI.checkWithSpin(self.sizebox, self, "Max node width:", 50, 200, "LimitNodeWidth", "MaxNodeWidth",
                                     tooltip="Limit the width of tree nodes",
                                     checkCallback=self.toggleNodeSize,
                                     spinCallback=self.toggleNodeSize,
                                     step=10)
        b = OWGUI.checkBox(OWGUI.indentedBox(self.sizebox, sep=OWGUI.checkButtonOffsetHint(cb)), self, "TruncateText", "Truncate text", callback=self.toggleTruncateText)
        cb.disables.append(b)
        cb.makeConsistent() 

        OWGUI.checkWithSpin(self.sizebox, self, 'Max tree depth:', 1, 20, 'MaxTreeDepthB', "MaxTreeDepth",
                            tooltip='Defines the depth of the tree displayed',
                            checkCallback=self.toggleTreeDepth,
                            spinCallback=self.toggleTreeDepth)
        
        
        self.edgebox = OWGUI.widgetBox(GeneralTab, "Edge Widths", addSpace=True)
        OWGUI.comboBox(self.edgebox, self,  'LineWidthMethod',
                                items=['Equal width', 'Root node', 'Parent node'],
                                callback=self.toggleLineWidth)
        # Node information
        grid = QGridLayout()
        grid.setContentsMargins(*self.controlArea.layout().getContentsMargins())
        
        navButton = OWGUI.button(self.controlArea, self, "Navigator", self.toggleNavigator, debuggingEnabled = 0, addToLayout=False)
#        findbox = OWGUI.widgetBox(self.controlArea, orientation = "horizontal")
        self.centerRootButton=OWGUI.button(self.controlArea, self, "Find Root", addToLayout=False,
                                           callback=lambda :self.rootNode and \
                                           self.sceneView.centerOn(self.rootNode.x(), self.rootNode.y()))
        self.centerNodeButton=OWGUI.button(self.controlArea, self, "Find Selected", addToLayout=False,
                                           callback=lambda :self.selectedNode and \
                                           self.sceneView.centerOn(self.selectedNode.scenePos()))
        grid.addWidget(navButton, 0, 0, 1, 2)
        grid.addWidget(self.centerRootButton, 1, 0)
        grid.addWidget(self.centerNodeButton, 1, 1)
        self.leftWidgetPart.layout().insertLayout(1, grid)
        
        self.NodeTab=NodeTab
        self.TreeTab=TreeTab
        self.GeneralTab=GeneralTab
#        OWGUI.rubber(NodeTab)
        self.rootNode=None
        self.tree=None
        self.resize(800, 500)
        
        self.connect(self.graphButton, SIGNAL("clicked()"), self.saveGraph)
    def __init__(self,parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "Association rules viewer")

        self.inputs = [("Association Rules", orange.AssociationRules, self.arules)]
        self.outputs = [("Association Rules", orange.AssociationRules), ("Covered Data", ExampleTable), ("Matching Data", ExampleTable), ("Mismatched Data", ExampleTable)]

        self.showWholeRules = 1
        self.treeDepth = 2
        self.autoSend = True
        self.dataChanged = False
        self.purgeAttributes = True
        self.purgeClasses = True

        self.nRules = self.nSelectedRules = self.nSelectedExamples = self.nMatchingExamples = self.nMismatchingExamples = ""
        
        self.showsupport = self.showconfidence = 1
        self.showlift = self.showleverage = self.showstrength = self.showcoverage = 0
        self.loadSettings()

#        self.grid = QGridLayout()
#        rightUpRight = OWGUI.widgetBox(self.mainArea, box="Shown measures", orientation = self.grid)
#        self.cbMeasures = [OWGUI.checkBox(rightUpRight, self, "show"+attr, long, callback = self.showHideColumn, addToLayout = 0) for long, short, attr in self.measures]
#        for i, cb in enumerate(self.cbMeasures):
#            self.grid.addWidget(cb, i % 2, i / 2)

        box = OWGUI.widgetBox(self.mainArea, orientation = 0)
        OWGUI.widgetLabel(box, "Shown measures: ")
        self.cbMeasures = [OWGUI.checkBox(box, self, "show"+attr, long+"   ", callback = self.showHideColumn) for long, short, attr in self.measures]
        OWGUI.rubber(box)

        self.treeRules = QTreeWidget(self.mainArea)
        self.mainArea.layout().addWidget(self.treeRules)
        self.treeRules.setSelectionMode (QTreeWidget.ExtendedSelection)
        self.treeRules.setHeaderLabels(["Rules"] + [m[1] for m in self.measures])
        self.treeRules.setAllColumnsShowFocus ( 1)
        self.treeRules.setAlternatingRowColors(1) 
        self.showHideColumn()
        self.connect(self.treeRules,SIGNAL("itemSelectionChanged()"),self. selectionChanged)

        box = OWGUI.widgetBox(self.controlArea, "Info", addSpace = True)
        OWGUI.label(box, self, "Number of rules: %(nRules)s")
        OWGUI.label(box, self, "Selected rules: %(nSelectedRules)s")
        OWGUI.label(box, self, "Selected examples: %(nSelectedExamples)s")
        ibox = OWGUI.indentedBox(box)
        OWGUI.label(ibox, self, "... matching: %(nMatchingExamples)s")
        OWGUI.label(ibox, self, "... mismatching: %(nMismatchingExamples)s")

        box = OWGUI.widgetBox(self.controlArea, "Options", addSpace = True)
        OWGUI.spin(box, self, "treeDepth", label = "Tree depth", min = 0, max = 10, step = 1, callback = self.displayRules, callbackOnReturn = True)
        OWGUI.separator(box)
        OWGUI.checkBox(box, self, "showWholeRules", "Display whole rules", callback = self.setWholeRules)

        OWGUI.rubber(self.controlArea)

        boxSettings = OWGUI.widgetBox(self.controlArea, 'Send selection')
        OWGUI.checkBox(boxSettings, self, "purgeAttributes", "Purge attribute values/attributes", box=None, callback=self.purgeChanged)
        self.purgeClassesCB = OWGUI.checkBox(OWGUI.indentedBox(boxSettings), self, "purgeClasses", "Purge class attribute", callback=self.purgeChanged)
        if not self.purgeAttributes:
            self.purgeClassesCB.setEnabled(False)
            self.oldPurgeClasses = False

        cbSendAuto = OWGUI.checkBox(boxSettings, self, "autoSend", "Send immediately", box=None)
        btnUpdate = OWGUI.button(boxSettings, self, "Send", self.sendData, default=True)
        OWGUI.setStopper(self, btnUpdate, cbSendAuto, "dataChanged", self.sendData)
        
        self.rules = None
Ejemplo n.º 31
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
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager,
                          "Association rules viewer")

        self.inputs = [("Association Rules", orange.AssociationRules,
                        self.arules)]
        self.outputs = [("Association Rules", orange.AssociationRules),
                        ("Covered Data", ExampleTable),
                        ("Matching Data", ExampleTable),
                        ("Mismatched Data", ExampleTable)]

        self.showWholeRules = 1
        self.treeDepth = 2
        self.autoSend = True
        self.dataChanged = False
        self.purgeAttributes = True
        self.purgeClasses = True

        self.nRules = self.nSelectedRules = self.nSelectedExamples = self.nMatchingExamples = self.nMismatchingExamples = ""

        self.showsupport = self.showconfidence = 1
        self.showlift = self.showleverage = self.showstrength = self.showcoverage = 0
        self.loadSettings()

        #        self.grid = QGridLayout()
        #        rightUpRight = OWGUI.widgetBox(self.mainArea, box="Shown measures", orientation = self.grid)
        #        self.cbMeasures = [OWGUI.checkBox(rightUpRight, self, "show"+attr, long, callback = self.showHideColumn, addToLayout = 0) for long, short, attr in self.measures]
        #        for i, cb in enumerate(self.cbMeasures):
        #            self.grid.addWidget(cb, i % 2, i / 2)

        box = OWGUI.widgetBox(self.mainArea, orientation=0)
        OWGUI.widgetLabel(box, "Shown measures: ")
        self.cbMeasures = [
            OWGUI.checkBox(box,
                           self,
                           "show" + attr,
                           long + "   ",
                           callback=self.showHideColumn)
            for long, short, attr in self.measures
        ]
        OWGUI.rubber(box)

        self.treeRules = QTreeWidget(self.mainArea)
        self.mainArea.layout().addWidget(self.treeRules)
        self.treeRules.setSelectionMode(QTreeWidget.ExtendedSelection)
        self.treeRules.setHeaderLabels(["Rules"] +
                                       [m[1] for m in self.measures])
        self.treeRules.setAllColumnsShowFocus(1)
        self.treeRules.setAlternatingRowColors(1)
        self.showHideColumn()
        self.connect(self.treeRules, SIGNAL("itemSelectionChanged()"),
                     self.selectionChanged)

        box = OWGUI.widgetBox(self.controlArea, "Info", addSpace=True)
        OWGUI.label(box, self, "Number of rules: %(nRules)s")
        OWGUI.label(box, self, "Selected rules: %(nSelectedRules)s")
        OWGUI.label(box, self, "Selected examples: %(nSelectedExamples)s")
        ibox = OWGUI.indentedBox(box)
        OWGUI.label(ibox, self, "... matching: %(nMatchingExamples)s")
        OWGUI.label(ibox, self, "... mismatching: %(nMismatchingExamples)s")

        box = OWGUI.widgetBox(self.controlArea, "Options", addSpace=True)
        OWGUI.spin(box,
                   self,
                   "treeDepth",
                   label="Tree depth",
                   min=0,
                   max=10,
                   step=1,
                   callback=self.displayRules,
                   callbackOnReturn=True)
        OWGUI.separator(box)
        OWGUI.checkBox(box,
                       self,
                       "showWholeRules",
                       "Display whole rules",
                       callback=self.setWholeRules)

        OWGUI.rubber(self.controlArea)

        boxSettings = OWGUI.widgetBox(self.controlArea, 'Send selection')
        OWGUI.checkBox(boxSettings,
                       self,
                       "purgeAttributes",
                       "Purge attribute values/attributes",
                       box=None,
                       callback=self.purgeChanged)
        self.purgeClassesCB = OWGUI.checkBox(OWGUI.indentedBox(boxSettings),
                                             self,
                                             "purgeClasses",
                                             "Purge class attribute",
                                             callback=self.purgeChanged)
        if not self.purgeAttributes:
            self.purgeClassesCB.setEnabled(False)
            self.oldPurgeClasses = False

        cbSendAuto = OWGUI.checkBox(boxSettings,
                                    self,
                                    "autoSend",
                                    "Send immediately",
                                    box=None)
        btnUpdate = OWGUI.button(boxSettings,
                                 self,
                                 "Send",
                                 self.sendData,
                                 default=True)
        OWGUI.setStopper(self, btnUpdate, cbSendAuto, "dataChanged",
                         self.sendData)

        self.rules = None
Ejemplo n.º 33
0
    def __init__(self,parent=None, signalManager = None, name = "Impute"):
        OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0)

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

        self.attrIcons = self.createAttributeIconDict()

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

        self.model = self.data = None

        self.indiValue = ""
        self.indiValCom = 0

        self.loadSettings()

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

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

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

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

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

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

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

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

        self.individualSelected(self.selectedAttr)
        self.btApply.setDisabled(self.autosend)
        self.setBtAllToDefault()
        self.resize(200,200)
Ejemplo n.º 34
0
    def __init__(self,parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "Mosaic display", True, True)

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

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

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

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

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

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

        self.loadSettings()

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        self.collapsableWBox.updateControls()
        dlg = self.createColorDialog()
        self.colorPalette = dlg.getDiscretePalette("discPalette")
        self.selectionColorPalette = [QColor(*col) for col in OWColorPalette.defaultRGBColors]
Ejemplo n.º 35
0
    def __init__(self, parent=None, signalManager=None, name="Interactive Discretization"):
        OWWidget.__init__(self, parent, signalManager, name)
        self.showBaseLine=1
        self.showLookaheadLine=1
        self.showTargetClassProb=1
        self.showRug=0
        self.snap=1
        self.measure=0
        self.targetClass=0
        self.discretization = self.classDiscretization = self.indiDiscretization = 1
        self.intervals = self.classIntervals = self.indiIntervals = 3
        self.outputOriginalClass = True
        self.indiData = []
        self.indiLabels = []
        self.resetIndividuals = 0
        self.customClassSplits = ""

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

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

        self.data = self.originalData = None

        self.loadSettings()

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

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

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

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

        OWGUI.separator(vbox)

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

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

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

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

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

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

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

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

        self.defaultMethodChanged()

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

        #self.controlArea.setFixedWidth(0)

        self.contAttrIcon =  self.createAttributeIconDict()[orange.VarTypes.Continuous]
        
        self.setAllIndividuals()
Ejemplo n.º 36
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, "SampleData", wantMainArea=0)

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

        # initialization of variables
        self.data = None  # dataset (incoming stream)
        self.indices = None  # indices that control sampling

        self.Stratified = 1  # use stratified sampling if possible?
        self.Repeat = 0  # can elements repeat in a sample?
        self.UseSpecificSeed = 0  # use a specific random seed?
        self.RandomSeed = 1  # specific seed used
        self.GroupSeed = 1  # current seed for multiple group selection
        self.outFold = 1  # folder/group to output
        self.Folds = 1  # total number of folds/groups

        self.SelectType = 0  # sampling type (LOO, CV, ...)
        self.useCases = 0  # use a specific number of cases?
        self.nCases = 25  # number of cases to use
        self.selPercentage = 30  # sample size in %
        self.CVFolds = 10  # number of CV folds
        self.nGroups = 3  # number of groups
        self.pGroups = [0.1, 0.25, 0.5]  # sizes of groups
        self.GroupText = "0.1,0.25,0.5"  # assigned to Groups Control (for internal use)
        self.autocommit = False

        # Invalidated settings flag.
        self.outputInvalidateFlag = False

        self.loadSettings()

        # GUI

        # Info Box
        box1 = OWGUI.widgetBox(self.controlArea, "Information", addSpace=True)
        # Input data set info
        self.infoa = OWGUI.widgetLabel(box1, "No data on input.")
        # Sampling type/parameters info
        self.infob = OWGUI.widgetLabel(box1, " ")
        # Output data set info
        self.infoc = OWGUI.widgetLabel(box1, " ")

        # Options Box
        box2 = OWGUI.widgetBox(self.controlArea, "Options", addSpace=True)
        OWGUI.checkBox(box2, self, "Stratified", "Stratified (if possible)", callback=self.settingsChanged)

        OWGUI.checkWithSpin(
            box2,
            self,
            "Set random seed:",
            0,
            32767,
            "UseSpecificSeed",
            "RandomSeed",
            checkCallback=self.settingsChanged,
            spinCallback=self.settingsChanged,
        )

        # Sampling Type Box
        self.s = [None, None, None, None]
        self.sBox = OWGUI.widgetBox(self.controlArea, "Sampling type", addSpace=True)
        self.sBox.buttons = []

        # Random Sampling
        self.s[0] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", "Random sampling")

        # indent
        indent = OWGUI.checkButtonOffsetHint(self.s[0])
        # repeat checkbox
        self.h1Box = OWGUI.indentedBox(self.sBox, sep=indent, orientation="horizontal")
        OWGUI.checkBox(self.h1Box, self, "Repeat", "With replacement", callback=self.settingsChanged)

        # specified number of elements checkbox
        self.h2Box = OWGUI.indentedBox(self.sBox, sep=indent, orientation="horizontal")
        check, _ = OWGUI.checkWithSpin(
            self.h2Box,
            self,
            "Sample size (instances):",
            1,
            1000000000,
            "useCases",
            "nCases",
            checkCallback=self.settingsChanged,
            spinCallback=self.settingsChanged,
        )

        # percentage slider
        self.h3Box = OWGUI.indentedBox(self.sBox, sep=indent)
        OWGUI.widgetLabel(self.h3Box, "Sample size:")

        self.slidebox = OWGUI.widgetBox(self.h3Box, orientation="horizontal")
        OWGUI.hSlider(
            self.slidebox,
            self,
            "selPercentage",
            minValue=1,
            maxValue=100,
            step=1,
            ticks=10,
            labelFormat="   %d%%",
            callback=self.settingsChanged,
        )

        # Sample size (instances) check disables the Percentage slider.
        # TODO: Should be an exclusive option (radio buttons)
        check.disables.extend([(-1, self.h3Box)])
        check.makeConsistent()

        # Cross Validation sampling options
        self.s[1] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", "Cross validation")

        box = OWGUI.indentedBox(self.sBox, sep=indent, orientation="horizontal")
        OWGUI.spin(box, self, "CVFolds", 2, 100, step=1, label="Number of folds:  ", callback=self.settingsChanged)

        # Leave-One-Out
        self.s[2] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", "Leave-one-out")

        # Multiple Groups
        self.s[3] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", "Multiple subsets")
        gbox = OWGUI.indentedBox(self.sBox, sep=indent, orientation="horizontal")
        OWGUI.lineEdit(
            gbox, self, "GroupText", label='Subset sizes (e.g. "0.1, 0.2, 0.5"):', callback=self.multipleChanged
        )

        # Output Group Box
        box = OWGUI.widgetBox(self.controlArea, "Output Data for Fold / Group", addSpace=True)
        self.foldcombo = OWGUI.comboBox(
            box,
            self,
            "outFold",
            items=range(1, 101),
            label="Fold / group:",
            orientation="horizontal",
            sendSelectedValue=1,
            valueType=int,
            callback=self.invalidate,
        )
        self.foldcombo.setEnabled(self.SelectType != 0)

        # Sample Data box
        OWGUI.rubber(self.controlArea)
        box = OWGUI.widgetBox(self.controlArea, "Sample Data")
        cb = OWGUI.checkBox(box, self, "autocommit", "Sample on any change")
        self.sampleButton = OWGUI.button(box, self, "Sample &Data", callback=self.sdata, default=True)
        OWGUI.setStopper(self, self.sampleButton, cb, "outputInvalidateFlag", callback=self.sdata)

        # set initial radio button on (default sample type)
        self.s[self.SelectType].setChecked(True)

        # Connect radio buttons (SelectType)
        for i, button in enumerate(self.s):
            button.toggled[bool].connect(lambda state, i=i: self.samplingTypeChanged(state, i))

        self.process()

        self.resize(200, 275)
Ejemplo n.º 37
0
    def __init__(self, parent=None, signalManager=None, name='TreeViewer2D'):
        OWWidget.__init__(self, parent, signalManager, name, wantGraph=True)
        self.root = None
        self.selectedNode = None

        self.inputs = [("Classification Tree", orange.TreeClassifier,
                        self.ctree)]
        self.outputs = [("Examples", ExampleTable)]

        #set default settings
        self.ZoomAutoRefresh = 0
        self.AutoArrange = 0
        self.ToolTipsEnabled = 1
        self.MaxTreeDepth = 5
        self.MaxTreeDepthB = 0
        self.LineWidth = 5
        self.LineWidthMethod = 0
        self.NodeSize = 5
        self.MaxNodeWidth = 150
        self.LimitNodeWidth = True
        self.NodeInfo = [0, 1]

        self.NodeColorMethod = 0
        self.Zoom = 5
        self.VSpacing = 5
        self.HSpacing = 5
        self.TruncateText = 1

        self.loadSettings()
        self.NodeInfo.sort()

        # GUI definition
        self.tabs = OWGUI.tabWidget(self.controlArea)

        # GENERAL TAB
        GeneralTab = OWGUI.createTabPage(self.tabs, "General")
        TreeTab = OWGUI.createTabPage(self.tabs, "Tree")
        NodeTab = OWGUI.createTabPage(self.tabs, "Node")

        OWGUI.hSlider(GeneralTab,
                      self,
                      'Zoom',
                      box='Zoom',
                      minValue=1,
                      maxValue=10,
                      step=1,
                      callback=self.toggleZoomSlider,
                      ticks=1)
        OWGUI.hSlider(GeneralTab,
                      self,
                      'VSpacing',
                      box='Vertical spacing',
                      minValue=1,
                      maxValue=10,
                      step=1,
                      callback=self.toggleVSpacing,
                      ticks=1)
        OWGUI.hSlider(GeneralTab,
                      self,
                      'HSpacing',
                      box='Horizontal spacing',
                      minValue=1,
                      maxValue=10,
                      step=1,
                      callback=self.toggleHSpacing,
                      ticks=1)

        OWGUI.checkBox(GeneralTab,
                       self,
                       'ToolTipsEnabled',
                       'Show node tool tips',
                       tooltip='When mouse over the node show tool tip',
                       callback=self.updateNodeToolTips)
        #        OWGUI.checkBox(GeneralTab, self, 'TruncateText', 'Truncate text to fit margins',
        #                       tooltip='Truncate any text to fit the node width',
        #                       callback=self.toggleTruncateText)

        self.infBox = OWGUI.widgetBox(GeneralTab,
                                      'Tree Size',
                                      sizePolicy=QSizePolicy(
                                          QSizePolicy.Minimum,
                                          QSizePolicy.Fixed))
        self.infoa = OWGUI.widgetLabel(self.infBox, 'No tree.')
        self.infob = OWGUI.widgetLabel(self.infBox, " ")

        # TREE TAB
        OWGUI.checkWithSpin(TreeTab,
                            self,
                            'Max tree depth:',
                            1,
                            20,
                            'MaxTreeDepthB',
                            "MaxTreeDepth",
                            tooltip='Defines the depth of the tree displayed',
                            checkCallback=self.toggleTreeDepth,
                            spinCallback=self.toggleTreeDepth)
        OWGUI.spin(
            TreeTab,
            self,
            'LineWidth',
            min=1,
            max=10,
            step=1,
            label='Max line width:',
            tooltip='Defines max width of the edges that connect tree nodes',
            callback=self.toggleLineWidth)
        OWGUI.radioButtonsInBox(
            TreeTab,
            self,
            'LineWidthMethod', ['No dependency', 'Root node', 'Parent node'],
            box='Reference for Line Width',
            tooltips=[
                'All edges are of the same width',
                'Line width is relative to number of cases in root node',
                'Line width is relative to number of cases in parent node'
            ],
            callback=self.toggleLineWidth)

        # NODE TAB
        #        # Node size options

        cb, sb = OWGUI.checkWithSpin(NodeTab,
                                     self,
                                     "Max node width:",
                                     50,
                                     200,
                                     "LimitNodeWidth",
                                     "MaxNodeWidth",
                                     tooltip="Limit the width of tree nodes",
                                     checkCallback=self.toggleNodeSize,
                                     spinCallback=self.toggleNodeSize,
                                     step=10)
        b = OWGUI.checkBox(OWGUI.indentedBox(
            NodeTab, sep=OWGUI.checkButtonOffsetHint(cb)),
                           self,
                           "TruncateText",
                           "Truncate text",
                           callback=self.toggleTruncateText)
        cb.disables.append(b)
        cb.makeConsistent()
        #        w = OWGUI.widgetBox(NodeTab, orientation="horizontal")
        #        cb = OWGUI.checkBox(w, self, "LimitNodeWidth", "Max node width", callback=self.toggleNodeSize)
        #        sl = OWGUI.hSlider(w, self, 'MaxNodeWidth', #box='Max node width',
        #                      minValue=50, maxValue=200, step=10,
        #                      callback=self.toggleNodeSize, ticks=50)
        #        cb.disables.append(sl)
        #        cb.makeConsistent()

        # Node information
        grid = QGridLayout()
        grid.setContentsMargins(
            *self.controlArea.layout().getContentsMargins())

        navButton = OWGUI.button(self.controlArea,
                                 self,
                                 "Navigator",
                                 self.toggleNavigator,
                                 debuggingEnabled=0,
                                 addToLayout=False)
        #        findbox = OWGUI.widgetBox(self.controlArea, orientation = "horizontal")
        self.centerRootButton=OWGUI.button(self.controlArea, self, "Find Root", addToLayout=False,
                                           callback=lambda :self.rootNode and \
                                           self.sceneView.centerOn(self.rootNode.x(), self.rootNode.y()))
        self.centerNodeButton=OWGUI.button(self.controlArea, self, "Find Selected", addToLayout=False,
                                           callback=lambda :self.selectedNode and \
                                           self.sceneView.centerOn(self.selectedNode.scenePos()))
        grid.addWidget(navButton, 0, 0, 1, 2)
        grid.addWidget(self.centerRootButton, 1, 0)
        grid.addWidget(self.centerNodeButton, 1, 1)
        self.leftWidgetPart.layout().insertLayout(1, grid)

        self.NodeTab = NodeTab
        self.TreeTab = TreeTab
        self.GeneralTab = GeneralTab
        OWGUI.rubber(GeneralTab)
        OWGUI.rubber(TreeTab)
        #        OWGUI.rubber(NodeTab)
        self.rootNode = None
        self.tree = None
        self.resize(800, 500)

        self.connect(self.graphButton, SIGNAL("clicked()"), self.saveGraph)
Ejemplo n.º 38
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self,
                          parent,
                          signalManager,
                          'SampleData',
                          wantMainArea=0)

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

        # initialization of variables
        self.data = None  # dataset (incoming stream)
        self.indices = None  # indices that control sampling
        self.ind = None  # indices that control sampling

        self.Stratified = 1  # use stratified sampling if possible?
        self.Repeat = 0  # can elements repeat in a sample?
        self.UseSpecificSeed = 0  # use a specific random seed?
        self.RandomSeed = 1  # specific seed used
        self.GroupSeed = 1  # current seed for multiple group selection
        self.outFold = 1  # folder/group to output
        self.Folds = 1  # total number of folds/groups

        self.SelectType = 0  # sampling type (LOO, CV, ...)
        self.useCases = 0  # use a specific number of cases?
        self.nCases = 25  # number of cases to use
        self.selPercentage = 30  # sample size in %
        self.LOO = 1  # use LOO?
        self.CVFolds = 10  # number of CV folds
        self.CVFoldsInternal = 10  # number of CV folds (for internal use)
        self.nGroups = 3  # number of groups
        self.pGroups = [0.1, 0.25, 0.5]  # sizes of groups
        self.GroupText = '0.1,0.25,0.5'  # assigned to Groups Control (for internal use)

        self.loadSettings()
        # GUI

        # Info Box
        box1 = OWGUI.widgetBox(self.controlArea, "Information", addSpace=True)
        self.infoa = OWGUI.widgetLabel(box1, 'No data on input.')
        self.infob = OWGUI.widgetLabel(box1, ' ')
        self.infoc = OWGUI.widgetLabel(box1, ' ')

        # Options Box
        box2 = OWGUI.widgetBox(self.controlArea, 'Options', addSpace=True)
        OWGUI.checkBox(box2,
                       self,
                       'Stratified',
                       'Stratified (if possible)',
                       callback=self.settingsChanged)
        OWGUI.checkWithSpin(box2,
                            self,
                            'Set random seed:',
                            0,
                            32767,
                            'UseSpecificSeed',
                            'RandomSeed',
                            checkCallback=self.settingsChanged,
                            spinCallback=self.settingsChanged)

        # Sampling Type Box
        self.s = [None, None, None, None]
        self.sBox = OWGUI.widgetBox(self.controlArea,
                                    "Sampling type",
                                    addSpace=True)
        self.sBox.buttons = []

        # Random Sampling
        self.s[0] = OWGUI.appendRadioButton(self.sBox, self, "SelectType",
                                            'Random sampling')

        # indent
        indent = sep = OWGUI.checkButtonOffsetHint(self.s[0])
        # repeat checkbox
        self.h1Box = OWGUI.indentedBox(self.sBox,
                                       sep=indent,
                                       orientation="horizontal")
        OWGUI.checkBox(self.h1Box,
                       self,
                       'Repeat',
                       'With replacement',
                       callback=self.settingsChanged)

        # specified number of elements checkbox
        self.h2Box = OWGUI.indentedBox(self.sBox,
                                       sep=indent,
                                       orientation="horizontal")
        OWGUI.checkWithSpin(self.h2Box,
                            self,
                            'Sample size (instances):',
                            1,
                            1000000000,
                            'useCases',
                            'nCases',
                            checkCallback=[self.uCases, self.settingsChanged],
                            spinCallback=self.settingsChanged)
        OWGUI.rubber(self.h2Box)

        # percentage slider
        self.h3Box = OWGUI.indentedBox(self.sBox,
                                       sep=indent,
                                       orientation="horizontal")
        OWGUI.widgetLabel(self.h3Box, "Sample size:")
        self.slidebox = OWGUI.indentedBox(self.sBox,
                                          sep=indent,
                                          orientation="horizontal")
        OWGUI.hSlider(self.slidebox,
                      self,
                      'selPercentage',
                      minValue=1,
                      maxValue=100,
                      step=1,
                      ticks=10,
                      labelFormat="   %d%%",
                      callback=self.settingsChanged)

        # Cross Validation
        self.s[1] = OWGUI.appendRadioButton(self.sBox, self, "SelectType",
                                            'Cross validation')

        box = OWGUI.indentedBox(self.sBox,
                                sep=indent,
                                orientation="horizontal")
        OWGUI.spin(box,
                   self,
                   'CVFolds',
                   2,
                   100,
                   step=1,
                   label='Number of folds:  ',
                   callback=[self.changeCombo, self.settingsChanged])
        OWGUI.rubber(box)

        # Leave-One-Out
        self.s[2] = OWGUI.appendRadioButton(self.sBox, self, "SelectType",
                                            'Leave-one-out')

        # Multiple Groups
        self.s[3] = OWGUI.appendRadioButton(self.sBox, self, "SelectType",
                                            'Multiple subsets')
        gbox = OWGUI.indentedBox(self.sBox,
                                 sep=indent,
                                 orientation="horizontal")
        OWGUI.lineEdit(gbox,
                       self,
                       'GroupText',
                       label='Subset sizes (e.g. "0.1, 0.2, 0.5"):',
                       callback=self.multipleChanged)

        # Output Group Box
        self.foldcombo = OWGUI.comboBox(self.controlArea,
                                        self,
                                        "outFold",
                                        'Output Data for Fold / Group',
                                        'Fold / group:',
                                        orientation="horizontal",
                                        items=list(range(1, 101)),
                                        callback=self.foldChanged,
                                        sendSelectedValue=1,
                                        valueType=int)
        self.foldcombo.setEnabled(False)

        # Select Data Button
        OWGUI.rubber(self.controlArea)
        self.sampleButton = OWGUI.button(self.controlArea,
                                         self,
                                         'Sample &Data',
                                         callback=self.process,
                                         addToLayout=False)
        self.buttonBackground.layout().setDirection(QBoxLayout.TopToBottom)
        self.buttonBackground.layout().insertWidget(0, self.sampleButton)
        self.buttonBackground.show()
        self.s[self.SelectType].setChecked(
            True)  # set initial radio button on (default sample type)

        # CONNECTIONS
        # set connections for RadioButton (SelectType)
        self.dummy1 = [None] * len(self.s)
        for i in range(len(self.s)):
            self.dummy1[i] = lambda x, v=i: self.sChanged(x, v)
            self.connect(self.s[i], SIGNAL("toggled(bool)"), self.dummy1[i])

        # final touch
        self.resize(200, 275)
Ejemplo n.º 39
0
    def __init__(self, canvasDlg, *args):
        apply(QDialog.__init__, (self, ) + args)
        self.canvasDlg = canvasDlg
        self.settings = dict(
            canvasDlg.settings
        )  # create a copy of the settings dict. in case we accept the dialog, we update the canvasDlg.settings with this dict
        if sys.platform == "darwin":
            self.setWindowTitle("Preferences")
        else:
            self.setWindowTitle("Canvas Options")
        self.topLayout = QVBoxLayout(self)
        self.topLayout.setSpacing(0)
        self.resize(300, 300)
        self.toAdd = []
        self.toRemove = []

        self.tabs = QTabWidget(self)
        GeneralTab = OWGUI.widgetBox(self.tabs, margin=4)
        ExceptionsTab = OWGUI.widgetBox(self.tabs, margin=4)
        TabOrderTab = OWGUI.widgetBox(self.tabs, margin=4)

        self.tabs.addTab(GeneralTab, "General")
        self.tabs.addTab(ExceptionsTab, "Exception handling")
        self.tabs.addTab(TabOrderTab, "Widget tab order")

        # #################################################################
        # GENERAL TAB
        generalBox = OWGUI.widgetBox(GeneralTab, "General Options")
        self.snapToGridCB = OWGUI.checkBox(generalBox,
                                           self.settings,
                                           "snapToGrid",
                                           "Snap widgets to grid",
                                           debuggingEnabled=0)
        self.writeLogFileCB = OWGUI.checkBox(
            generalBox,
            self.settings,
            "writeLogFile",
            "Save content of the Output window to a log file",
            debuggingEnabled=0)
        self.showSignalNamesCB = OWGUI.checkBox(
            generalBox,
            self.settings,
            "showSignalNames",
            "Show signal names between widgets",
            debuggingEnabled=0)
        self.dontAskBeforeCloseCB = OWGUI.checkBox(
            generalBox,
            self.settings,
            "dontAskBeforeClose",
            "Don't ask to save schema before closing",
            debuggingEnabled=0)
        self.saveWidgetsPositionCB = OWGUI.checkBox(
            generalBox,
            self.settings,
            "saveWidgetsPosition",
            "Save size and position of widgets",
            debuggingEnabled=0)
        self.useContextsCB = OWGUI.checkBox(generalBox, self.settings,
                                            "useContexts",
                                            "Use context settings")

        validator = QIntValidator(self)
        validator.setRange(0, 10000)

        hbox1 = OWGUI.widgetBox(GeneralTab, orientation="horizontal")
        hbox2 = OWGUI.widgetBox(GeneralTab, orientation="horizontal")
        canvasDlgSettings = OWGUI.widgetBox(hbox1, "Canvas Dialog Settings")
        #        schemeSettings = OWGUI.widgetBox(hbox1, "Scheme Settings")

        self.widthSlider = OWGUI.qwtHSlider(canvasDlgSettings,
                                            self.settings,
                                            "canvasWidth",
                                            minValue=300,
                                            maxValue=1200,
                                            label="Canvas width:  ",
                                            step=50,
                                            precision=" %.0f px",
                                            debuggingEnabled=0)
        self.heightSlider = OWGUI.qwtHSlider(canvasDlgSettings,
                                             self.settings,
                                             "canvasHeight",
                                             minValue=300,
                                             maxValue=1200,
                                             label="Canvas height:  ",
                                             step=50,
                                             precision=" %.0f px",
                                             debuggingEnabled=0)
        OWGUI.separator(canvasDlgSettings)

        items = [str(n) for n in QStyleFactory.keys()]
        ind = items.index(self.settings.get("style", "WindowsXP"))
        OWGUI.comboBox(canvasDlgSettings,
                       self.settings,
                       "style",
                       label="Window style:",
                       orientation="horizontal",
                       items=[str(n) for n in QStyleFactory.keys()],
                       sendSelectedValue=1,
                       debuggingEnabled=0)
        OWGUI.checkBox(canvasDlgSettings,
                       self.settings,
                       "useDefaultPalette",
                       "Use style's standard palette",
                       debuggingEnabled=0)

        #        if canvasDlg:
        #            selectedWidgetBox = OWGUI.widgetBox(schemeSettings, orientation = "horizontal")
        #            self.selectedWidgetIcon = ColorIcon(selectedWidgetBox, canvasDlg.widgetSelectedColor)
        #            selectedWidgetBox.layout().addWidget(self.selectedWidgetIcon)
        #            selectedWidgetLabel = OWGUI.widgetLabel(selectedWidgetBox, " Selected widget")
        #
        #            activeWidgetBox = OWGUI.widgetBox(schemeSettings, orientation = "horizontal")
        #            self.activeWidgetIcon = ColorIcon(activeWidgetBox, canvasDlg.widgetActiveColor)
        #            activeWidgetBox.layout().addWidget(self.activeWidgetIcon)
        #            selectedWidgetLabel = OWGUI.widgetLabel(activeWidgetBox, " Active widget")
        #
        #            lineBox = OWGUI.widgetBox(schemeSettings, orientation = "horizontal")
        #            self.lineIcon = ColorIcon(lineBox, canvasDlg.lineColor)
        #            lineBox.layout().addWidget(self.lineIcon)
        #            selectedWidgetLabel = OWGUI.widgetLabel(lineBox, " Lines")
        #
        #        OWGUI.separator(schemeSettings)
        #        items = ["%d x %d" % (v,v) for v in self.canvasDlg.schemeIconSizeList]
        #        val = min(len(items)-1, self.settings['schemeIconSize'])
        #        self.schemeIconSizeCombo = OWGUI.comboBoxWithCaption(schemeSettings, self.settings, 'schemeIconSize', "Scheme icon size:", items = items, tooltip = "Set the size of the widget icons on the scheme", debuggingEnabled = 0)

        GeneralTab.layout().addStretch(1)

        # #################################################################
        # EXCEPTION TAB
        exceptions = OWGUI.widgetBox(ExceptionsTab, "Exceptions")
        #self.catchExceptionCB = QCheckBox('Catch exceptions', exceptions)
        self.focusOnCatchExceptionCB = OWGUI.checkBox(
            exceptions, self.settings, "focusOnCatchException",
            'Show output window on exception')
        self.printExceptionInStatusBarCB = OWGUI.checkBox(
            exceptions, self.settings, "printExceptionInStatusBar",
            'Print last exception in status bar')

        output = OWGUI.widgetBox(ExceptionsTab, "System output")
        #self.catchOutputCB = QCheckBox('Catch system output', output)
        self.focusOnCatchOutputCB = OWGUI.checkBox(
            output, self.settings, "focusOnCatchOutput",
            'Focus output window on system output')
        self.printOutputInStatusBarCB = OWGUI.checkBox(
            output, self.settings, "printOutputInStatusBar",
            'Print last system output in status bar')

        hboxExc = OWGUI.widgetBox(ExceptionsTab, orientation="horizontal")
        outputCanvas = OWGUI.widgetBox(hboxExc, "Canvas Info Handling")
        outputWidgets = OWGUI.widgetBox(hboxExc, "Widget Info Handling")
        self.ocShow = OWGUI.checkBox(outputCanvas, self.settings, "ocShow",
                                     'Show icon above widget for...')
        self.ocInfo = OWGUI.checkBox(OWGUI.indentedBox(outputCanvas, 10),
                                     self.settings, "ocInfo", 'Information')
        self.ocWarning = OWGUI.checkBox(OWGUI.indentedBox(outputCanvas, 10),
                                        self.settings, "ocWarning", 'Warnings')
        self.ocError = OWGUI.checkBox(OWGUI.indentedBox(outputCanvas, 10),
                                      self.settings, "ocError", 'Errors')

        self.owShow = OWGUI.checkBox(outputWidgets, self.settings, "owShow",
                                     'Show statusbar info for...')
        self.owInfo = OWGUI.checkBox(OWGUI.indentedBox(outputWidgets, 10),
                                     self.settings, "owInfo", 'Information')
        self.owWarning = OWGUI.checkBox(OWGUI.indentedBox(outputWidgets, 10),
                                        self.settings, "owWarning", 'Warnings')
        self.owError = OWGUI.checkBox(OWGUI.indentedBox(outputWidgets, 10),
                                      self.settings, "owError", 'Errors')

        verbosityBox = OWGUI.widgetBox(ExceptionsTab,
                                       "Verbosity",
                                       orientation="horizontal")
        verbosityBox.setSizePolicy(
            QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum))
        self.verbosityCombo = OWGUI.comboBox(
            verbosityBox,
            self.settings,
            "outputVerbosity",
            label="Set level of widget output: ",
            orientation='horizontal',
            items=["Small", "Medium", "High"])
        ExceptionsTab.layout().addStretch(1)

        # #################################################################
        # TAB ORDER TAB
        tabOrderBox = OWGUI.widgetBox(TabOrderTab,
                                      "Set Order of Widget Categories",
                                      orientation="horizontal",
                                      sizePolicy=QSizePolicy(
                                          QSizePolicy.Minimum,
                                          QSizePolicy.Minimum))
        self.tabOrderList = QListWidget(tabOrderBox)
        self.tabOrderList.setAcceptDrops(True)

        tabOrderBox.layout().addWidget(self.tabOrderList)
        self.tabOrderList.setSelectionMode(QListWidget.SingleSelection)

        ind = 0
        for (name, show) in self.settings["WidgetTabs"]:
            if self.canvasDlg.widgetRegistry.has_key(name):
                self.tabOrderList.addItem(name)
                self.tabOrderList.item(ind).setCheckState(show and Qt.Checked
                                                          or Qt.Unchecked)
                ind += 1

        w = OWGUI.widgetBox(tabOrderBox,
                            sizePolicy=QSizePolicy(QSizePolicy.Minimum,
                                                   QSizePolicy.Expanding))
        self.upButton = OWGUI.button(w, self, "Up", callback=self.moveUp)
        self.downButton = OWGUI.button(w, self, "Down", callback=self.moveDown)
        w.layout().addSpacing(20)
        self.addButton = OWGUI.button(w,
                                      self,
                                      "Add",
                                      callback=self.addCategory)
        self.removeButton = OWGUI.button(w,
                                         self,
                                         "Remove",
                                         callback=self.removeCategory)
        self.removeButton.setEnabled(0)
        w.layout().addStretch(1)

        # OK, Cancel buttons
        hbox = OWGUI.widgetBox(self,
                               orientation="horizontal",
                               sizePolicy=QSizePolicy(QSizePolicy.Minimum,
                                                      QSizePolicy.Fixed))
        hbox.layout().addStretch(1)
        self.okButton = OWGUI.button(hbox, self, "OK", callback=self.accept)
        self.cancelButton = OWGUI.button(hbox,
                                         self,
                                         "Cancel",
                                         callback=self.reject)
        self.connect(self.tabOrderList, SIGNAL("currentRowChanged(int)"),
                     self.enableDisableButtons)

        self.topLayout.addWidget(self.tabs)
        self.topLayout.addWidget(hbox)
Ejemplo n.º 40
0
    def defineGUI(self):

        self.sBox = OWGUI.widgetBox(self.controlArea, "Execution environment")
        itms = [e[0] for e in self.execEnvs]
        OWGUI.radioButtonsInBox(self.sBox, self, "execEnv", btnLabels=itms)

        boxGrid = OWGUI.widgetBox(self.controlArea,
                                  'Initial Point for the Optimizer')
        OWGUI.checkBox(
            boxGrid,
            self,
            'UseGridSearch',
            'Use Grid-Search',
            tooltip=
            'Use Grid-Search to find the best initial point to start the optimization.<br>If not checked, the midrange point will be used as optimization initial point.'
        )
        OWGUI.spin(
            boxGrid,
            self,
            'nInnerPoints',
            1,
            100,
            step=1,
            label='    Number of inner points:',
            tooltip=
            'Number of points to break down each variable to evaluate the initial point.<br>It will evaluate nInnerPoints^nOptimizedVars'
        )

        OWGUI.separator(self.controlArea)

        self.sBox = OWGUI.widgetBox(self.controlArea, "Sampling  Method")
        itms = [e[0] for e in self.SMethods]
        self.comboDistItems = [
            "Continuous", "Power2", "By Step", "Specific Values"
        ]
        OWGUI.radioButtonsInBox(self.sBox, self, "SMethod", btnLabels=itms)

        hBox = OWGUI.widgetBox(OWGUI.indentedBox(self.sBox))
        #QWidget(hBox).setFixedSize(19, 8)
        OWGUI.spin(hBox,
                   self,
                   'nFolds',
                   2,
                   100,
                   step=1,
                   label='Number of Folds:  ')

        OWGUI.separator(self.controlArea)

        box2 = OWGUI.widgetBox(self.controlArea, 'Evaluation Method')
        width = 150
        itms = [e[0] for e in self.CMethods]
        OWGUI.comboBox(
            box2,
            self,
            'CMethod',
            items=itms,
            label='For Classifiers:',
            labelWidth=width,
            orientation='horizontal',
            tooltip='Method used for evaluation in case of classifiers.')
        itms = [e[0] for e in self.RMethods]
        OWGUI.comboBox(
            box2,
            self,
            'RMethod',
            items=itms,
            label='For Regressors:',
            labelWidth=width,
            orientation='horizontal',
            tooltip='Method used for evaluation in case of regressors.')

        OWGUI.separator(self.controlArea)
        OWGUI.button(self.controlArea,
                     self,
                     "&Reload Defaults ",
                     callback=self.reloadDefaults)
        OWGUI.separator(self.controlArea)

        #OWGUI.separator(self.controlArea, height=24)

        infoBox = OWGUI.widgetBox(self.controlArea, "Optimizer status")
        self.infoStatus = OWGUI.label(infoBox, self, 'Waiting for inputs...')
        self.infoPars = OWGUI.label(infoBox, self, '')
        self.infoRes = OWGUI.label(infoBox, self, '')
        OWGUI.label(infoBox, self, '')
        self.infoErr = OWGUI.label(infoBox, self, '')
        OWGUI.separator(self.controlArea)
        OWGUI.button(self.controlArea,
                     self,
                     "&Apply Settings ",
                     callback=self.optimizeParameters)

        # Main area GUI
        import sip
        sip.delete(self.mainArea.layout())
        self.mainLayout = QGridLayout(self.mainArea)

        mainRight = OWGUI.widgetBox(self.mainArea, "Parameters Configuration")
        mainRight.setSizePolicy(
            QSizePolicy(QSizePolicy.MinimumExpanding,
                        QSizePolicy.MinimumExpanding))

        self.paramsTable = OWGUI.table(
            self.mainArea,
            rows=0,
            columns=0,
            selectionMode=QTableWidget.MultiSelection,
            addToLayout=0)
        #self.paramsTable.setLeftMargin(0)
        self.paramsTable.verticalHeader().hide()
        self.paramsTable.setSelectionMode(QTableWidget.NoSelection)
        self.paramsTable.setColumnCount(len(self.paramsNames))

        #for i, m in enumerate(self.paramsNames):
        #    self.paramsTable.setColumnStretchable(i, 0)
        #    header.setLabel(i, m)
        self.paramsTable.setHorizontalHeaderLabels(self.paramsNames)
        #self.mainLayout.setColumnStretch(1, 100)
        #self.mainLayout.setRowStretch(2, 100)
        self.mainLayout.addWidget(self.paramsTable, 0, 0, 1, 2)
        self.mainLayout.addWidget(
            OWGUI.label(
                mainRight, self,
                'Red - Parameter selected to be optimized\r\nGreen - Parameter optimized\r\nBlack - Parameter will not be optimized'
            ), 1, 0)
        self.mainLayout.addWidget(
            OWGUI.label(
                mainRight, self,
                'N_EX - Number of Examples in dataset\r\nN_ATTR - Number of attributes in dataset'
            ), 1, 1)

        self.adjustSize()
        self.create()
Ejemplo n.º 41
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, "TestLearners")

        self.inputs = [("Data", ExampleTable, self.setData, Default),
                       ("Separate Test Data", ExampleTable, self.setTestData),
                       ("Learner", orange.Learner, self.setLearner, Multiple),
                       ("Preprocess", PreprocessedLearner,
                        self.setPreprocessor)]
        self.outputs = [("Evaluation Results", orngTest.ExperimentResults)]

        # Settings
        self.resampling = 0  # cross-validation
        self.nFolds = 5  # cross validation folds
        self.pLearning = 70  # size of learning set when sampling [%]
        self.pRepeat = 10
        self.precision = 4
        self.applyOnAnyChange = True
        self.selectedCScores = [
            i for (i, s) in enumerate(self.cStatistics) if s.show
        ]
        self.selectedRScores = [
            i for (i, s) in enumerate(self.rStatistics) if s.show
        ]
        self.targetClass = 0
        self.loadSettings()
        self.resampling = 0  # cross-validation

        self.stat = self.cStatistics

        self.data = None  # input data set
        self.testdata = None  # separate test data set
        self.learners = {}  # set of learners (input)
        self.results = None  # from orngTest
        self.preprocessor = None

        self.controlArea.layout().setSpacing(8)
        # GUI
        self.sBtns = OWGUI.radioButtonsInBox(
            self.controlArea,
            self,
            "resampling",
            box="Sampling",
            btnLabels=self.resamplingMethods[:1],
            callback=self.newsampling)
        indent = OWGUI.checkButtonOffsetHint(self.sBtns.buttons[-1])

        ibox = OWGUI.widgetBox(OWGUI.indentedBox(self.sBtns, sep=indent))
        OWGUI.spin(ibox,
                   self,
                   'nFolds',
                   2,
                   100,
                   step=1,
                   label='Number of folds:',
                   callback=lambda p=0: self.conditionalRecompute(p))
        OWGUI.separator(self.sBtns, height=3)

        OWGUI.appendRadioButton(self.sBtns, self, "resampling",
                                self.resamplingMethods[1])  # leave one out
        OWGUI.separator(self.sBtns, height=3)
        OWGUI.appendRadioButton(self.sBtns, self, "resampling",
                                self.resamplingMethods[2])  # random sampling

        ibox = OWGUI.widgetBox(OWGUI.indentedBox(self.sBtns, sep=indent))
        OWGUI.spin(ibox,
                   self,
                   'pRepeat',
                   1,
                   100,
                   step=1,
                   label='Repeat train/test:',
                   callback=lambda p=2: self.conditionalRecompute(p))

        OWGUI.widgetLabel(ibox, "Relative training set size:")

        OWGUI.hSlider(ibox,
                      self,
                      'pLearning',
                      minValue=10,
                      maxValue=100,
                      step=1,
                      ticks=10,
                      labelFormat="   %d%%",
                      callback=lambda p=2: self.conditionalRecompute(p))

        OWGUI.separator(self.sBtns, height=3)
        OWGUI.appendRadioButton(self.sBtns, self, "resampling",
                                self.resamplingMethods[3])  # test on train
        OWGUI.separator(self.sBtns, height=3)
        OWGUI.appendRadioButton(self.sBtns, self, "resampling",
                                self.resamplingMethods[4])  # test on test

        self.trainDataBtn = self.sBtns.buttons[-2]
        self.testDataBtn = self.sBtns.buttons[-1]
        self.testDataBtn.setDisabled(True)

        #        box = OWGUI.widgetBox(self.sBtns, orientation='vertical', addSpace=False)
        #        OWGUI.separator(box)
        OWGUI.separator(self.sBtns)
        OWGUI.checkBox(self.sBtns,
                       self,
                       'applyOnAnyChange',
                       label="Apply on any change",
                       callback=self.applyChange)
        self.applyBtn = OWGUI.button(self.sBtns,
                                     self,
                                     "&Apply",
                                     callback=lambda f=True: self.recompute(f))
        self.applyBtn.setDisabled(True)

        if self.resampling == 4:
            self.resampling = 3

#        OWGUI.separator(self.controlArea)

# statistics
        self.statLayout = QStackedLayout()
        #        self.cbox = OWGUI.widgetBox(self.controlArea, spacing=8, margin=0)
        #        self.cbox.layout().setSpacing(8)
        self.cbox = OWGUI.widgetBox(self.controlArea, addToLayout=False)
        self.cStatLabels = [s.name for s in self.cStatistics]
        self.cstatLB = OWGUI.listBox(self.cbox,
                                     self,
                                     'selectedCScores',
                                     'cStatLabels',
                                     box="Performance scores",
                                     selectionMode=QListWidget.MultiSelection,
                                     callback=self.newscoreselection)
        #        OWGUI.separator(self.cbox)
        self.cbox.layout().addSpacing(8)
        self.targetCombo = OWGUI.comboBox(self.cbox,
                                          self,
                                          "targetClass",
                                          orientation=0,
                                          callback=[self.changedTarget],
                                          box="Target class")

        self.rStatLabels = [s.name for s in self.rStatistics]
        self.rbox = OWGUI.widgetBox(self.controlArea,
                                    "Performance scores",
                                    addToLayout=False)
        self.rstatLB = OWGUI.listBox(self.rbox,
                                     self,
                                     'selectedRScores',
                                     'rStatLabels',
                                     selectionMode=QListWidget.MultiSelection,
                                     callback=self.newscoreselection)

        self.statLayout.addWidget(self.cbox)
        self.statLayout.addWidget(self.rbox)
        self.controlArea.layout().addLayout(self.statLayout)

        self.statLayout.setCurrentWidget(self.cbox)

        #        self.rstatLB.box.hide()

        # score table
        # table with results
        self.g = OWGUI.widgetBox(self.mainArea, 'Evaluation Results')
        self.tab = OWGUI.table(self.g, selectionMode=QTableWidget.NoSelection)

        #self.lab = QLabel(self.g)

        self.resize(680, 470)
Ejemplo n.º 42
0
    def __init__(self, parent=None, signalManager=None, name='TreeViewer2D'):
        OWWidget.__init__(self, parent, signalManager, name, wantGraph=True)
        self.root = None
        self.selectedNode = None

        self.inputs = [("Classification Tree",
                        Orange.classification.tree.TreeClassifier, self.ctree)]
        self.outputs = [("Examples", ExampleTable)]

        #set default settings
        self.ZoomAutoRefresh = 0
        self.AutoArrange = 0
        self.ToolTipsEnabled = 1
        self.MaxTreeDepth = 5
        self.MaxTreeDepthB = 0
        self.LineWidth = 5
        self.LineWidthMethod = 2
        self.NodeSize = 5
        self.MaxNodeWidth = 150
        self.LimitNodeWidth = True
        self.NodeInfo = [0, 1]

        self.Zoom = 5
        self.VSpacing = 5
        self.HSpacing = 5
        self.TruncateText = 1

        self.loadSettings()
        self.NodeInfo.sort()

        # Changed when the GUI was simplified - added here to override any saved settings
        self.VSpacing = 1
        self.HSpacing = 1
        self.ToolTipsEnabled = 1
        self.LineWidth = 15  # Also reset when the LineWidthMethod is changed!

        # GUI definition
        #        self.tabs = OWGUI.tabWidget(self.controlArea)

        # GENERAL TAB
        # GeneralTab = OWGUI.createTabPage(self.tabs, "General")
        #        GeneralTab = TreeTab = OWGUI.createTabPage(self.tabs, "Tree")
        #        NodeTab = OWGUI.createTabPage(self.tabs, "Node")

        GeneralTab = NodeTab = TreeTab = self.controlArea

        self.infBox = OWGUI.widgetBox(GeneralTab,
                                      'Info',
                                      sizePolicy=QSizePolicy(
                                          QSizePolicy.Minimum,
                                          QSizePolicy.Fixed),
                                      addSpace=True)
        self.infoa = OWGUI.widgetLabel(self.infBox, 'No tree.')
        self.infob = OWGUI.widgetLabel(self.infBox, " ")

        self.sizebox = OWGUI.widgetBox(GeneralTab, "Size", addSpace=True)
        OWGUI.hSlider(self.sizebox,
                      self,
                      'Zoom',
                      label='Zoom',
                      minValue=1,
                      maxValue=10,
                      step=1,
                      callback=self.toggleZoomSlider,
                      ticks=1)
        OWGUI.separator(self.sizebox)

        cb, sb = OWGUI.checkWithSpin(self.sizebox,
                                     self,
                                     "Max node width:",
                                     50,
                                     200,
                                     "LimitNodeWidth",
                                     "MaxNodeWidth",
                                     tooltip="Limit the width of tree nodes",
                                     checkCallback=self.toggleNodeSize,
                                     spinCallback=self.toggleNodeSize,
                                     step=10)
        b = OWGUI.checkBox(OWGUI.indentedBox(
            self.sizebox, sep=OWGUI.checkButtonOffsetHint(cb)),
                           self,
                           "TruncateText",
                           "Truncate text",
                           callback=self.toggleTruncateText)
        cb.disables.append(b)
        cb.makeConsistent()

        OWGUI.checkWithSpin(self.sizebox,
                            self,
                            'Max tree depth:',
                            1,
                            20,
                            'MaxTreeDepthB',
                            "MaxTreeDepth",
                            tooltip='Defines the depth of the tree displayed',
                            checkCallback=self.toggleTreeDepth,
                            spinCallback=self.toggleTreeDepth)

        self.edgebox = OWGUI.widgetBox(GeneralTab,
                                       "Edge Widths",
                                       addSpace=True)
        OWGUI.comboBox(self.edgebox,
                       self,
                       'LineWidthMethod',
                       items=['Equal width', 'Root node', 'Parent node'],
                       callback=self.toggleLineWidth)
        # Node information
        grid = QGridLayout()
        grid.setContentsMargins(
            *self.controlArea.layout().getContentsMargins())

        navButton = OWGUI.button(self.controlArea,
                                 self,
                                 "Navigator",
                                 self.toggleNavigator,
                                 debuggingEnabled=0,
                                 addToLayout=False)
        #        findbox = OWGUI.widgetBox(self.controlArea, orientation = "horizontal")
        self.centerRootButton=OWGUI.button(self.controlArea, self, "Find Root", addToLayout=False,
                                           callback=lambda :self.rootNode and \
                                           self.sceneView.centerOn(self.rootNode.x(), self.rootNode.y()))
        self.centerNodeButton=OWGUI.button(self.controlArea, self, "Find Selected", addToLayout=False,
                                           callback=lambda :self.selectedNode and \
                                           self.sceneView.centerOn(self.selectedNode.scenePos()))
        grid.addWidget(navButton, 0, 0, 1, 2)
        grid.addWidget(self.centerRootButton, 1, 0)
        grid.addWidget(self.centerNodeButton, 1, 1)
        self.leftWidgetPart.layout().insertLayout(1, grid)

        self.NodeTab = NodeTab
        self.TreeTab = TreeTab
        self.GeneralTab = GeneralTab
        #        OWGUI.rubber(NodeTab)
        self.rootNode = None
        self.tree = None
        self.resize(800, 500)

        self.connect(self.graphButton, SIGNAL("clicked()"), self.saveGraph)
Ejemplo n.º 43
0
    def __init__(self, parent=None, signalManager=None):
        #OWWidget.__init__(self, parent, 'Hierarchical Clustering')
        OWWidget.__init__(self, parent, signalManager,
                          'Hierarchical Clustering')
        self.parent = parent
        self.callbackDeposit = []
        self.inputs = [("Distance matrix", orange.SymMatrix, self.dataset)]
        self.outputs = [("Selected Examples", ExampleTable),
                        ("Unselected Examples", ExampleTable),
                        ("Structured Data Files", DataFiles)]
        self.linkage = [
            ("Single linkage", orange.HierarchicalClustering.Single),
            ("Average linkage", orange.HierarchicalClustering.Average),
            ("Ward's linkage", orange.HierarchicalClustering.Ward),
            ("Complete linkage", orange.HierarchicalClustering.Complete),
        ]
        self.Linkage = 0
        self.OverwriteMatrix = 0
        self.Annotation = 0
        self.Brightness = 5
        self.PrintDepthCheck = 0
        self.PrintDepth = 100
        self.HDSize = 500  #initial horizontal and vertical dendrogram size
        self.VDSize = 800
        self.ManualHorSize = 0
        self.AutoResize = 0
        self.TextSize = 8
        self.LineSpacing = 4
        self.SelectionMode = 0
        self.ZeroOffset = 1
        self.DisableHighlights = 0
        self.DisableBubble = 0
        self.ClassifySelected = 0
        self.CommitOnChange = 0
        self.ClassifyName = "HC_class"
        self.loadSettings()
        self.AutoResize = False
        self.inputMatrix = None
        self.matrixSource = "Unknown"
        self.rootCluster = None
        self.selectedExamples = None
        self.ctrlPressed = FALSE
        self.addIdAs = 0
        self.settingsChanged = False

        self.linkageMethods = [a[0] for a in self.linkage]

        #################################
        ##GUI
        #################################

        #Tabs
        ##        self.tabs = OWGUI.tabWidget(self.controlArea)
        ##        self.settingsTab = OWGUI.createTabPage(self.tabs, "Settings")
        ##        self.selectionTab= OWGUI.createTabPage(self.tabs, "Selection")

        #HC Settings
        OWGUI.comboBox(self.controlArea,
                       self,
                       "Linkage",
                       box="Linkage",
                       items=self.linkageMethods,
                       tooltip="Choose linkage method",
                       callback=self.constructTree,
                       addSpace=16)
        #Label
        box = OWGUI.widgetBox(self.controlArea, "Annotation", addSpace=16)
        self.labelCombo = OWGUI.comboBox(box,
                                         self,
                                         "Annotation",
                                         items=["None"],
                                         tooltip="Choose label attribute",
                                         callback=self.updateLabel)

        OWGUI.spin(box,
                   self,
                   "TextSize",
                   label="Text font size",
                   min=5,
                   max=15,
                   step=1,
                   callback=self.applySettings,
                   controlWidth=40)
        OWGUI.spin(box,
                   self,
                   "LineSpacing",
                   label="Line spacing",
                   min=2,
                   max=8,
                   step=1,
                   callback=self.applySettings,
                   controlWidth=40)

        #        OWGUI.checkBox(box, self, "DisableBubble", "Disable bubble info")

        #Dendrogram graphics settings
        dendrogramBox = OWGUI.widgetBox(self.controlArea,
                                        "Dendrogram settings",
                                        addSpace=16)
        #OWGUI.spin(dendrogramBox, self, "Brightness", label="Brigthtness",min=1,max=9,step=1)
        cblp = OWGUI.checkBox(dendrogramBox,
                              self,
                              "PrintDepthCheck",
                              "Limit print depth",
                              callback=self.applySettings)
        ib = OWGUI.indentedBox(dendrogramBox, orientation=0)
        OWGUI.widgetLabel(ib, "Depth" + "  ")
        slpd = OWGUI.hSlider(ib,
                             self,
                             "PrintDepth",
                             minValue=1,
                             maxValue=50,
                             callback=self.applySettings)
        cblp.disables.append(ib)
        cblp.makeConsistent()

        OWGUI.separator(dendrogramBox)
        #OWGUI.spin(dendrogramBox, self, "VDSize", label="Vertical size", min=100,
        #        max=10000, step=10)
        cbhs = OWGUI.checkBox(
            dendrogramBox,
            self,
            "ManualHorSize",
            "Manually set horizontal size",
            callback=[
                lambda: self.hSizeBox.setDisabled(self.ManualHorSize),
                self.applySettings
            ])
        self.hSizeBox = OWGUI.spin(OWGUI.indentedBox(dendrogramBox),
                                   self,
                                   "HDSize",
                                   label="Size" + "  ",
                                   min=200,
                                   max=10000,
                                   step=10,
                                   callback=self.applySettings,
                                   callbackOnReturn=True,
                                   controlWidth=45)
        cbhs.disables.append(self.hSizeBox)
        cbhs.makeConsistent()

        #OWGUI.checkBox(dendrogramBox, self, "ManualHorSize", "Fit horizontal size")
        #OWGUI.checkBox(dendrogramBox, self, "AutoResize", "Auto resize")

        box = OWGUI.widgetBox(self.controlArea, "Selection")
        OWGUI.checkBox(box,
                       self,
                       "SelectionMode",
                       "Show cutoff line",
                       callback=self.updateCutOffLine)
        cb = OWGUI.checkBox(box,
                            self,
                            "ClassifySelected",
                            "Append cluster indices",
                            callback=self.commitDataIf)
        self.classificationBox = ib = OWGUI.indentedBox(box)
        le = OWGUI.lineEdit(ib,
                            self,
                            "ClassifyName",
                            "Name" + "  ",
                            callback=self.commitDataIf,
                            orientation=0,
                            controlWidth=75)
        OWGUI.separator(ib, height=4)
        aa = OWGUI.comboBox(
            ib,
            self,
            "addIdAs",
            label="Place" + "  ",
            orientation=0,
            items=["Class attribute", "Attribute", "Meta attribute"],
            callback=self.commitDataIf)
        cb.disables.append(ib)
        cb.makeConsistent()

        OWGUI.separator(box)
        cbAuto = OWGUI.checkBox(box, self, "CommitOnChange",
                                "Commit on change")
        btCommit = OWGUI.button(box, self, "&Commit", self.commitData)
        OWGUI.setStopper(self, btCommit, cbAuto, "settingsChanged",
                         self.commitData)

        OWGUI.rubber(self.controlArea)
        OWGUI.button(self.controlArea,
                     self,
                     "&Save Graph",
                     self.saveGraph,
                     debuggingEnabled=0)

        scale = QGraphicsScene(self)
        self.headerView = ScaleView(self, scale, self.mainArea)
        self.footerView = ScaleView(self, scale, self.mainArea)
        self.dendrogram = Dendrogram(self)
        self.dendrogramView = DendrogramView(self.dendrogram, self.mainArea)

        self.mainArea.layout().addWidget(self.headerView)
        self.mainArea.layout().addWidget(self.dendrogramView)
        self.mainArea.layout().addWidget(self.footerView)

        self.dendrogram.header = self.headerView
        self.dendrogram.footer = self.footerView

        self.connect(self.dendrogramView.horizontalScrollBar(),
                     SIGNAL("valueChanged(int)"),
                     self.footerView.horizontalScrollBar().setValue)
        self.connect(self.dendrogramView.horizontalScrollBar(),
                     SIGNAL("valueChanged(int)"),
                     self.headerView.horizontalScrollBar().setValue)
        self.dendrogram.setSceneRect(0, 0, self.HDSize, self.VDSize)
        self.dendrogram.update()
        self.resize(800, 500)

        self.matrix = None
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, "Nomogram", 1)

        #self.setWFlags(Qt.WResizeNoErase | Qt.WRepaintNoErase) #this works like magic.. no flicker during repaint!
        self.parent = parent
        #        self.setWFlags(self.getWFlags()+Qt.WStyle_Maximize)

        self.callbackDeposit = []  # deposit for OWGUI callback functions
        self.alignType = 0
        self.contType = 0
        self.yAxis = 0
        self.probability = 0
        self.verticalSpacing = 60
        self.verticalSpacingContinuous = 100
        self.diff_between_ordinal = 30
        self.fontSize = 9
        self.lineWidth = 1
        self.histogram = 0
        self.histogram_size = 10
        self.data = None
        self.cl = None
        self.confidence_check = 0
        self.confidence_percent = 95
        self.sort_type = 0

        self.loadSettings()

        self.pointsName = ["Total", "Total"]
        self.totalPointsName = ["Probability", "Probability"]
        self.bnomogram = None

        self.inputs = [("Classifier", orange.Classifier, self.classifier)]

        self.TargetClassIndex = 0
        self.targetCombo = OWGUI.comboBox(
            self.controlArea,
            self,
            "TargetClassIndex",
            " Target Class ",
            addSpace=True,
            tooltip='Select target (prediction) class in the model.',
            callback=self.setTarget)

        self.alignRadio = OWGUI.radioButtonsInBox(
            self.controlArea,
            self,
            'alignType', ['Align left', 'Align by zero influence'],
            box='Attribute placement',
            tooltips=[
                'Attributes in nomogram are left aligned',
                'Attributes are not aligned, top scale represents true (normalized) regression coefficient value'
            ],
            addSpace=True,
            callback=self.showNomogram)
        self.verticalSpacingLabel = OWGUI.spin(
            self.alignRadio,
            self,
            'verticalSpacing',
            15,
            200,
            label='Vertical spacing:',
            orientation=0,
            tooltip='Define space (pixels) between adjacent attributes.',
            callback=self.showNomogram)

        self.ContRadio = OWGUI.radioButtonsInBox(
            self.controlArea,
            self,
            'contType', ['1D projection', '2D curve'],
            'Continuous attributes',
            tooltips=[
                'Continuous attribute are presented on a single scale',
                'Two dimensional space is used to present continuous attributes in nomogram.'
            ],
            addSpace=True,
            callback=[
                lambda: self.verticalSpacingContLabel.setDisabled(
                    not self.contType), self.showNomogram
            ])

        self.verticalSpacingContLabel = OWGUI.spin(
            OWGUI.indentedBox(self.ContRadio,
                              sep=OWGUI.checkButtonOffsetHint(
                                  self.ContRadio.buttons[-1])),
            self,
            'verticalSpacingContinuous',
            15,
            200,
            label="Height",
            orientation=0,
            tooltip=
            'Define space (pixels) between adjacent 2d presentation of attributes.',
            callback=self.showNomogram)
        self.verticalSpacingContLabel.setDisabled(not self.contType)

        self.yAxisRadio = OWGUI.radioButtonsInBox(
            self.controlArea,
            self,
            'yAxis', ['Point scale', 'Log odds ratios'],
            'Scale',
            tooltips=[
                'values are normalized on a 0-100 point scale',
                'values on top axis show log-linear contribution of attribute to full model'
            ],
            addSpace=True,
            callback=self.showNomogram)

        layoutBox = OWGUI.widgetBox(self.controlArea,
                                    "Display",
                                    orientation=1,
                                    addSpace=True)

        self.probabilityCheck = OWGUI.checkBox(layoutBox,
                                               self,
                                               'probability',
                                               'Show prediction',
                                               tooltip='',
                                               callback=self.setProbability)

        self.CICheck, self.CILabel = OWGUI.checkWithSpin(
            layoutBox,
            self,
            'Confidence intervals (%):',
            min=1,
            max=99,
            step=1,
            checked='confidence_check',
            value='confidence_percent',
            checkCallback=self.showNomogram,
            spinCallback=self.showNomogram)

        self.histogramCheck, self.histogramLabel = OWGUI.checkWithSpin(
            layoutBox,
            self,
            'Show histogram, size',
            min=1,
            max=30,
            checked='histogram',
            value='histogram_size',
            step=1,
            tooltip='-(TODO)-',
            checkCallback=self.showNomogram,
            spinCallback=self.showNomogram)

        OWGUI.separator(layoutBox)
        self.sortOptions = [
            "No sorting", "Absolute importance", "Positive influence",
            "Negative influence"
        ]
        self.sortBox = OWGUI.comboBox(layoutBox,
                                      self,
                                      "sort_type",
                                      label="Sort by ",
                                      items=self.sortOptions,
                                      callback=self.sortNomogram,
                                      orientation="horizontal")

        OWGUI.rubber(self.controlArea)

        self.connect(self.graphButton, SIGNAL("clicked()"),
                     self.menuItemPrinter)

        #add a graph widget
        self.header = OWNomogramHeader(None, self.mainArea)
        self.header.setFixedHeight(60)
        self.header.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.header.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.graph = OWNomogramGraph(self.bnomogram, self.mainArea)
        self.graph.setMinimumWidth(200)
        self.graph.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.footer = OWNomogramHeader(None, self.mainArea)
        self.footer.setFixedHeight(60 * 2 + 10)
        self.footer.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.footer.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)

        self.mainArea.layout().addWidget(self.header)
        self.mainArea.layout().addWidget(self.graph)
        self.mainArea.layout().addWidget(self.footer)
        self.resize(700, 500)
        #self.repaint()
        #self.update()

        # mouse pressed flag
        self.mousepr = False
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, parent=None, signalManager=None):
        "Constructor"
        OWWidget.__init__(self, parent, signalManager, "&Distributions", TRUE)
        # settings
        self.numberOfBars = 5
        self.barSize = 50
        self.showContinuousClassGraph = 1
        self.showProbabilities = 1
        self.showConfidenceIntervals = 0
        self.smoothLines = 0
        self.lineWidth = 1
        self.showMainTitle = 0
        self.showXaxisTitle = 1
        self.showYaxisTitle = 1
        self.showYPaxisTitle = 1

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

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

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

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

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

        self.loadSettings()

        self.barSize = 50

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

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

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

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

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

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

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

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

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

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

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

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

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

        OWGUI.rubber(self.SettingsTab)

        #add controls to self.controlArea widget

        self.icons = self.createAttributeIconDict()

        self.graph.numberOfBars = self.numberOfBars
        self.graph.barSize = self.barSize
        self.graph.setShowMainTitle(self.showMainTitle)
        self.graph.setShowXaxisTitle(self.showXaxisTitle)
        self.graph.setShowYLaxisTitle(self.showYaxisTitle)
        self.graph.setShowYRaxisTitle(self.showYPaxisTitle)
        self.graph.setMainTitle(self.mainTitle)
        self.graph.setXaxisTitle(self.xaxisTitle)
        self.graph.setYLaxisTitle(self.yaxisTitle)
        self.graph.setYRaxisTitle(self.yPaxisTitle)
        self.graph.showProbabilities = self.showProbabilities
        self.graph.showConfidenceIntervals = self.showConfidenceIntervals
        self.graph.smoothLines = self.smoothLines
        self.graph.lineWidth = self.lineWidth
        #self.graph.variableContinuous = self.VariableContinuous
        self.graph.targetValue = self.targetValue
    def __init__(self, parent=None, signalManager = None):
        "Constructor"
        OWWidget.__init__(self, parent, signalManager, "&Distributions", TRUE)
        # settings
        self.numberOfBars = 5
        self.barSize = 50
        self.showContinuousClassGraph=1
        self.showProbabilities = 1
        self.showConfidenceIntervals = 0
        self.smoothLines = 0
        self.lineWidth = 1
        self.showMainTitle = 0
        self.showXaxisTitle = 1
        self.showYaxisTitle = 1
        self.showYPaxisTitle = 1

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

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

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

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

        self.barSize = 50

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

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

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

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

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

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

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

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

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

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

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

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


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

        #add controls to self.controlArea widget

        self.icons = self.createAttributeIconDict()

        self.graph.numberOfBars = self.numberOfBars
        self.graph.barSize = self.barSize
        self.graph.setShowMainTitle(self.showMainTitle)
        self.graph.setShowXaxisTitle(self.showXaxisTitle)
        self.graph.setShowYLaxisTitle(self.showYaxisTitle)
        self.graph.setShowYRaxisTitle(self.showYPaxisTitle)
        self.graph.setMainTitle(self.mainTitle)
        self.graph.setXaxisTitle(self.xaxisTitle)
        self.graph.setYLaxisTitle(self.yaxisTitle)
        self.graph.setYRaxisTitle(self.yPaxisTitle)
        self.graph.showProbabilities = self.showProbabilities
        self.graph.showConfidenceIntervals = self.showConfidenceIntervals
        self.graph.smoothLines = self.smoothLines
        self.graph.lineWidth = self.lineWidth
        #self.graph.variableContinuous = self.VariableContinuous
        self.graph.targetValue = self.targetValue
    def __init__(self, parent=None, signalManager=None, name="Select data"):
        OWWidget.__init__(self, parent, signalManager, name,
                          wantMainArea=0)  #initialize base class

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        self.icons = self.createAttributeIconDict()
        self.setData(None)
        self.lbOperatorsD.setCurrentRow(0)
        self.lbOperatorsC.setCurrentRow(0)
        self.lbOperatorsS.setCurrentRow(0)
        self.resize(500, 661)
        grid.setRowStretch(0, 10)
        grid.setRowStretch(2, 10)
Ejemplo n.º 49
0
    def __init__(self, parent=None, signalManager=None, name="SVM"):
        OWWidget.__init__(self, parent, signalManager, name)
        self.inputs=[("Example Table", ExampleTable, self.setData)]
        self.outputs=[("Learner", orange.Learner),("Classifier", orange.Classifier)]   #  ,("Support Vectors", ExampleTable)]

        self.data = None
        self.name="Support Vector Machine"
        self.nMin = -1
        self.nMax = 1
        self.nClassMin = -1
        self.nClassMax = 1
        self.svm_typeGUI = None
        self.stopCritGUI = None
        self.priorsGUI = ""
        #Read default parameters from AZOrangeConfig.py file
        for par in ("kernel_type", "svm_type","gamma","C","p","epsC","epsR","stopCrit",\
                        "maxIter","nu","scaleData","scaleClass","priors","coef0","degree"):
            setattr(self, par, AZOC.CVSVMDEFAULTDICT[par])
        if self.svm_type in (103,104):
            self.eps = self.epsR
        else:
            self.eps = self.epsC
        self.setSVMTypeGUI(self.svm_type)
        self.setStopCritGUI(self.stopCrit)
        self.setPriorsGUI()#self.priors)

##scJS Added parameter needed for saving an SVM model
        self.modelFile = os.path.join(os.getcwd(),"SVM.model")
##ecJS
        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!')
        ## scLC
        # Do not use the one class svm (type 2).
        self.svmTypeBox=b=OWGUI.widgetBox(self.controlArea,"SVM Type")
        self.svmTyperadio = OWGUI.radioButtonsInBox(b, self, "svm_typeGUI", btnLabels=["C-SVC", "nu-SVC","epsilon-SVR", "nu-SVR"], callback=self.setSVMTypeLearner)
        ## ecLC

        self.kernelBox=b=OWGUI.widgetBox(self.controlArea, "Kernel")
        self.kernelradio = OWGUI.radioButtonsInBox(b, self, "kernel_type", btnLabels=["Linear,   x.y", "Polynomial,   (g*x.y+c)^d",
                    "RBF,   exp(-g*(x-y).(x-y))", "Sigmoid,   tanh(g*x.y+c)"], callback=self.changeKernel)

        self.gcd = OWGUI.widgetBox(b, orientation="horizontal")
        self.leg = OWGUI.doubleSpin(self.gcd, self, "gamma",0.0,10.0,0.0001, label="gamma: ", orientation="horizontal", callback=self.changeKernel)
        self.led = OWGUI.doubleSpin(self.gcd, self, "coef0", 0.0,10.0,0.0001, label="  coef0: ", orientation="horizontal", callback=self.changeKernel)
        self.lec = OWGUI.doubleSpin(self.gcd, self, "degree", 0.0,10.0,0.5, label="  degree: ", orientation="horizontal", callback=self.changeKernel)

        OWGUI.separator(self.controlArea)


        #self.layout=QVBoxLayout(self.mainArea)
        self.optionsBox=b=OWGUI.widgetBox(self.mainArea, "Options", addSpace = True)
        self.cBox = OWGUI.doubleSpin(b,self, "C", 0.0, 512.0, 0.5, label="Model complexity (C)",  orientation="horizontal", tooltip="Penalty cost")
        self.cBox.control.setDecimals(3)
        self.pBox = OWGUI.doubleSpin(b,self, "p", 0.0, 10.0, 0.1, label="Tolerance (p)",  orientation="horizontal", tooltip="zero-loss width zone")
        self.pBox.control.setDecimals(3)
        self.nuBox = OWGUI.doubleSpin(b, self, "nu", 0.0,1.0,0.1, label="Complexity bound (nu)",  orientation="horizontal", tooltip="Upper bound on the ratio of support vectors")
        self.nuBox.control.setDecimals(3)        

        self.priorBox = OWGUI.lineEdit(b, self, 'priorsGUI', box='Class weights', \
                       tooltip='Ex: POS:2 , NEG:1')

        self.stopCritBox=OWGUI.widgetBox(self.optionsBox,"Stop Criteria")
        self.stopCritradio = OWGUI.radioButtonsInBox(self.stopCritBox, self, "stopCritGUI", btnLabels=["Maximum number of iterations (maxIter)", "Numeric precision (eps)"], callback=self.setStopCritLearner)
        OWGUI.doubleSpin(self.stopCritBox,self, "eps", 0.0, 0.5, 0.001, label="Numeric precision (eps)",  orientation="horizontal")
        OWGUI.doubleSpin(self.stopCritBox,self, "maxIter", 0, 100000, 1, label="Maximum number of iterations (maxIter)",  orientation="horizontal")


        self.scaleDataBox=OWGUI.checkBox(b, self, "scaleData", "Scale Data", tooltip="Scales the training data, and the input examples",callback = self.changeScaling)
        self.scaleClassBox=OWGUI.checkBox(OWGUI.indentedBox(b), self, "scaleClass", "Scale Class variable", tooltip="Scales the class variable of training data, and the output predictions",callback = self.changeScaling)
        #self.scalenMin = OWGUI.lineEdit(OWGUI.indentedBox(b), self, 'nMin', 'Var min:', orientation="horizontal", tooltip='Variables scaling minimum')
        #self.scalenMax = OWGUI.lineEdit(OWGUI.indentedBox(b), self, 'nMax', 'Var max:', orientation="horizontal", tooltip='Variables scaling maximum')
        #OWGUI.separator(OWGUI.indentedBox(b))
        self.scalenClassMin = OWGUI.lineEdit(OWGUI.indentedBox(b), self, 'nClassMin', 'Class min:', orientation="horizontal", tooltip='Class scaling minimum')
        self.scalenClassMax = OWGUI.lineEdit(OWGUI.indentedBox(b), self, 'nClassMax', 'Class max:', orientation="horizontal", tooltip='Class scaling maximum')
        OWGUI.separator(self.controlArea)

        #self.paramButton=OWGUI.button(self.controlArea, self, "Automatic parameter search", callback=self.parameterSearch,
        #                             tooltip="Automaticaly searches for parameters that optimize classifier acuracy")
        self.optionsBox.adjustSize()
        #self.layout.add(self.optionsBox)

        #OWGUI.separator(self.controlArea)

        OWGUI.button(self.controlArea, self,"&Apply", callback=self.applySettings)
##scJS Adding saving of svm models 

        # 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.")
        #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 model
        OWGUI.button(self.controlArea, self,"&Save SVM model", callback=self.saveModel)

        #self.adjustSize()
        #self.loadSettings()
        self.setStopCritLearner()
        self.setSVMTypeLearner()
        self.changeKernel() 
        self.applySettings()
        self.resize(500,400)
Ejemplo n.º 50
0
    def __init__(self, parent=None, signalManager=None):
        """Widget creator."""
        
        OWWidget.__init__(            
            self,
            parent,
            signalManager,
            wantMainArea=0,
            wantStateInfoWidget=0,
        )
      
        # DEFINE OUTPUT
        
        self.outputs = [('Text data', Segmentation)]

       

        # Settings and other attribute initializations...

        self.segment_label = u'search_results'
        self.nb_tweet = 50
        self.include_RT = False
        self.word_to_search = ''
        self.autoSend = False

        self.useTwitterLicenseKey = False
        self.twitterLicenseKeys = False
        self.twitterLicenseKeysConsumerKey = ''
        self.twitterLicenseKeysConsumerSecret = ''
        self.twitterLicenseKeysAccessToken = ''
        self.twitterLicenseKeysAccessTokenSecret = ''

        self.service = u'Twitter'
        self.wiki_section = False
        self.wiki_type_of_text = u'Plain text'
        self.nb_bing_entry = 50
        self.language = 'English'
        self.createdInputs = list()

        self.dico_lang = {
            'English': 'en',
            'French': 'fr',
            'German': 'de',
            'Spanish': 'es',
            'Italian': 'it',
            'Dutch': 'nl'
        }

        

        # BASIC SETTING

        self.uuid = None
        self.loadSettings()
        self.uuid = getWidgetUuid(self)
        self.inputData = None

        self.infoBox = InfoBox(widget=self.controlArea)
        self.sendButton = SendButton(
            widget=self.controlArea,
            master=self,
            callback=self.sendData,
            infoBoxAttribute='infoBox'
        )

     
        # CONFIG BOXES
 
        optionsBox = OWGUI.widgetBox(self.controlArea, 'Options')
        OWGUI.separator(widget=self.controlArea, height=3)
        self.twitterBox = OWGUI.widgetBox(self.controlArea, 'Twitter')      
        self.wikipediaBox = OWGUI.widgetBox(self.controlArea, 'Wikipedia')
        self.bingBox = OWGUI.widgetBox(self.controlArea, 'Bing')
        OWGUI.separator(widget=self.controlArea, height=3)

        self.serviceBoxes = [self.twitterBox, self.wikipediaBox, self.bingBox]



        # OPTION BOX

        OWGUI.comboBox(
            widget              = optionsBox,
            master              = self,
            value               = 'service',
            items               = [u'Twitter', u'Wikipedia', u'Bing'],
            sendSelectedValue   = True,
            orientation         = 'horizontal',
            label               = u'Service:',
            labelWidth          = 160,
            callback            = self.set_service_box_visibility,
            tooltip             = (
                    u"Select a service."
            ),
        )

        OWGUI.separator(widget=optionsBox, height=3)

        OWGUI.comboBox(
            widget              = optionsBox,
            master              = self,
            value               = 'language',
            items               = ['English', 'French', 'German', 'Spanish', 'Italian', 'Dutch'],
            sendSelectedValue   = True,
            orientation         = 'horizontal',
            label               = u'Language:',
            labelWidth          = 160,
            callback            = self.sendButton.settingsChanged,
            tooltip             = (
                    u"Select language."
            ),
        )
        
        OWGUI.separator(widget=optionsBox, height=3)
        
        OWGUI.lineEdit(
            widget              = optionsBox,
            master              = self,
            value               = 'word_to_search',
            orientation         = 'horizontal',
            label               = u'Query:',
            callback            = self.sendButton.settingsChanged,
            labelWidth          = 160,
        )

        OWGUI.separator(widget=optionsBox, height=3)



        # TWITTER BOX

        OWGUI.spin(
            widget=self.twitterBox,          
            master=self, 
            value='nb_tweet',
            label='Number of tweets:',
            labelWidth=160,
            tooltip='Select a number of tweet.',
            callback= self.sendButton.settingsChanged,
            min= 1, 
            max= 3000, 
            step=1,
        )

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

        OWGUI.checkBox(
            widget              = self.twitterBox,
            master              = self,
            value               = 'include_RT',
            label               = u'Include retweets',
            labelWidth          = 160,
            callback            = self.sendButton.settingsChanged,
            tooltip             = (
                    u"Include re-tweets or not."
            ),
        )

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

        # TWITTER LICENSE KEY BOX

        OWGUI.checkBox(
            widget              = self.twitterBox,
            master              = self,
            value               = 'useTwitterLicenseKey',
            label               = u'Use license key',
            labelWidth          = 160,
            callback            = self.changeTwitterLicenseKeyBox,
            tooltip             = (
                    u"Use private license key or not."
            ),
        )

        self.twitterLicenseBox = OWGUI.indentedBox(self.twitterBox, sep=20)

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

        OWGUI.lineEdit(
            widget=self.twitterLicenseBox,
            master=self,
            value='twitterLicenseKeysConsumerKey',
            label=u'Consumer key: ',
            orientation='horizontal',
            callback=self.sendButton.settingsChanged,
            labelWidth=140,
            tooltip=(
                    u"Your twitter Consumer key."
            ),
        )

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

        OWGUI.lineEdit(
            widget=self.twitterLicenseBox,
            master=self,
            value='twitterLicenseKeysConsumerSecret',
            label=u'Consumer secret: ',
            orientation='horizontal',
            callback=self.sendButton.settingsChanged,
            labelWidth=140,
            tooltip=(
                    u"Your private twitter license key."
            ),
        )

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

        OWGUI.lineEdit(
            widget=self.twitterLicenseBox,
            master=self,
            value='twitterLicenseKeysAccessToken',
            label=u'Access token: ',
            orientation='horizontal',
            callback=self.sendButton.settingsChanged,
            labelWidth=140,
            tooltip=(
                    u"Your private twitter Access token."
            ),
        )

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

        OWGUI.lineEdit(
            widget=self.twitterLicenseBox,
            master=self,
            value='twitterLicenseKeysAccessTokenSecret',
            label=u'Access token secret: ',
            orientation='horizontal',
            callback=self.sendButton.settingsChanged,
            labelWidth=140,
            tooltip=(
                    u"Your private twitter access token secret."
            ),
        )
        OWGUI.separator(widget=self.twitterLicenseBox, height=3)




        # WIKIPEDIA BOX

        OWGUI.checkBox(
            widget              = self.wikipediaBox,
            master              = self,
            value               = 'wiki_section',
            label               = u'Segment into sections',
            labelWidth          = 160,
            callback            = self.sendButton.settingsChanged,
            tooltip             = (
                    u"Segment into Wikipedia sections:"
            ),
        )

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

        OWGUI.comboBox(
            widget              = self.wikipediaBox,
            master              = self,
            value               = 'wiki_type_of_text',
            items               = [u'Plain text', u'HTML'],
            sendSelectedValue   = True,
            orientation         = 'horizontal',
            label               = u'Output format:',
            labelWidth          = 160,
            callback            = self.sendButton.settingsChanged,
            tooltip             = (
                    u"Select type of text."
            ),
        )

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


        # BING BOX

        OWGUI.spin(
            widget=self.bingBox,          
            master=self, 
            value='nb_bing_entry',
            label='Number of results:',
            labelWidth=160,
            tooltip='Select a number of results.',
            callback= self.sendButton.settingsChanged,
            min= 1, 
            max= 1000, 
            step=1,
        )

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

        # CONFIG WIDGET
        
        OWGUI.rubber(self.controlArea)
        self.sendButton.draw()
        self.infoBox.draw()
        self.set_service_box_visibility()
        self.changeTwitterLicenseKeyBox()
        self.sendButton.sendIf()
        self.adjustSizeWithTimer()        
Ejemplo n.º 51
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, 'Itemset visualizer')

        self.inputs = [("Graph with Data", orange.Graph, self.setGraph),
                       ("Data Subset", orange.ExampleTable,
                        self.setExampleSubset)]
        self.outputs = [("Selected Data", ExampleTable),
                        ("Selected Graph", orange.Graph)]

        self.markerAttributes = []
        self.tooltipAttributes = []
        self.attributes = []
        self.autoSendSelection = False
        self.graphShowGrid = 1  # show gridlines in the graph

        self.markNConnections = 2
        self.markNumber = 0
        self.markProportion = 0
        self.markSearchString = ""
        self.markDistance = 2
        self.frSteps = 1
        self.hubs = 0
        self.color = 0
        self.nVertices = self.nMarked = self.nSelected = self.nHidden = self.nShown = self.nEdges = self.verticesPerEdge = self.edgesPerVertex = self.diameter = 0
        self.optimizeWhat = 1
        self.stopOptimization = 0

        self.loadSettings()

        self.visualize = None

        self.graph = OWIntemsetCanvas(self, self.mainArea, "Network")

        #start of content (right) area
        self.box = QVBoxLayout(self.mainArea)
        self.box.addWidget(self.graph)

        self.tabs = QTabWidget(self.controlArea)

        self.displayTab = QVGroupBox(self)
        self.mainTab = self.displayTab
        self.markTab = QVGroupBox(self)
        self.infoTab = QVGroupBox(self)
        self.protoTab = QVGroupBox(self)

        self.tabs.insertTab(self.displayTab, "Display")
        self.tabs.insertTab(self.markTab, "Mark")
        self.tabs.insertTab(self.infoTab, "Info")
        self.tabs.insertTab(self.protoTab, "Prototypes")
        OWGUI.separator(self.controlArea)

        self.optimizeBox = OWGUI.radioButtonsInBox(self.mainTab,
                                                   self,
                                                   "optimizeWhat", [],
                                                   "Optimize",
                                                   addSpace=False)
        OWGUI.button(self.optimizeBox, self, "Random", callback=self.random)
        self.frButton = OWGUI.button(self.optimizeBox,
                                     self,
                                     "Fruchterman Reingold",
                                     callback=self.fr,
                                     toggleButton=1)
        OWGUI.spin(self.optimizeBox,
                   self,
                   "frSteps",
                   1,
                   10000,
                   1,
                   label="Iterations: ")
        OWGUI.button(self.optimizeBox,
                     self,
                     "F-R Radial",
                     callback=self.frRadial)
        OWGUI.button(self.optimizeBox,
                     self,
                     "Circular Original",
                     callback=self.circularOriginal)
        OWGUI.button(self.optimizeBox,
                     self,
                     "Circular Crossing Reduction",
                     callback=self.circularCrossingReduction)

        self.showLabels = 0
        OWGUI.checkBox(self.mainTab,
                       self,
                       'showLabels',
                       'Show labels',
                       callback=self.showLabelsClick)

        self.labelsOnMarkedOnly = 0
        OWGUI.checkBox(self.mainTab,
                       self,
                       'labelsOnMarkedOnly',
                       'Show labels on marked nodes only',
                       callback=self.labelsOnMarked)

        OWGUI.separator(self.mainTab)

        OWGUI.button(self.mainTab,
                     self,
                     "Show degree distribution",
                     callback=self.showDegreeDistribution)
        OWGUI.button(self.mainTab,
                     self,
                     "Save network",
                     callback=self.saveNetwork)

        ib = OWGUI.widgetBox(self.markTab, "Info", addSpace=True)
        OWGUI.label(
            ib, self,
            "Vertices (shown/hidden): %(nVertices)i (%(nShown)i/%(nHidden)i)")
        OWGUI.label(
            ib, self,
            "Selected and marked vertices: %(nSelected)i - %(nMarked)i")

        ribg = OWGUI.radioButtonsInBox(self.markTab,
                                       self,
                                       "hubs", [],
                                       "Method",
                                       callback=self.setHubs,
                                       addSpace=True)
        OWGUI.appendRadioButton(ribg, self, "hubs",
                                "Mark vertices given in the input signal")

        OWGUI.appendRadioButton(ribg, self, "hubs",
                                "Find vertices which label contain")
        self.ctrlMarkSearchString = OWGUI.lineEdit(
            OWGUI.indentedBox(ribg),
            self,
            "markSearchString",
            callback=self.setSearchStringTimer,
            callbackOnType=True)
        self.searchStringTimer = QTimer(self)
        self.connect(self.searchStringTimer, SIGNAL("timeout()"), self.setHubs)

        OWGUI.appendRadioButton(ribg, self, "hubs",
                                "Mark neighbours of focused vertex")
        OWGUI.appendRadioButton(ribg, self, "hubs",
                                "Mark neighbours of selected vertices")
        ib = OWGUI.indentedBox(ribg, orientation=0)
        self.ctrlMarkDistance = OWGUI.spin(
            ib,
            self,
            "markDistance",
            0,
            100,
            1,
            label="Distance ",
            callback=(lambda h=2: self.setHubs(h)))

        self.ctrlMarkFreeze = OWGUI.button(ib,
                                           self,
                                           "&Freeze",
                                           value="graph.freezeNeighbours",
                                           toggleButton=True)

        OWGUI.widgetLabel(ribg, "Mark  vertices with ...")
        OWGUI.appendRadioButton(ribg, self, "hubs", "at least N connections")
        OWGUI.appendRadioButton(ribg, self, "hubs", "at most N connections")
        self.ctrlMarkNConnections = OWGUI.spin(
            OWGUI.indentedBox(ribg),
            self,
            "markNConnections",
            0,
            1000000,
            1,
            label="N ",
            callback=(lambda h=4: self.setHubs(h)))

        OWGUI.appendRadioButton(ribg, self, "hubs",
                                "more connections than any neighbour")
        OWGUI.appendRadioButton(ribg, self, "hubs",
                                "more connections than avg neighbour")

        OWGUI.appendRadioButton(ribg, self, "hubs", "most connections")
        ib = OWGUI.indentedBox(ribg)
        self.ctrlMarkNumber = OWGUI.spin(
            ib,
            self,
            "markNumber",
            0,
            1000000,
            1,
            label="Number of vertices" + ": ",
            callback=(lambda h=8: self.setHubs(h)))
        OWGUI.widgetLabel(ib, "(More vertices are marked in case of ties)")

        ib = QHGroupBox("Selection", self.markTab)
        btnM2S = OWGUI.button(ib, self, "", callback=self.markedToSelection)
        btnM2S.setPixmap(QPixmap(dlg_mark2sel))
        QToolTip.add(btnM2S, "Add Marked to Selection")
        btnS2M = OWGUI.button(ib, self, "", callback=self.markedFromSelection)
        btnS2M.setPixmap(QPixmap(dlg_sel2mark))
        QToolTip.add(btnS2M, "Remove Marked from Selection")
        btnSIM = OWGUI.button(ib, self, "", callback=self.setSelectionToMarked)
        btnSIM.setPixmap(QPixmap(dlg_selIsmark))
        QToolTip.add(btnSIM, "Set Selection to Marked")

        self.hideBox = QHGroupBox("Hide vertices", self.markTab)
        btnSEL = OWGUI.button(self.hideBox,
                              self,
                              "",
                              callback=self.hideSelected)
        btnSEL.setPixmap(QPixmap(dlg_selected))
        QToolTip.add(btnSEL, "Selected")
        btnUN = OWGUI.button(self.hideBox,
                             self,
                             "",
                             callback=self.hideAllButSelected)
        btnUN.setPixmap(QPixmap(dlg_unselected))
        QToolTip.add(btnUN, "Unselected")
        OWGUI.button(self.hideBox, self, "Show", callback=self.showAllNodes)

        T = OWToolbars.NavigateSelectToolbar
        self.zoomSelectToolbar = OWToolbars.NavigateSelectToolbar(
            self,
            self.controlArea,
            self.graph,
            self.autoSendSelection,
            buttons=(T.IconZoom, T.IconZoomExtent, T.IconZoomSelection,
                     ("", "", "", None, None, 0, "navigate"), T.IconPan,
                     ("Move selection", "buttonMoveSelection",
                      "activateMoveSelection", QPixmap(OWToolbars.dlg_select),
                      Qt.arrowCursor, 1, "select"), T.IconRectangle,
                     T.IconPolygon, ("", "", "", None, None, 0,
                                     "select"), T.IconSendSelection))

        ib = OWGUI.widgetBox(self.infoTab, "General", addSpace=True)
        OWGUI.label(ib, self, "Number of vertices: %(nVertices)i")
        OWGUI.label(ib, self, "Number of edges: %(nEdges)i")
        OWGUI.label(ib, self, "Vertices per edge: %(verticesPerEdge).2f")
        OWGUI.label(ib, self, "Edges per vertex: %(edgesPerVertex).2f")
        OWGUI.label(ib, self, "Diameter: %(diameter)i")

        self.insideView = 0
        self.insideViewNeighbours = 2
        self.insideSpin = OWGUI.spin(self.protoTab,
                                     self,
                                     "insideViewNeighbours",
                                     1,
                                     6,
                                     1,
                                     label="Inside view (neighbours): ",
                                     checked="insideView",
                                     checkCallback=self.insideview,
                                     callback=self.insideviewneighbours)
        #OWGUI.button(self.protoTab, self, "Clustering", callback=self.clustering)
        OWGUI.button(self.protoTab, self, "Collapse", callback=self._collapse)

        self.icons = self.createAttributeIconDict()
        self.setHubs()

        self.resize(850, 700)
Ejemplo n.º 52
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)
    def defineGUI(self):

        self.sBox = OWGUI.widgetBox(self.controlArea, "Execution environment")
        itms = [e[0] for e in self.execEnvs]
        OWGUI.radioButtonsInBox(self.sBox, self, "execEnv", btnLabels=itms)

        boxGrid = OWGUI.widgetBox(self.controlArea,'Initial Point for the Optimizer')
        OWGUI.checkBox(boxGrid, self, 'UseGridSearch','Use Grid-Search',  tooltip='Use Grid-Search to find the best initial point to start the optimization.<br>If not checked, the midrange point will be used as optimization initial point.')
        OWGUI.spin(boxGrid, self, 'nInnerPoints', 1, 100, step=1, label='    Number of inner points:', tooltip='Number of points to break down each variable to evaluate the initial point.<br>It will evaluate nInnerPoints^nOptimizedVars')

        OWGUI.separator(self.controlArea)

        self.sBox = OWGUI.widgetBox(self.controlArea, "Sampling  Method")
        itms = [e[0] for e in self.SMethods]
        self.comboDistItems = ["Continuous","Power2","By Step","Specific Values"]        
        OWGUI.radioButtonsInBox(self.sBox, self, "SMethod", btnLabels=itms)

        hBox = OWGUI.widgetBox(OWGUI.indentedBox(self.sBox))
        #QWidget(hBox).setFixedSize(19, 8)
        OWGUI.spin(hBox, self, 'nFolds', 2, 100, step=1, label='Number of Folds:  ')


        OWGUI.separator(self.controlArea)

        box2 = OWGUI.widgetBox(self.controlArea,'Evaluation Method')
        width = 150
        itms = [e[0] for e in self.CMethods]
        OWGUI.comboBox(box2, self, 'CMethod', items=itms, label='For Classifiers:', labelWidth=width, orientation='horizontal',
                       tooltip='Method used for evaluation in case of classifiers.')
        itms = [e[0] for e in self.RMethods]
        OWGUI.comboBox(box2, self, 'RMethod', items=itms, label='For Regressors:', labelWidth=width, 
                       orientation='horizontal', tooltip='Method used for evaluation in case of regressors.')

        OWGUI.separator(self.controlArea)
        OWGUI.button(self.controlArea, self,"&Reload Defaults ", callback=self.reloadDefaults)
        OWGUI.separator(self.controlArea)


        #OWGUI.separator(self.controlArea, height=24)

        infoBox = OWGUI.widgetBox(self.controlArea, "Optimizer status")
        self.infoStatus = OWGUI.label(infoBox,self,'Waiting for inputs...')                    
        self.infoPars = OWGUI.label(infoBox,self,'')
        self.infoRes = OWGUI.label(infoBox,self,'')
        OWGUI.label(infoBox,self,'')
        self.infoErr = OWGUI.label(infoBox,self,'')
        OWGUI.separator(self.controlArea)
        OWGUI.button(self.controlArea, self,"&Apply Settings ", callback=self.optimizeParameters)
 

        # Main area GUI
        import sip
        sip.delete(self.mainArea.layout())
        self.mainLayout = QGridLayout(self.mainArea)

        mainRight = OWGUI.widgetBox(self.mainArea, "Parameters Configuration")
        mainRight.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))

        self.paramsTable = OWGUI.table(self.mainArea, rows = 0, columns = 0, selectionMode = QTableWidget.MultiSelection, addToLayout = 0)
        #self.paramsTable.setLeftMargin(0)
        self.paramsTable.verticalHeader().hide()
        self.paramsTable.setSelectionMode(QTableWidget.NoSelection)
        self.paramsTable.setColumnCount(len(self.paramsNames))

        #for i, m in enumerate(self.paramsNames):
        #    self.paramsTable.setColumnStretchable(i, 0)
        #    header.setLabel(i, m)
        self.paramsTable.setHorizontalHeaderLabels(self.paramsNames)
        #self.mainLayout.setColumnStretch(1, 100)
        #self.mainLayout.setRowStretch(2, 100)
        self.mainLayout.addWidget(self.paramsTable, 0, 0, 1,2)
        self.mainLayout.addWidget(OWGUI.label(mainRight,self,'Red - Parameter selected to be optimized\r\nGreen - Parameter optimized\r\nBlack - Parameter will not be optimized'),1,0) 
        self.mainLayout.addWidget(OWGUI.label(mainRight,self,'N_EX - Number of Examples in dataset\r\nN_ATTR - Number of attributes in dataset'),1,1)
         
        self.adjustSize()
        self.create()
    def __init__(self, parent = None, signalManager = None, name = "Select data"):
        OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0)  #initialize base class

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

        self.inputs = [("Examples", ExampleTable, self.setData)]
        self.outputs = [("Reduced Example Table", ExampleTable,
                         Default + Single),
                        ("ExampleTable Attributes", ExampleTable, NonDefault)]

        self.settingsList += self.measuresAttrs
        self.logORIdx = self.measuresShort.index("log OR")

        self.nDecimals = 3
        self.reliefK = 10
        self.reliefN = 20
        self.nIntervals = 4
        self.sortBy = 0
        self.selectMethod = 3
        self.nSelected = 5
        self.autoApply = True
        self.showDistributions = 1
        self.distColorRgb = (220, 220, 220, 255)
        self.distColor = QColor(*self.distColorRgb)
        self.minmax = {}

        self.data = None

        for meas in self.measuresAttrs:
            setattr(self, meas, True)

        self.loadSettings()

        labelWidth = 80

        box = OWGUI.widgetBox(self.controlArea, "Measures", addSpace=True)
        for meas, valueName in zip(self.measures, self.measuresAttrs):
            if valueName == "computeReliefF":
                hbox = OWGUI.widgetBox(box, orientation="horizontal")
                OWGUI.checkBox(hbox,
                               self,
                               valueName,
                               meas,
                               callback=self.measuresChanged)
                hbox.layout().addSpacing(5)
                smallWidget = OWGUI.SmallWidgetLabel(
                    hbox,
                    pixmap=1,
                    box="ReliefF Parameters",
                    tooltip="Show ReliefF parameters")
                OWGUI.spin(smallWidget.widget,
                           self,
                           "reliefK",
                           1,
                           20,
                           label="Neighbours",
                           labelWidth=labelWidth,
                           orientation=0,
                           callback=self.reliefChanged,
                           callbackOnReturn=True)
                OWGUI.spin(smallWidget.widget,
                           self,
                           "reliefN",
                           20,
                           100,
                           label="Examples",
                           labelWidth=labelWidth,
                           orientation=0,
                           callback=self.reliefChanged,
                           callbackOnReturn=True)
                OWGUI.button(smallWidget.widget,
                             self,
                             "Load defaults",
                             callback=self.loadReliefDefaults)
                OWGUI.rubber(hbox)
            else:
                OWGUI.checkBox(box,
                               self,
                               valueName,
                               meas,
                               callback=self.measuresChanged)
        OWGUI.separator(box)

        OWGUI.comboBox(
            box,
            self,
            "sortBy",
            label="Sort by" + "  ",
            items=["No Sorting", "Attribute Name", "Number of Values"] +
            self.measures,
            orientation=0,
            valueType=int,
            callback=self.sortingChanged)

        box = OWGUI.widgetBox(self.controlArea, "Discretization")
        OWGUI.spin(box,
                   self,
                   "nIntervals",
                   2,
                   20,
                   label="Intervals: ",
                   orientation=0,
                   callback=self.discretizationChanged,
                   callbackOnReturn=True)

        box = OWGUI.widgetBox(self.controlArea, "Precision", addSpace=True)
        OWGUI.spin(box,
                   self,
                   "nDecimals",
                   1,
                   6,
                   label="No. of decimals: ",
                   orientation=0,
                   callback=self.decimalsChanged)

        OWGUI.rubber(self.controlArea)

        box = OWGUI.widgetBox(self.controlArea, "Distributions", addSpace=True)
        self.cbShowDistributions = OWGUI.checkBox(
            box,
            self,
            "showDistributions",
            'Visualize values',
            callback=self.cbShowDistributions)
        colBox = OWGUI.indentedBox(box, orientation="horizontal")
        OWGUI.widgetLabel(colBox, "Color: ")
        self.colButton = OWGUI.toolButton(colBox,
                                          self,
                                          self.changeColor,
                                          width=20,
                                          height=20,
                                          debuggingEnabled=0)
        OWGUI.rubber(colBox)

        selMethBox = OWGUI.radioButtonsInBox(
            self.controlArea,
            self,
            "selectMethod", ["None", "All", "Manual", "Best ranked"],
            box="Select attributes",
            callback=self.selectMethodChanged)
        OWGUI.spin(OWGUI.indentedBox(selMethBox),
                   self,
                   "nSelected",
                   1,
                   100,
                   label="No. selected" + "  ",
                   orientation=0,
                   callback=self.nSelectedChanged)

        OWGUI.separator(selMethBox)

        applyButton = OWGUI.button(selMethBox,
                                   self,
                                   "Commit",
                                   callback=self.apply)
        autoApplyCB = OWGUI.checkBox(selMethBox, self, "autoApply",
                                     "Commit automatically")
        OWGUI.setStopper(self, applyButton, autoApplyCB, "dataChanged",
                         self.apply)

        self.table = QTableWidget()
        self.mainArea.layout().addWidget(self.table)

        self.table.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.table.setSelectionMode(QAbstractItemView.MultiSelection)
        self.table.verticalHeader().setResizeMode(QHeaderView.ResizeToContents)
        self.table.setItemDelegate(RankItemDelegate(self, self.table))

        self.topheader = self.table.horizontalHeader()
        self.topheader.setSortIndicatorShown(1)
        self.topheader.setHighlightSections(0)

        self.setMeasures()
        self.resetInternals()

        self.connect(self.table.horizontalHeader(),
                     SIGNAL("sectionClicked(int)"), self.headerClick)
        self.connect(self.table, SIGNAL("clicked (const QModelIndex&)"),
                     self.selectItem)
        self.resize(690, 500)
        self.updateColor()