def __init__(self,parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "Calibration Plot", 1)

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

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

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

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

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

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

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

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

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

        ## settings tab
        OWGUI.hSlider(self.settingsTab, self, 'CalibrationCurveWidth', box='Calibration Curve Width', minValue=1, maxValue=9, step=1, callback=self.setCalibrationCurveWidth, ticks=1)
        OWGUI.checkBox(self.settingsTab, self, 'ShowDiagonal', 'Show Diagonal Line', tooltip='', callback=self.setShowDiagonal)
        OWGUI.checkBox(self.settingsTab, self, 'ShowRugs', 'Show Rugs', tooltip='', callback=self.setShowRugs)
        self.settingsTab.layout().addStretch(100)
Ejemplo n.º 2
0
    def __init__(self,parent = None, signalManager = None):
        OWClassificationTreeViewer.__init__(self, parent, signalManager, 'I&nteractive Tree Builder')
        self.inputs = [("Data", ExampleTable, self.setData),
                       ("Tree Learner", orange.Learner, self.setLearner)]
        
        self.outputs = [("Data", ExampleTable),
                        ("Classifier", Orange.classification.tree.TreeClassifier),
                        ("Tree Learner", orange.Learner)]

        self.attridx = 0
        self.cutoffPoint = 0.0
        self.targetClass = 0
        self.loadSettings()

        self.data = None
        self.treeLearner = None
        self.tree = None
        self.learner = None
        
        new_controlArea = OWGUI.widgetBox(self.leftWidgetPart, orientation="vertical", margin=4, addToLayout=False)
        self.leftWidgetPart.layout().insertWidget(0, new_controlArea)
        self.leftWidgetPart.layout().removeWidget(self.controlArea)

        tabWidget = OWGUI.tabWidget(new_controlArea)
        buildTab = OWGUI.createTabPage(tabWidget, "Build")
#        new_controlArea.layout().addWidget(self.controlArea)

        self.old_controlArea = self.controlArea
        displayTab = OWGUI.createTabPage(tabWidget, "Display", self.controlArea)
        self.controlArea = new_controlArea

        self.old_controlArea.layout().removeWidget(self.infBox)
        buildTab.layout().insertWidget(0, self.infBox)
        
        OWGUI.separator(buildTab)
        box = OWGUI.widgetBox(buildTab, "Split selection")
#        OWGUI.widgetLabel(box, "Split By:")
        self.attrsCombo = OWGUI.comboBox(box, self, 'attridx', orientation="horizontal", callback=self.cbAttributeSelected)
        self.cutoffEdit = OWGUI.lineEdit(box, self, 'cutoffPoint', label = 'Cut off point: ', orientation='horizontal', validator=QDoubleValidator(self))
        OWGUI.button(box, self, "Split", callback=self.btnSplitClicked)

        OWGUI.separator(buildTab)
        box = OWGUI.widgetBox(buildTab, "Prune or grow tree")
        self.btnPrune = OWGUI.button(box, self, "Cut", callback = self.btnPruneClicked, disabled = 1)
        self.btnBuild = OWGUI.button(box, self, "Build", callback = self.btnBuildClicked)

        OWGUI.rubber(buildTab)

        self.activateLoadedSettings()
Ejemplo n.º 3
0
    def __init__(self,parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "Sieve Multigram", wantGraph = True, wantStatusBar = True)

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

        #add a graph widget
        self.graph = OWSieveMultigramGraph(self.mainArea)
        self.graph.useAntialiasing = 1
        self.mainArea.layout().addWidget(self.graph)

        #set default settings
        self.graphCanvasColor = str(QColor(Qt.white).name())
        self.data = None
        self.graph.lineWidth = 3
        self.graph.minPearson = 2
        self.graph.maxPearson = 10
        self.showAllAttributes = 0

        # add a settings dialog and initialize its values
        self.loadSettings()

        #GUI
        # add a settings dialog and initialize its values
        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main")
        self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings")

        #add controls to self.controlArea widget
        self.createShowHiddenLists(self.GeneralTab, callback = self.updateGraph)

        OWGUI.button(self.GeneralTab, self, "Find Interesting Attr.", callback = self.interestingSubsetSelection, debuggingEnabled = 0)

        OWGUI.hSlider(self.SettingsTab, self, 'graph.lineWidth', box = 1, label = "Max line width:", minValue=1, maxValue=10, step=1, callback = self.updateGraph)
        residualBox = OWGUI.widgetBox(self.SettingsTab, "Attribute independence (Pearson residuals)")
        OWGUI.hSlider(residualBox, self, 'graph.maxPearson', label = "Max residual:", minValue=4, maxValue=12, step=1, callback = self.updateGraph)
        OWGUI.hSlider(residualBox, self, 'graph.minPearson', label = "Min residual:", minValue=0, maxValue=4, step=1, callback = self.updateGraph, tooltip = "The minimal absolute residual value that will be shown in graph")
        self.SettingsTab.layout().addStretch(100)

        self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile)
        self.resize(800, 600)
    def __init__(self, parent=None, signalManager=None, name='Correspondence Analysis', **kwargs):
        OWWidget.__init__(self, parent, signalManager, name, *kwargs)
        self.callbackDeposit = []

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

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

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


        self.colorSettings = None

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

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

#        layout.addWidget(self.tabsMain)

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

        self.icons = self.createAttributeIconDict()

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

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

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

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

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

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

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


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

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

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

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


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

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

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

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

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

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

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

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

        self.resize(700, 800)
Ejemplo n.º 5
0
    def __init__(self,parent=None, signalManager = None, name = "Linear Projection", graphClass = None):
        OWVisWidget.__init__(self, parent, signalManager, name, TRUE)

        self.inputs = [("Data", ExampleTable, self.setData, Default),
                       ("Data Subset", ExampleTable, self.setSubsetData),
                       ("Features", AttributeList, self.setShownAttributes),
                       ("Evaluation Results", orngTest.ExperimentResults, self.setTestResults),
                       ("VizRank Learner", orange.Learner, self.setVizRankLearner),
                       ("Distances", orange.SymMatrix, self.setDistances)]
        self.outputs = [("Selected Data", ExampleTable), ("Other Data", ExampleTable), ("Features", AttributeList), ("FreeViz Learner", orange.Learner)]

        # local variables
        self.showAllAttributes = 0
        self.valueScalingType = 0
        self.autoSendSelection = 1
        self.data = None
        self.subsetData = None
        self.distances = None
        self.toolbarSelection = 0
        self.classificationResults = None
        self.outlierValues = None
        self.attributeSelectionList = None
        self.colorSettings = None
        self.selectedSchemaIndex = 0
        self.addProjectedPositions = 0
        self.resetAnchors = 0

        #add a graph widget
        if graphClass:
            self.graph = graphClass(self, self.mainArea, name)
        else:
            self.graph = OWLinProjGraph(self, self.mainArea, name)
        self.mainArea.layout().addWidget(self.graph)

        # graph variables
        self.graph.manualPositioning = 0
        self.graph.hideRadius = 0
        self.graph.showAnchors = 1
        self.graph.jitterContinuous = 0
        self.graph.showProbabilities = 0
        self.graph.useDifferentSymbols = 0
        self.graph.useDifferentColors = 1
        self.graph.tooltipKind = 0
        self.graph.tooltipValue = 0
        self.graph.scaleFactor = 1.0
        self.graph.squareGranularity = 3
        self.graph.spaceBetweenCells = 1
        self.graph.showAxisScale = 0
        self.graph.showValueLines = 0
        self.graph.valueLineLength = 5

        #load settings
        self.loadSettings()

##        # cluster dialog
##        self.clusterDlg = ClusterOptimization(self, self.signalManager, self.graph, name)
##        self.graph.clusterOptimization = self.clusterDlg

        # optimization dialog
        if name.lower() == "radviz":
            self.vizrank = OWVizRank(self, self.signalManager, self.graph, orngVizRank.RADVIZ, name)
            self.connect(self.graphButton, SIGNAL("clicked()"), self.saveToFile)
        elif name.lower() == "polyviz":
            self.vizrank = OWVizRank(self, self.signalManager, self.graph, orngVizRank.POLYVIZ, name)
            self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile)
        else:
            self.vizrank = OWVizRank(self, self.signalManager, self.graph, orngVizRank.LINEAR_PROJECTION, name)
            self.connect(self.graphButton, SIGNAL("clicked()"), self.saveToFile)

        self.optimizationDlg = self.vizrank  # for backward compatibility

        self.graph.normalizeExamples = (name.lower() == "radviz")       # ignore settings!! if we have radviz then normalize, otherwise not.

        #GUI
        # add a settings dialog and initialize its values

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

        #add controls to self.controlArea widget
        self.createShowHiddenLists(self.GeneralTab, callback = self.updateGraphAndAnchors)

        self.optimizationButtons = OWGUI.widgetBox(self.GeneralTab, "Optimization Dialogs", orientation = "horizontal")
        self.vizrankButton = OWGUI.button(self.optimizationButtons, self, "VizRank", callback = self.vizrank.reshow, tooltip = "Opens VizRank dialog, where you can search for interesting projections with different subsets of attributes.", debuggingEnabled = 0)
        self.wdChildDialogs = [self.vizrank]    # used when running widget debugging

        # freeviz dialog
        if name.lower() in ["linear projection", "radviz"]:
            self.freeVizDlg = FreeVizOptimization(self, self.signalManager, self.graph, name)
            self.wdChildDialogs.append(self.freeVizDlg)
            self.freeVizDlgButton = OWGUI.button(self.optimizationButtons, self, "FreeViz", callback = self.freeVizDlg.reshow, tooltip = "Opens FreeViz dialog, where the position of attribute anchors is optimized so that class separation is improved", debuggingEnabled = 0)
            if name.lower() == "linear projection":
                self.freeVizLearner = FreeVizLearner(self.freeVizDlg)
                self.send("FreeViz Learner", self.freeVizLearner)

##        self.clusterDetectionDlgButton = OWGUI.button(self.optimizationButtons, self, "Cluster", callback = self.clusterDlg.reshow, debuggingEnabled = 0)
##        self.vizrankButton.setMaximumWidth(63)
##        self.clusterDetectionDlgButton.setMaximumWidth(63)
##        self.freeVizDlgButton.setMaximumWidth(63)
##        self.connect(self.clusterDlg.startOptimizationButton , SIGNAL("clicked()"), self.optimizeClusters)
##        self.connect(self.clusterDlg.resultList, SIGNAL("selectionChanged()"),self.showSelectedCluster)

        self.zoomSelectToolbar = OWToolbars.ZoomSelectToolbar(self, self.GeneralTab, self.graph, self.autoSendSelection)
        self.graph.autoSendSelectionCallback = self.selectionChanged
        self.connect(self.zoomSelectToolbar.buttonSendSelections, SIGNAL("clicked()"), self.sendSelections)

        # ####################################
        # SETTINGS TAB
        # #####
        self.extraTopBox = OWGUI.widgetBox(self.SettingsTab, orientation = "vertical")
        self.extraTopBox.hide()

        box = OWGUI.widgetBox(self.SettingsTab, "Point Properties")
        OWGUI.hSlider(box, self, 'graph.pointWidth', label = "Size: ", minValue=1, maxValue=20, step=1, callback = self.updateGraph)
        OWGUI.hSlider(box, self, 'graph.alphaValue', label = "Transparency: ", minValue=0, maxValue=255, step=10, callback = self.updateGraph)

        box = OWGUI.widgetBox(self.SettingsTab, "Jittering Options")
        OWGUI.comboBoxWithCaption(box, self, "graph.jitterSize", 'Jittering size (% of range):', callback = self.resetGraphData, items = self.jitterSizeNums, sendSelectedValue = 1, valueType = float)
        OWGUI.checkBox(box, self, 'graph.jitterContinuous', 'Jitter continuous attributes', callback = self.resetGraphData, tooltip = "Does jittering apply also on continuous attributes?")

        box = OWGUI.widgetBox(self.SettingsTab, "Scaling Options")
        OWGUI.qwtHSlider(box, self, "graph.scaleFactor", label = 'Inflate points by: ', minValue=1.0, maxValue= 10.0, step=0.1, callback = self.updateGraph, tooltip="If points lie too much together you can expand their position to improve perception", maxWidth = 90)

        box = OWGUI.widgetBox(self.SettingsTab, "General Graph Settings")
        #OWGUI.checkBox(box, self, 'graph.normalizeExamples', 'Normalize examples', callback = self.updateGraph)
        OWGUI.checkBox(box, self, 'graph.showLegend', 'Show legend', callback = self.updateGraph)
        bbox = OWGUI.widgetBox(box, orientation = "horizontal")
        OWGUI.checkBox(bbox, self, 'graph.showValueLines', 'Show value lines  ', callback = self.updateGraph)
        OWGUI.qwtHSlider(bbox, self, 'graph.valueLineLength', minValue=1, maxValue=10, step=1, callback = self.updateGraph, showValueLabel = 0)
        OWGUI.checkBox(box, self, 'graph.useDifferentSymbols', 'Use different symbols', callback = self.updateGraph, tooltip = "Show different class values using different symbols")
        OWGUI.checkBox(box, self, 'graph.useDifferentColors', 'Use different colors', callback = self.updateGraph, tooltip = "Show different class values using different colors")
        OWGUI.checkBox(box, self, 'graph.showFilledSymbols', 'Show filled symbols', callback = self.updateGraph)
        OWGUI.checkBox(box, self, 'graph.useAntialiasing', 'Use antialiasing', callback = self.updateGraph)
        wbox = OWGUI.widgetBox(box, orientation = "horizontal")
        OWGUI.checkBox(wbox, self, 'graph.showProbabilities', 'Show probabilities'+'  ', callback = self.updateGraph, tooltip = "Show a background image with class probabilities")
        smallWidget = OWGUI.SmallWidgetLabel(wbox, pixmap = 1, box = "Advanced settings", tooltip = "Show advanced settings")
        OWGUI.rubber(wbox)

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

        box = OWGUI.widgetBox(self.SettingsTab, "Tooltips Settings")
        OWGUI.comboBox(box, self, "graph.tooltipKind", items = ["Show line tooltips", "Show visible attributes", "Show all attributes"], callback = self.updateGraph)
        OWGUI.comboBox(box, self, "graph.tooltipValue", items = ["Tooltips show data values", "Tooltips show spring values"], callback = self.updateGraph, tooltip = "Do you wish that tooltips would show you original values of visualized attributes or the 'spring' values (values between 0 and 1). \nSpring values are scaled values that are used for determining the position of shown points. Observing these values will therefore enable you to \nunderstand why the points are placed where they are.")

        box = OWGUI.widgetBox(self.SettingsTab, "Auto Send Selected Data When...")
        OWGUI.checkBox(box, self, 'autoSendSelection', 'Adding/Removing selection areas', callback = self.selectionChanged, tooltip = "Send selected data whenever a selection area is added or removed")
        OWGUI.checkBox(box, self, 'graph.sendSelectionOnUpdate', 'Moving/Resizing selection areas', tooltip = "Send selected data when a user moves or resizes an existing selection area")
        OWGUI.comboBox(box, self, "addProjectedPositions", items = ["Do not modify the domain", "Append projection as attributes", "Append projection as meta attributes"], callback = self.sendSelections)
        self.selectionChanged()

        box = OWGUI.widgetBox(smallWidget.widget, orientation = "horizontal")
        OWGUI.widgetLabel(box, "Granularity:  ")
        OWGUI.hSlider(box, self, 'graph.squareGranularity', minValue=1, maxValue=10, step=1, callback = self.updateGraph)

        box = OWGUI.widgetBox(smallWidget.widget, orientation = "horizontal")
        OWGUI.checkBox(box, self, 'graph.spaceBetweenCells', 'Show space between cells', callback = self.updateGraph)

        self.SettingsTab.layout().addStretch(100)

        self.icons = self.createAttributeIconDict()
        self.debugSettings = ["hiddenAttributes", "shownAttributes"]

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

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

        self.cbShowAllAttributes()      # update list boxes based on the check box value

        self.resize(900, 700)
Ejemplo n.º 6
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.º 7
0
    def __init__(self, parent=None, signalManager=None, name='ScatterPlot 3D'):
        OWWidget.__init__(self, parent, signalManager, name, True)

        self.inputs = [('Data', ExampleTable, self.set_data, Default), ('Subset Examples', ExampleTable, self.set_subset_data)]
        self.outputs = [('Selected Data', ExampleTable), ('Other Data', ExampleTable)]

        self.x_attr = ''
        self.y_attr = ''
        self.z_attr = ''

        self.x_attr_discrete = False
        self.y_attr_discrete = False
        self.z_attr_discrete = False

        self.color_attr = ''
        self.size_attr = ''
        self.symbol_attr = ''
        self.label_attr = ''

        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.main_tab = OWGUI.createTabPage(self.tabs, 'Main')
        self.settings_tab = OWGUI.createTabPage(self.tabs, 'Settings', canScroll=True)

        self.x_attr_cb = OWGUI.comboBox(self.main_tab, self, 'x_attr', box='X-axis attribute',
            tooltip='Attribute to plot on X axis.',
            callback=self.on_axis_change,
            sendSelectedValue=1,
            valueType=str)

        self.y_attr_cb = OWGUI.comboBox(self.main_tab, self, 'y_attr', box='Y-axis attribute',
            tooltip='Attribute to plot on Y axis.',
            callback=self.on_axis_change,
            sendSelectedValue=1,
            valueType=str)

        self.z_attr_cb = OWGUI.comboBox(self.main_tab, self, 'z_attr', box='Z-axis attribute',
            tooltip='Attribute to plot on Z axis.',
            callback=self.on_axis_change,
            sendSelectedValue=1,
            valueType=str)

        self.color_attr_cb = OWGUI.comboBox(self.main_tab, self, 'color_attr', box='Point color',
            tooltip='Attribute to use for point color',
            callback=self.on_axis_change,
            sendSelectedValue=1,
            valueType=str)

        # Additional point properties (labels, size, symbol).
        additional_box = OWGUI.widgetBox(self.main_tab, 'Additional Point Properties')
        self.size_attr_cb = OWGUI.comboBox(additional_box, self, 'size_attr', label='Point size:',
            tooltip='Attribute to use for point size',
            callback=self.on_axis_change,
            indent=10,
            emptyString='(Same size)',
            sendSelectedValue=1,
            valueType=str)

        self.symbol_attr_cb = OWGUI.comboBox(additional_box, self, 'symbol_attr', label='Point symbol:',
            tooltip='Attribute to use for point symbol',
            callback=self.on_axis_change,
            indent=10,
            emptyString='(Same symbol)',
            sendSelectedValue=1,
            valueType=str)

        self.label_attr_cb = OWGUI.comboBox(additional_box, self, 'label_attr', label='Point label:',
            tooltip='Attribute to use for pointLabel',
            callback=self.on_axis_change,
            indent=10,
            emptyString='(No labels)',
            sendSelectedValue=1,
            valueType=str)

        self.plot = ScatterPlot(self)
        self.vizrank = OWVizRank(self, self.signalManager, self.plot, orngVizRank.SCATTERPLOT3D, 'ScatterPlot3D')
        self.optimization_dlg = self.vizrank

        self.optimization_buttons = OWGUI.widgetBox(self.main_tab, 'Optimization dialogs', orientation='horizontal')
        OWGUI.button(self.optimization_buttons, self, 'VizRank', callback=self.vizrank.reshow,
            tooltip='Opens VizRank dialog, where you can search for interesting projections with different subsets of attributes',
            debuggingEnabled=0)

        box = OWGUI.widgetBox(self.settings_tab, 'Point properties')
        OWGUI.hSlider(box, self, 'plot.symbol_scale', label='Symbol scale',
            minValue=1, maxValue=20,
            tooltip='Scale symbol size',
            callback=self.on_checkbox_update)

        OWGUI.hSlider(box, self, 'plot.alpha_value', label='Transparency',
            minValue=10, maxValue=255,
            tooltip='Point transparency value',
            callback=self.on_checkbox_update)
        OWGUI.rubber(box)

        box = OWGUI.widgetBox(self.settings_tab, 'Jittering Options')
        self.jitter_size_combo = OWGUI.comboBox(box, self, 'plot.jitter_size', label='Jittering size (% of size)'+'  ',
            orientation='horizontal',
            callback=self.handleNewSignals,
            items=self.jitter_sizes,
            sendSelectedValue=1,
            valueType=float)
        OWGUI.checkBox(box, self, 'plot.jitter_continuous', 'Jitter continuous attributes',
            callback=self.handleNewSignals,
            tooltip='Does jittering apply also on continuous attributes?')

        self.dark_theme = False

        box = OWGUI.widgetBox(self.settings_tab, 'General settings')
        OWGUI.checkBox(box, self, 'plot.show_x_axis_title',   'X axis title',   callback=self.on_checkbox_update)
        OWGUI.checkBox(box, self, 'plot.show_y_axis_title',   'Y axis title',   callback=self.on_checkbox_update)
        OWGUI.checkBox(box, self, 'plot.show_z_axis_title',   'Z axis title',   callback=self.on_checkbox_update)
        OWGUI.checkBox(box, self, 'plot.show_legend',         'Show legend',    callback=self.on_checkbox_update)
        OWGUI.checkBox(box, self, 'plot.use_2d_symbols',      '2D symbols',     callback=self.update_plot)
        OWGUI.checkBox(box, self, 'dark_theme',               'Dark theme',     callback=self.on_theme_change)
        OWGUI.checkBox(box, self, 'plot.show_grid',           'Show grid',      callback=self.on_checkbox_update)
        OWGUI.checkBox(box, self, 'plot.show_axes',           'Show axes',      callback=self.on_checkbox_update)
        OWGUI.checkBox(box, self, 'plot.show_chassis',        'Show chassis',   callback=self.on_checkbox_update)
        OWGUI.checkBox(box, self, 'plot.hide_outside',        'Hide outside',   callback=self.on_checkbox_update)
        OWGUI.rubber(box)

        box = OWGUI.widgetBox(self.settings_tab, 'Mouse', orientation = "horizontal")
        OWGUI.hSlider(box, self, 'plot.mouse_sensitivity', label='Sensitivity', minValue=1, maxValue=10,
                      step=1,
                      callback=self.plot.update,
                      tooltip='Change mouse sensitivity')

        gui = self.plot.gui
        buttons = gui.default_zoom_select_buttons
        buttons.insert(2, (gui.UserButton, 'Rotate', 'state', ROTATING, None, 'Dlg_undo'))
        self.zoom_select_toolbar = gui.zoom_select_toolbar(self.main_tab, buttons=buttons)
        self.connect(self.zoom_select_toolbar.buttons[gui.SendSelection], SIGNAL("clicked()"), self.send_selection)
        self.connect(self.zoom_select_toolbar.buttons[gui.Zoom], SIGNAL("clicked()"), self.plot.unselect_all_points)
        self.plot.set_selection_behavior(OWPlot.ReplaceSelection)

        self.tooltip_kind = TooltipKind.NONE
        box = OWGUI.widgetBox(self.settings_tab, 'Tooltips Settings')
        OWGUI.comboBox(box, self, 'tooltip_kind', items = [
            'Don\'t Show Tooltips', 'Show Visible Attributes', 'Show All Attributes'])

        self.plot.mouseover_callback = self.mouseover_callback

        self.main_tab.layout().addStretch(100)
        self.settings_tab.layout().addStretch(100)

        self.mainArea.layout().addWidget(self.plot)
        self.connect(self.graphButton, SIGNAL('clicked()'), self.plot.save_to_file)

        self.loadSettings()
        self.plot.update_camera()
        self.on_theme_change()

        self.data = None
        self.subset_data = None
        self.resize(1100, 600)
Ejemplo n.º 8
0
    def __init__(self, parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "Time Data Visualizer", TRUE)

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

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

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

        self.data = None
        self.subsetData = None

        #load settings
        self.loadSettings()

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

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

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

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

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


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

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

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

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

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

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

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

        self.activateLoadedSettings()
        self.resize(700, 550)
Ejemplo n.º 9
0
    def __init__(self, parent=None, signalManager=None, name="Linear Projection (qt)", graphClass=None):
        OWVisWidget.__init__(self, parent, signalManager, name, TRUE)

        self.inputs = [
            ("Data", ExampleTable, self.setData, Default),
            ("Data Subset", ExampleTable, self.setSubsetData),
            ("Features", AttributeList, self.setShownAttributes),
            ("Evaluation Results", orngTest.ExperimentResults, self.setTestResults),
            ("VizRank Learner", orange.Learner, self.setVizRankLearner),
            ("Distances", orange.SymMatrix, self.setDistances),
        ]
        self.outputs = [
            ("Selected Data", ExampleTable),
            ("Other Data", ExampleTable),
            ("Features", AttributeList),
            ("FreeViz Learner", orange.Learner),
        ]

        name_lower = name.lower()
        self._name_lower = name_lower

        # local variables
        self.showAllAttributes = 0
        self.valueScalingType = 0
        self.autoSendSelection = 1
        self.data = None
        self.subsetData = None
        self.distances = None
        self.toolbarSelection = 0
        self.classificationResults = None
        self.outlierValues = None
        self.attributeSelectionList = None
        self.colorSettings = None
        self.selectedSchemaIndex = 0
        self.addProjectedPositions = 0
        self.resetAnchors = 0

        # add a graph widget
        if graphClass:
            self.graph = graphClass(self, self.mainArea, name)
        else:
            self.graph = OWLinProjGraph(self, self.mainArea, name)
        self.mainArea.layout().addWidget(self.graph)

        # graph variables
        self.graph.manualPositioning = 0
        self.graph.hideRadius = 0
        self.graph.showAnchors = 1
        self.graph.jitterContinuous = 0
        self.graph.showProbabilities = 0
        self.graph.useDifferentSymbols = 0
        self.graph.useDifferentColors = 1
        self.graph.tooltipKind = 0
        self.graph.tooltipValue = 0
        self.graph.scaleFactor = 1.0
        self.graph.squareGranularity = 3
        self.graph.spaceBetweenCells = 1
        self.graph.showAxisScale = 0
        self.graph.showValueLines = 0
        self.graph.valueLineLength = 5
        self.dark_theme = False

        if "3d" in name_lower:
            self.settingsList.append("graph.use_2d_symbols")
            self.settingsList.append("graph.mouse_sensitivity")
            self.settingsList.append("dark_theme")
            if "sphereviz" in name_lower:
                self.settingsList.append("graph.show_anchor_grid")

        # load settings
        self.loadSettings()

        ##        # cluster dialog
        ##        self.clusterDlg = ClusterOptimization(self, self.signalManager, self.graph, name)
        ##        self.graph.clusterOptimization = self.clusterDlg

        # optimization dialog
        if "radviz" in name_lower:
            self.vizrank = OWVizRank(self, self.signalManager, self.graph, orngVizRank.RADVIZ, name)
            self.connect(self.graphButton, SIGNAL("clicked()"), self.saveToFile)
        elif "polyviz" in name_lower:
            self.vizrank = OWVizRank(self, self.signalManager, self.graph, orngVizRank.POLYVIZ, name)
            self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile)
        elif "sphereviz" in name_lower:
            self.vizrank = OWVizRank(self, self.signalManager, self.graph, orngVizRank.SPHEREVIZ3D, name)
            self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile)
        elif "3d" in name_lower:
            self.vizrank = OWVizRank(self, self.signalManager, self.graph, orngVizRank.LINEAR_PROJECTION3D, name)
            self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile)
        else:
            self.vizrank = OWVizRank(self, self.signalManager, self.graph, orngVizRank.LINEAR_PROJECTION, name)
            self.connect(self.graphButton, SIGNAL("clicked()"), self.saveToFile)

        self.optimizationDlg = self.vizrank  # for backward compatibility

        # ignore settings!! if we have radviz then normalize, otherwise not.
        self.graph.normalizeExamples = "radviz" in name_lower or "sphereviz" in name_lower

        # GUI
        # add a settings dialog and initialize its values

        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main")
        self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings", canScroll=1)
        if not "3d" in name_lower:
            self.PerformanceTab = OWGUI.createTabPage(self.tabs, "Performance")

        # add controls to self.controlArea widget
        self.createShowHiddenLists(self.GeneralTab, callback=self.updateGraphAndAnchors)

        self.optimizationButtons = OWGUI.widgetBox(self.GeneralTab, "Optimization Dialogs", orientation="horizontal")
        self.vizrankButton = OWGUI.button(
            self.optimizationButtons,
            self,
            "VizRank",
            callback=self.vizrank.reshow,
            tooltip="Opens VizRank dialog, where you can search for interesting projections with different subsets of attributes.",
            debuggingEnabled=0,
        )
        self.wdChildDialogs = [self.vizrank]  # used when running widget debugging

        # freeviz dialog
        if "radviz" in name_lower or "linear projection" in name_lower or "sphereviz" in name_lower:
            self.freeVizDlg = FreeVizOptimization(self, self.signalManager, self.graph, name)
            self.wdChildDialogs.append(self.freeVizDlg)
            self.freeVizDlgButton = OWGUI.button(
                self.optimizationButtons,
                self,
                "FreeViz",
                callback=self.freeVizDlg.reshow,
                tooltip="Opens FreeViz dialog, where the position of attribute anchors is optimized so that class separation is improved",
                debuggingEnabled=0,
            )
            if "linear projection" in name_lower:
                self.freeVizLearner = FreeVizLearner(self.freeVizDlg)
                self.send("FreeViz Learner", self.freeVizLearner)
            if "3d" in name_lower:
                # Patch a method in Freeviz
                get_shown_attribute_list = lambda: [anchor[3] for anchor in self.graph.anchorData]
                self.freeVizDlg.get_shown_attribute_list = get_shown_attribute_list
                self.freeVizDlg.getShownAttributeList = get_shown_attribute_list
                self.freeVizDlg._use_3D = True

        ##        self.clusterDetectionDlgButton = OWGUI.button(self.optimizationButtons, self, "Cluster", callback = self.clusterDlg.reshow, debuggingEnabled = 0)
        ##        self.vizrankButton.setMaximumWidth(63)
        ##        self.clusterDetectionDlgButton.setMaximumWidth(63)
        ##        self.freeVizDlgButton.setMaximumWidth(63)
        ##        self.connect(self.clusterDlg.startOptimizationButton , SIGNAL("clicked()"), self.optimizeClusters)
        ##        self.connect(self.clusterDlg.resultList, SIGNAL("selectionChanged()"),self.showSelectedCluster)

        gui = self.graph.gui

        if "3d" in name_lower:
            toolbar_buttons = [
                gui.StateButtonsBegin,
                (gui.UserButton, "Rotate", "state", ROTATING, None, "Dlg_undo"),
                gui.Select,
                gui.StateButtonsEnd,
                gui.Spacing,
                gui.SendSelection,
                gui.ClearSelection,
            ]

            self.zoomSelectToolbar = gui.zoom_select_toolbar(self.GeneralTab, buttons=toolbar_buttons)
            self.connect(self.zoomSelectToolbar.buttons[gui.SendSelection], SIGNAL("clicked()"), self.sendSelections)
            self.graph.set_selection_behavior(OWPlot.ReplaceSelection)
        else:
            # zooming / selection
            self.zoomSelectToolbar = gui.zoom_select_toolbar(
                self.GeneralTab, buttons=gui.default_zoom_select_buttons + [gui.Spacing, gui.ShufflePoints]
            )
            self.connect(self.zoomSelectToolbar.buttons[gui.SendSelection], SIGNAL("clicked()"), self.sendSelections)

        # ####################################
        # SETTINGS TAB
        # #####
        self.extraTopBox = OWGUI.widgetBox(self.SettingsTab, orientation="vertical")
        self.extraTopBox.hide()

        self.graph.gui.point_properties_box(self.SettingsTab)

        box = OWGUI.widgetBox(self.SettingsTab, "Jittering Options")
        OWGUI.comboBoxWithCaption(
            box,
            self,
            "graph.jitterSize",
            "Jittering size (% of range):",
            callback=self.resetGraphData,
            items=self.jitterSizeNums,
            sendSelectedValue=1,
            valueType=float,
        )
        OWGUI.checkBox(
            box,
            self,
            "graph.jitterContinuous",
            "Jitter continuous attributes",
            callback=self.resetGraphData,
            tooltip="Does jittering apply also on continuous attributes?",
        )

        if not "3d" in name_lower:
            box = OWGUI.widgetBox(self.SettingsTab, "Scaling Options")
            OWGUI.qwtHSlider(
                box,
                self,
                "graph.scaleFactor",
                label="Inflate points by: ",
                minValue=1.0,
                maxValue=10.0,
                step=0.1,
                callback=self.updateGraph,
                tooltip="If points lie too much together you can expand their position to improve perception",
                maxWidth=90,
            )

        box = OWGUI.widgetBox(self.SettingsTab, "General Graph Settings")
        # OWGUI.checkBox(box, self, 'graph.normalizeExamples', 'Normalize examples', callback = self.updateGraph)
        self.graph.gui.show_legend_check_box(box)
        bbox = OWGUI.widgetBox(box, orientation="horizontal")
        if "3d" in name_lower:
            OWGUI.checkBox(bbox, self, "graph.showValueLines", "Show value lines  ", callback=self.graph.update)
            OWGUI.qwtHSlider(
                bbox,
                self,
                "graph.valueLineLength",
                minValue=1,
                maxValue=10,
                step=1,
                callback=self.graph.update,
                showValueLabel=0,
            )
        else:
            OWGUI.checkBox(bbox, self, "graph.showValueLines", "Show value lines  ", callback=self.updateGraph)
            OWGUI.qwtHSlider(
                bbox,
                self,
                "graph.valueLineLength",
                minValue=1,
                maxValue=10,
                step=1,
                callback=self.updateGraph,
                showValueLabel=0,
            )
        OWGUI.checkBox(
            box,
            self,
            "graph.useDifferentSymbols",
            "Use different symbols",
            callback=self.updateGraph,
            tooltip="Show different class values using different symbols",
        )
        OWGUI.checkBox(
            box,
            self,
            "graph.useDifferentColors",
            "Use different colors",
            callback=self.updateGraph,
            tooltip="Show different class values using different colors",
        )

        if "3d" in name_lower:
            OWGUI.checkBox(box, self, "dark_theme", "Dark theme", callback=self.on_theme_change)
            OWGUI.checkBox(
                box, self, "graph.use_2d_symbols", "2D symbols", callback=self.updateGraph, tooltip="Use 2D symbols"
            )
            self.on_theme_change()
            if "sphereviz" in name_lower:
                OWGUI.checkBox(box, self, "graph.show_anchor_grid", "Anchor grid", callback=self.on_theme_change)
                box = OWGUI.widgetBox(self.SettingsTab, "Camery type", orientation="horizontal")
                c = OWGUI.comboBox(
                    box, self, "graph.camera_type", callback=self.graph.update_camera_type, sendSelectedValue=0
                )
                c.addItem("Default")
                c.addItem("Center")
                c.addItem("Random attribute")
                OWGUI.hSlider(
                    box,
                    self,
                    "graph.camera_angle",
                    label="FOV",
                    minValue=45,
                    maxValue=180,
                    step=1,
                    callback=self.graph.update,
                    tooltip="Field of view angle",
                )
            box = OWGUI.widgetBox(self.SettingsTab, "Mouse", orientation="horizontal")
            OWGUI.hSlider(
                box,
                self,
                "graph.mouse_sensitivity",
                label="Sensitivity",
                minValue=1,
                maxValue=10,
                step=1,
                callback=self.graph.update,
                tooltip="Change mouse sensitivity",
            )
        else:
            self.graph.gui.filled_symbols_check_box(box)
            wbox = OWGUI.widgetBox(box, orientation="horizontal")
            OWGUI.checkBox(
                wbox,
                self,
                "graph.showProbabilities",
                "Show probabilities" + "  ",
                callback=self.updateGraph,
                tooltip="Show a background image with class probabilities",
            )
            smallWidget = OWGUI.SmallWidgetLabel(
                wbox, pixmap=1, box="Advanced settings", tooltip="Show advanced settings"
            )
            OWGUI.rubber(wbox)

            box = OWGUI.widgetBox(smallWidget.widget, orientation="horizontal")
            OWGUI.widgetLabel(box, "Granularity:  ")
            OWGUI.hSlider(
                box, self, "graph.squareGranularity", minValue=1, maxValue=10, step=1, callback=self.updateGraph
            )

            box = OWGUI.widgetBox(smallWidget.widget, orientation="horizontal")
            OWGUI.checkBox(box, self, "graph.spaceBetweenCells", "Show space between cells", callback=self.updateGraph)

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

        box = OWGUI.widgetBox(self.SettingsTab, "Tooltips Settings")
        callback = self.graph.update if "3d" in name_lower else self.updateGraph
        OWGUI.comboBox(
            box,
            self,
            "graph.tooltipKind",
            items=["Show line tooltips", "Show visible attributes", "Show all attributes"],
            callback=callback,
        )
        OWGUI.comboBox(
            box,
            self,
            "graph.tooltipValue",
            items=["Tooltips show data values", "Tooltips show spring values"],
            callback=callback,
            tooltip="Do you wish that tooltips would show you original values of visualized attributes or the 'spring' values (values between 0 and 1). \nSpring values are scaled values that are used for determining the position of shown points. Observing these values will therefore enable you to \nunderstand why the points are placed where they are.",
        )

        box = OWGUI.widgetBox(self.SettingsTab, "Auto Send Selected Data When...")
        OWGUI.checkBox(
            box,
            self,
            "autoSendSelection",
            "Adding/Removing selection areas",
            callback=self.selectionChanged,
            tooltip="Send selected data whenever a selection area is added or removed",
        )
        OWGUI.checkBox(
            box,
            self,
            "graph.sendSelectionOnUpdate",
            "Moving/Resizing selection areas",
            tooltip="Send selected data when a user moves or resizes an existing selection area",
        )
        OWGUI.comboBox(
            box,
            self,
            "addProjectedPositions",
            items=[
                "Do not modify the domain",
                "Append projection as attributes",
                "Append projection as meta attributes",
            ],
            callback=self.sendSelections,
        )
        self.selectionChanged()

        self.SettingsTab.layout().addStretch(100)

        if not "3d" in name_lower:
            self.graph.gui.effects_box(self.PerformanceTab)
            self.PerformanceTab.layout().addStretch(100)

        self.icons = self.createAttributeIconDict()
        self.debugSettings = ["hiddenAttributes", "shownAttributes"]

        dlg = self.createColorDialog()
        self.graph.contPalette = dlg.getContinuousPalette("contPalette")
        self.graph.discPalette = dlg.getDiscretePalette("discPalette")

        p = self.graph.palette()
        p.setColor(OWPalette.Canvas, dlg.getColor("Canvas"))
        self.graph.set_palette(p)

        self.cbShowAllAttributes()  # update list boxes based on the check box value

        self.resize(900, 700)
Ejemplo n.º 10
0
    def __init__(self, parentWidget = None, signalManager = None, graph = None, parentName = "Visualization widget"):
        OWWidget.__init__(self, None, signalManager, "FreeViz Dialog", savePosition = True, wantMainArea = 0, wantStatusBar = 1)
        FreeViz.__init__(self, graph)

        self.parentWidget = parentWidget
        self.parentName = parentName
        self.setCaption("FreeViz Optimization Dialog")
        self.cancelOptimization = 0
        self.forceRelation = 5
        self.disableAttractive = 0
        self.disableRepulsive = 0
        self.touringSpeed = 4
        self.graph = graph

        if self.graph:
            self.graph.hideRadius = 0
            self.graph.showAnchors = 1

        # differential evolution
        self.differentialEvolutionPopSize = 100
        self.DERadvizSolver = None

        self.loadSettings()

        self.layout().setMargin(0)
        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.MainTab = OWGUI.createTabPage(self.tabs, "Main")
        self.ProjectionsTab = OWGUI.createTabPage(self.tabs, "Projections")

        # ###########################
        # MAIN TAB
        OWGUI.comboBox(self.MainTab, self, "implementation", box = "FreeViz implementation", items = ["Fast (C) implementation", "Slow (Python) implementation", "LDA"])

        box = OWGUI.widgetBox(self.MainTab, "Optimization")

        self.optimizeButton = OWGUI.button(box, self, "Optimize Separation", callback = self.optimizeSeparation)
        self.stopButton = OWGUI.button(box, self, "Stop Optimization", callback = self.stopOptimization)
        self.singleStepButton = OWGUI.button(box, self, "Single Step", callback = self.singleStepOptimization)
        f = self.optimizeButton.font(); f.setBold(1)
        self.optimizeButton.setFont(f)
        self.stopButton.setFont(f); self.stopButton.hide()
        self.attrKNeighboursCombo = OWGUI.comboBoxWithCaption(box, self, "stepsBeforeUpdate", "Number of steps before updating graph: ", tooltip = "Set the number of optimization steps that will be executed before the updated anchor positions will be visualized", items = [1, 3, 5, 10, 15, 20, 30, 50, 75, 100, 150, 200, 300], sendSelectedValue = 1, valueType = int)
        OWGUI.checkBox(box, self, "mirrorSymmetry", "Keep mirror symmetry", tooltip = "'Rotational' keeps the second anchor upside")

        vbox = OWGUI.widgetBox(self.MainTab, "Set anchor positions")
        hbox1 = OWGUI.widgetBox(vbox, orientation = "horizontal")
        OWGUI.button(hbox1, self, "Sphere" if "3d" in self.parentName.lower() else "Circle", callback = self.radialAnchors)
        OWGUI.button(hbox1, self, "Random", callback = self.randomAnchors)
        self.manualPositioningButton = OWGUI.button(hbox1, self, "Manual", callback = self.setManualPosition)
        self.manualPositioningButton.setCheckable(1)
        OWGUI.comboBox(vbox, self, "restrain", label="Restrain anchors:", orientation = "horizontal", items = ["Unrestrained", "Fixed Length", "Fixed Angle"], callback = self.setRestraints)

        box2 = OWGUI.widgetBox(self.MainTab, "Forces", orientation = "vertical")

        self.cbLaw = OWGUI.comboBox(box2, self, "law", label="Law", labelWidth = 40, orientation="horizontal", items=["Linear", "Square", "Gaussian", "KNN", "Variance"], callback = self.forceLawChanged)

        hbox2 = OWGUI.widgetBox(box2, orientation = "horizontal")
        hbox2.layout().addSpacing(10)

        validSigma = QDoubleValidator(self); validSigma.setBottom(0.01)
        self.spinSigma = OWGUI.lineEdit(hbox2, self, "forceSigma", label = "Kernel width (sigma) ", labelWidth = 110, orientation = "horizontal", valueType = float)
        self.spinSigma.setFixedSize(60, self.spinSigma.sizeHint().height())
        self.spinSigma.setSizePolicy(QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed))

        box2.layout().addSpacing(20)

        self.cbforcerel = OWGUI.comboBox(box2, self, "forceRelation", label= "Attractive : Repulsive  ",orientation = "horizontal", items=self.forceRelValues, callback = self.updateForces)
        self.cbforcebal = OWGUI.checkBox(box2, self, "forceBalancing", "Dynamic force balancing", tooltip="Normalize the forces so that the total sums of the\nrepulsive and attractive are in the above proportion.")

        box2.layout().addSpacing(20)

        self.cbDisableAttractive = OWGUI.checkBox(box2, self, "disableAttractive", "Disable attractive forces", callback = self.setDisableAttractive)
        self.cbDisableRepulsive = OWGUI.checkBox(box2, self, "disableRepulsive", "Disable repulsive forces", callback = self.setDisableRepulsive)

        box = OWGUI.widgetBox(self.MainTab, "Show anchors")
        OWGUI.checkBox(box, self, 'graph.showAnchors', 'Show attribute anchors', callback = self.parentWidget.updateGraph)
        OWGUI.qwtHSlider(box, self, "graph.hideRadius", label="Hide radius", minValue=0, maxValue=9, step=1, ticks=0, callback = self.parentWidget.updateGraph)
        self.freeAttributesButton = OWGUI.button(box, self, "Remove hidden attributes", callback = self.removeHidden)

        if parentName.lower() != "radviz" and parentName.lower() != "sphereviz":
            pcaBox = OWGUI.widgetBox(self.ProjectionsTab, "Principal Component Analysis")
            OWGUI.button(pcaBox, self, "Principal component analysis", callback = self.findPCAProjection)
            OWGUI.button(pcaBox, self, "Supervised principal component analysis", callback = self.findSPCAProjection)
            OWGUI.checkBox(pcaBox, self, "useGeneralizedEigenvectors", "Merge examples with same class value")
            plsBox = OWGUI.widgetBox(self.ProjectionsTab, "Partial Least Squares")
            OWGUI.button(plsBox, self, "Partial least squares", callback = self.findPLSProjection)
        
        box = OWGUI.widgetBox(self.ProjectionsTab, "Projection Tours")
        self.startTourButton = OWGUI.button(box, self, "Start Random Touring", callback = self.startRandomTouring)
        self.stopTourButton = OWGUI.button(box, self, "Stop Touring", callback = self.stopRandomTouring)
        self.stopTourButton.hide()
        OWGUI.hSlider(box, self, 'touringSpeed', label = "Speed:  ", minValue=1, maxValue=10, step=1)
        OWGUI.rubber(self.ProjectionsTab)
        
        box = OWGUI.widgetBox(self.ProjectionsTab, "Signal to Noise Heuristic")
        #OWGUI.comboBoxWithCaption(box, self, "s2nSpread", "Anchor spread: ", tooltip = "Are the anchors for each class value placed together or are they distributed along the circle", items = range(11), callback = self.s2nMixAnchors)
        box2 = OWGUI.widgetBox(box, 0, orientation = "horizontal")
        OWGUI.widgetLabel(box2, "Anchor spread:           ")
        OWGUI.hSlider(box2, self, 's2nSpread', minValue=0, maxValue=10, step=1, callback = self.s2nMixAnchors, labelFormat="  %d", ticks=0)
        OWGUI.comboBoxWithCaption(box, self, "s2nPlaceAttributes", "Attributes to place: ", tooltip = "Set the number of top ranked attributes to place. You can select a higher value than the actual number of attributes", items = self.attrsNum, callback = self.s2nMixAnchors, sendSelectedValue = 1, valueType = int)
        OWGUI.checkBox(box, self, 'autoSetParameters', 'Automatically find optimal parameters')
        self.s2nMixButton = OWGUI.button(box, self, "Place anchors", callback = self.s2nMixAnchorsAutoSet)


        self.forceLawChanged()
        self.updateForces()
        self.cbforcebal.setDisabled(self.cbDisableAttractive.isChecked() or self.cbDisableRepulsive.isChecked())
        self.resize(320,650)
Ejemplo n.º 11
0
    def __init__(self,parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "Parallel Coordinates (Qt)", TRUE)

        #add a graph widget
        self.graph = OWParallelGraph(self, self.mainArea)
        self.mainArea.layout().addWidget(self.graph)

        self.showAllAttributes = 0

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

        #set default settings
        self.data = None
        self.subsetData = None
        self.autoSendSelection = 1
        self.attrDiscOrder = "Unordered"
        self.attrContOrder = "Unordered"
        self.projections = None
        self.correlationDict = {}
        self.middleLabels = "Correlations"
        self.attributeSelectionList = None
        self.toolbarSelection = 0
        self.colorSettings = None
        self.selectedSchemaIndex = 0

        self.graph.jitterSize = 10
        self.graph.showDistributions = 1
        self.graph.showStatistics = 0
        self.graph.showAttrValues = 1
        self.graph.useSplines = 0
        self.graph.show_legend = 1

        #load settings
        self.loadSettings()

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

        self.createShowHiddenLists(self.GeneralTab, callback = self.updateGraph)
        self.connect(self.shownAttribsLB, SIGNAL('itemDoubleClicked(QListWidgetItem*)'), self.flipAttribute)

        self.optimizationDlg = ParallelOptimization(self, signalManager = self.signalManager)
        self.optimizationDlgButton = OWGUI.button(self.GeneralTab, self, "Optimization Dialog", callback = self.optimizationDlg.reshow, debuggingEnabled = 0)

        self.zoomSelectToolbar = OWToolbars.ZoomSelectToolbar(self, self.GeneralTab, self.graph, self.autoSendSelection, buttons = (1, 2, 0, 7, 8))
        self.connect(self.zoomSelectToolbar.buttonSendSelections, SIGNAL("clicked()"), self.sendSelections)

        #connect controls to appropriate functions
        self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile)

        # ####################################
        # SETTINGS functionality
        box = OWGUI.widgetBox(self.SettingsTab, "Transparency")
        OWGUI.hSlider(box, self, 'graph.alphaValue', label = "Examples: ", minValue=0, maxValue=255, step=10, callback = self.updateGraph, tooltip = "Alpha value used for drawing example lines")
        OWGUI.hSlider(box, self, 'graph.alphaValue2', label = "Rest:     ", minValue=0, maxValue=255, step=10, callback = self.updateGraph, tooltip = "Alpha value used to draw statistics, example subsets, ...")

        box = OWGUI.widgetBox(self.SettingsTab, "Jittering Options")
        OWGUI.comboBox(box, self, "graph.jitterSize", label = 'Jittering size (% of size):  ', orientation='horizontal', callback = self.setJitteringSize, items = self.jitterSizeNums, sendSelectedValue = 1, valueType = float)

        # visual settings
        box = OWGUI.widgetBox(self.SettingsTab, "Visual Settings")

        OWGUI.checkBox(box, self, 'graph.showAttrValues', 'Show attribute values', callback = self.updateGraph)
        OWGUI.checkBox(box, self, 'graph.useSplines', 'Show splines', callback = self.updateGraph, tooltip  = "Show lines using splines")
        
        self.graph.gui.show_legend_check_box(box)

        box = OWGUI.widgetBox(self.SettingsTab, "Axis Distance")
        resizeColsBox = OWGUI.widgetBox(box, 0, "horizontal", 0)
        OWGUI.label(resizeColsBox, self, "Increase/decrease distance: ")
        b = OWGUI.toolButton(resizeColsBox, self, "+", callback=self.increaseAxesDistance, tooltip = "Increase the distance between the axes", width=30, height = 20)
        b = OWGUI.toolButton(resizeColsBox, self, "-", callback=self.decreaseAxesDistance, tooltip = "Decrease the distance between the axes", width=30, height = 20)
        OWGUI.rubber(resizeColsBox)
        OWGUI.checkBox(box, self, "graph.autoUpdateAxes", "Auto scale X axis", tooltip = "Auto scale X axis to show all visualized attributes", callback = self.updateGraph)

        box = OWGUI.widgetBox(self.SettingsTab, "Statistical Information")
        OWGUI.comboBox(box, self, "graph.showStatistics", label = "Statistics: ", orientation = "horizontal", labelWidth=90, items = ["No statistics", "Means, deviations", "Median, quartiles"], callback = self.updateGraph, sendSelectedValue = 0, valueType = int)
        OWGUI.comboBox(box, self, "middleLabels", label = "Middle labels: ", orientation="horizontal", labelWidth=90, items = ["No labels", "Correlations", "VizRank"], callback = self.updateGraph, tooltip = "The information do you wish to view on top in the middle of coordinate axes", sendSelectedValue = 1, valueType = str)
        OWGUI.checkBox(box, self, 'graph.showDistributions', 'Show distributions', callback = self.updateGraph, tooltip = "Show bars with distribution of class values (only for discrete attributes)")

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

        box = OWGUI.widgetBox(self.SettingsTab, "Auto Send Selected Data When...")
        OWGUI.checkBox(box, self, 'autoSendSelection', 'Adding/Removing selection areas', callback = self.selectionChanged, tooltip = "Send selected data whenever a selection area is added or removed")
        OWGUI.checkBox(box, self, 'graph.sendSelectionOnUpdate', 'Moving/Resizing selection areas', tooltip = "Send selected data when a user moves or resizes an existing selection area")
        self.graph.autoSendSelectionCallback = self.selectionChanged

        self.SettingsTab.layout().addStretch(100)
        self.icons = self.createAttributeIconDict()

        dlg = self.createColorDialog()
        self.graph.contPalette = dlg.getContinuousPalette("contPalette")
        self.graph.discPalette = dlg.getDiscretePalette("discPalette")
        self.graph.setCanvasBackground(dlg.getColor("Canvas"))
        apply([self.zoomSelectToolbar.actionZooming, self.zoomSelectToolbar.actionRectangleSelection, self.zoomSelectToolbar.actionPolygonSelection][self.toolbarSelection], [])
        self.cbShowAllAttributes()

        self.resize(900, 700)
Ejemplo n.º 12
0
    def __init__(self, visualizationWidget = None, signalManager = None):
        OWWidget.__init__(self, None, signalManager, "Sieve Evaluation Dialog", savePosition = True, wantMainArea = 0, wantStatusBar = 1)
        orngMosaic.__init__(self)

        self.resize(390,620)
        self.setCaption("Sieve Diagram Evaluation Dialog")
        
        # loaded variables
        self.visualizationWidget = visualizationWidget
        self.useTimeLimit = 0
        self.useProjectionLimit = 0
        self.qualityMeasure = CHI_SQUARE        # we will always compute only chi square with sieve diagram
        self.optimizationType = EXACT_NUMBER_OF_ATTRS
        self.attributeCount = 2
        self.attrCondition = None
        self.attrConditionValue = None

        self.lastSaveDirName = os.getcwd()

        self.attrLenDict = {}
        self.shownResults = []
        self.loadSettings()
       
        self.layout().setMargin(0)
        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.MainTab = OWGUI.createTabPage(self.tabs, "Main")
        self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings")
        self.ManageTab = OWGUI.createTabPage(self.tabs, "Manage")

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

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

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

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

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

        # ##########################
        # SETTINGS TAB
        OWGUI.checkBox(self.SettingsTab, self, "ignoreTooSmallCells", "Ignore cells where expected number of cases is less than 5", box = "Ignore small cells", tooltip = "Statisticians advise that in cases when the number of expected examples is less than 5 we ignore the cell \nsince it can significantly influence the chi-square value.")
        
        OWGUI.comboBoxWithCaption(self.SettingsTab, self, "percentDataUsed", "Percent of data used: ", box = "Data settings", items = self.percentDataNums, sendSelectedValue = 1, valueType = int, tooltip = "In case that we have a large dataset the evaluation of each projection can take a lot of time.\nWe can therefore use only a subset of randomly selected examples, evaluate projection on them and thus make evaluation faster.")

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

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

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

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

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

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

        # reset some parameters if we are debugging so that it won't take too much time
        if orngDebugging.orngDebuggingEnabled:
            self.useTimeLimit = 1
            self.timeLimit = 0.3
            self.useProjectionLimit = 1
            self.projectionLimit = 100
        self.icons = self.createAttributeIconDict()
    def __init__(self,
                 parent=None,
                 signalManager=None,
                 name="Correspondence Analysis"):
        OWWidget.__init__(self, parent, signalManager, name, wantGraph=True)

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

        self.colAttr = 0
        self.rowAttr = 1
        self.xPrincipalAxis = 0
        self.yPrincipalAxis = 1
        self.pointSize = 6
        self.alpha = 240
        self.jitter = 0
        self.showGridlines = 0
        self.percCol = 100
        self.percRow = 100
        self.autoSend = 0

        self.loadSettings()

        # GUI
        self.graph = OWGraph(self)
        self.graph.sendData = self.sendData
        self.mainArea.layout().addWidget(self.graph)

        self.controlAreaTab = OWGUI.tabWidget(self.controlArea)
        # Graph tab
        self.graphTab = graphTab = OWGUI.createTabPage(self.controlAreaTab,
                                                       "Graph")
        self.colAttrCB = OWGUI.comboBox(graphTab,
                                        self,
                                        "colAttr",
                                        "Column Attribute",
                                        tooltip="Column attribute",
                                        callback=self.runCA)

        self.rowAttrCB = OWGUI.comboBox(graphTab,
                                        self,
                                        "rowAttr",
                                        "Row Attribute",
                                        tooltip="Row attribute",
                                        callback=self.runCA)

        self.xAxisCB = OWGUI.comboBox(graphTab,
                                      self,
                                      "xPrincipalAxis",
                                      "Principal Axis X",
                                      tooltip="Principal axis X",
                                      callback=self.updateGraph)

        self.yAxisCB = OWGUI.comboBox(graphTab,
                                      self,
                                      "yPrincipalAxis",
                                      "Principal Axis Y",
                                      tooltip="Principal axis Y",
                                      callback=self.updateGraph)

        box = OWGUI.widgetBox(graphTab, "Contribution to Inertia")
        self.contributionInfo = OWGUI.widgetLabel(box, "NA\nNA")

        OWGUI.hSlider(
            graphTab,
            self,
            "percCol",
            "Percent of Column Points",
            1,
            100,
            1,
            callback=self.updateGraph,
            tooltip=
            "The percent of column points with the largest contribution to inertia"
        )

        OWGUI.hSlider(
            graphTab,
            self,
            "percRow",
            "Percent of Row Points",
            1,
            100,
            1,
            callback=self.updateGraph,
            tooltip=
            "The percent of row points with the largest contribution to inertia"
        )

        self.zoomSelect = ZoomSelectToolbar(self, graphTab, self.graph,
                                            self.autoSend)
        OWGUI.rubber(graphTab)

        # Settings tab
        self.settingsTab = settingsTab = OWGUI.createTabPage(
            self.controlAreaTab, "Settings")
        OWGUI.hSlider(settingsTab,
                      self,
                      "pointSize",
                      "Point Size",
                      3,
                      20,
                      step=1,
                      callback=self.setPointSize)

        OWGUI.hSlider(settingsTab,
                      self,
                      "alpha",
                      "Transparancy",
                      1,
                      255,
                      step=1,
                      callback=self.updateAlpha)

        OWGUI.hSlider(settingsTab,
                      self,
                      "jitter",
                      "Jitter Points",
                      0,
                      20,
                      step=1,
                      callback=self.updateGraph)

        box = OWGUI.widgetBox(settingsTab, "General Settings")
        OWGUI.checkBox(box,
                       self,
                       "showGridlines",
                       "Show gridlines",
                       tooltip="Show gridlines in the plot.",
                       callback=self.updateGridlines)
        OWGUI.rubber(settingsTab)

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

        self.contingency = None
        self.contColAttr = None
        self.contRowAttr = None

        self.resize(800, 600)
Ejemplo n.º 14
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.º 15
0
 def __init__(self, parent=None, signalManager=None, name="Correspondence Analysis"):
     OWWidget.__init__(self, parent, signalManager, name, wantGraph=True)
     
     self.inputs = [("Data", ExampleTable, self.setData)]
     self.outputs = [("Selected Data", ExampleTable), ("Remaining Data", ExampleTable)]
     
     self.colAttr = 0
     self.rowAttr = 1
     self.xPrincipalAxis = 0
     self.yPrincipalAxis = 1
     self.pointSize = 6
     self.alpha = 240
     self.jitter = 0
     self.showGridlines = 0
     self.percCol = 100
     self.percRow = 100
     self.autoSend = 0
     
     self.loadSettings()
     
     # GUI
     self.graph = OWGraph(self)
     self.graph.sendData = self.sendData
     self.mainArea.layout().addWidget(self.graph)
     
     
     self.controlAreaTab = OWGUI.tabWidget(self.controlArea)
     # Graph tab
     self.graphTab = graphTab = OWGUI.createTabPage(self.controlAreaTab, "Graph")
     self.colAttrCB = OWGUI.comboBox(graphTab, self, "colAttr", "Column Attribute", 
                                     tooltip="Column attribute",
                                     callback=self.runCA)
     
     self.rowAttrCB = OWGUI.comboBox(graphTab, self, "rowAttr", "Row Attribute", 
                                     tooltip="Row attribute",
                                     callback=self.runCA)
     
     self.xAxisCB = OWGUI.comboBox(graphTab, self, "xPrincipalAxis", "Principal Axis X",
                                   tooltip="Principal axis X",
                                   callback=self.updateGraph)
     
     self.yAxisCB = OWGUI.comboBox(graphTab, self, "yPrincipalAxis", "Principal Axis Y",
                                   tooltip="Principal axis Y",
                                   callback=self.updateGraph)
     
     box = OWGUI.widgetBox(graphTab, "Contribution to Inertia")
     self.contributionInfo = OWGUI.widgetLabel(box, "NA\nNA")
     
     OWGUI.hSlider(graphTab, self, "percCol", "Percent of Column Points", 1, 100, 1,
                   callback=self.updateGraph,
                   tooltip="The percent of column points with the largest contribution to inertia")
     
     OWGUI.hSlider(graphTab, self, "percRow", "Percent of Row Points", 1, 100, 1,
                   callback=self.updateGraph,
                   tooltip="The percent of row points with the largest contribution to inertia")
     
     self.zoomSelect = ZoomSelectToolbar(self, graphTab, self.graph, self.autoSend)
     OWGUI.rubber(graphTab)
     
     # Settings tab
     self.settingsTab = settingsTab = OWGUI.createTabPage(self.controlAreaTab, "Settings")
     OWGUI.hSlider(settingsTab, self, "pointSize", "Point Size", 3, 20, step=1,
                   callback=self.setPointSize)
     
     OWGUI.hSlider(settingsTab, self, "alpha", "Transparancy", 1, 255, step=1,
                   callback=self.updateAlpha)
     
     OWGUI.hSlider(settingsTab, self, "jitter", "Jitter Points", 0, 20, step=1,
                   callback=self.updateGraph)
     
     box = OWGUI.widgetBox(settingsTab, "General Settings")
     OWGUI.checkBox(box, self, "showGridlines", "Show gridlines",
                    tooltip="Show gridlines in the plot.",
                    callback=self.updateGridlines)
     OWGUI.rubber(settingsTab)
     
     self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile)
     
     self.contingency = None
     self.contColAttr = None
     self.contRowAttr = None
     
     self.resize(800, 600)
Ejemplo n.º 16
0
    def __init__(self, parent=None, signalManager=None, name="ScatterPlot 3D"):
        OWWidget.__init__(self, parent, signalManager, name, True)

        self.inputs = [
            ("Data", ExampleTable, self.set_data, Default),
            ("Subset Examples", ExampleTable, self.set_subset_data),
        ]
        self.outputs = [("Selected Data", ExampleTable), ("Other Data", ExampleTable)]

        self.x_attr = ""
        self.y_attr = ""
        self.z_attr = ""

        self.x_attr_discrete = False
        self.y_attr_discrete = False
        self.z_attr_discrete = False

        self.color_attr = ""
        self.size_attr = ""
        self.symbol_attr = ""
        self.label_attr = ""

        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.main_tab = OWGUI.createTabPage(self.tabs, "Main")
        self.settings_tab = OWGUI.createTabPage(self.tabs, "Settings", canScroll=True)

        self.x_attr_cb = OWGUI.comboBox(
            self.main_tab,
            self,
            "x_attr",
            box="X-axis attribute",
            tooltip="Attribute to plot on X axis.",
            callback=self.on_axis_change,
            sendSelectedValue=1,
            valueType=str,
        )

        self.y_attr_cb = OWGUI.comboBox(
            self.main_tab,
            self,
            "y_attr",
            box="Y-axis attribute",
            tooltip="Attribute to plot on Y axis.",
            callback=self.on_axis_change,
            sendSelectedValue=1,
            valueType=str,
        )

        self.z_attr_cb = OWGUI.comboBox(
            self.main_tab,
            self,
            "z_attr",
            box="Z-axis attribute",
            tooltip="Attribute to plot on Z axis.",
            callback=self.on_axis_change,
            sendSelectedValue=1,
            valueType=str,
        )

        self.color_attr_cb = OWGUI.comboBox(
            self.main_tab,
            self,
            "color_attr",
            box="Point color",
            tooltip="Attribute to use for point color",
            callback=self.on_axis_change,
            sendSelectedValue=1,
            valueType=str,
        )

        # Additional point properties (labels, size, symbol).
        additional_box = OWGUI.widgetBox(self.main_tab, "Additional Point Properties")
        self.size_attr_cb = OWGUI.comboBox(
            additional_box,
            self,
            "size_attr",
            label="Point size:",
            tooltip="Attribute to use for point size",
            callback=self.on_axis_change,
            indent=10,
            emptyString="(Same size)",
            sendSelectedValue=1,
            valueType=str,
        )

        self.symbol_attr_cb = OWGUI.comboBox(
            additional_box,
            self,
            "symbol_attr",
            label="Point symbol:",
            tooltip="Attribute to use for point symbol",
            callback=self.on_axis_change,
            indent=10,
            emptyString="(Same symbol)",
            sendSelectedValue=1,
            valueType=str,
        )

        self.label_attr_cb = OWGUI.comboBox(
            additional_box,
            self,
            "label_attr",
            label="Point label:",
            tooltip="Attribute to use for pointLabel",
            callback=self.on_axis_change,
            indent=10,
            emptyString="(No labels)",
            sendSelectedValue=1,
            valueType=str,
        )

        self.plot = ScatterPlot(self)
        self.vizrank = OWVizRank(self, self.signalManager, self.plot, orngVizRank.SCATTERPLOT3D, "ScatterPlot3D")
        self.optimization_dlg = self.vizrank

        self.optimization_buttons = OWGUI.widgetBox(self.main_tab, "Optimization dialogs", orientation="horizontal")
        OWGUI.button(
            self.optimization_buttons,
            self,
            "VizRank",
            callback=self.vizrank.reshow,
            tooltip="Opens VizRank dialog, where you can search for interesting projections with different subsets of attributes",
            debuggingEnabled=0,
        )

        box = OWGUI.widgetBox(self.settings_tab, "Point properties")
        OWGUI.hSlider(
            box,
            self,
            "plot.symbol_scale",
            label="Symbol scale",
            minValue=1,
            maxValue=20,
            tooltip="Scale symbol size",
            callback=self.on_checkbox_update,
        )

        OWGUI.hSlider(
            box,
            self,
            "plot.alpha_value",
            label="Transparency",
            minValue=10,
            maxValue=255,
            tooltip="Point transparency value",
            callback=self.on_checkbox_update,
        )
        OWGUI.rubber(box)

        box = OWGUI.widgetBox(self.settings_tab, "Jittering Options")
        self.jitter_size_combo = OWGUI.comboBox(
            box,
            self,
            "plot.jitter_size",
            label="Jittering size (% of size)" + "  ",
            orientation="horizontal",
            callback=self.handleNewSignals,
            items=self.jitter_sizes,
            sendSelectedValue=1,
            valueType=float,
        )
        OWGUI.checkBox(
            box,
            self,
            "plot.jitter_continuous",
            "Jitter continuous attributes",
            callback=self.handleNewSignals,
            tooltip="Does jittering apply also on continuous attributes?",
        )

        self.dark_theme = False

        box = OWGUI.widgetBox(self.settings_tab, "General settings")
        OWGUI.checkBox(box, self, "plot.show_x_axis_title", "X axis title", callback=self.on_checkbox_update)
        OWGUI.checkBox(box, self, "plot.show_y_axis_title", "Y axis title", callback=self.on_checkbox_update)
        OWGUI.checkBox(box, self, "plot.show_z_axis_title", "Z axis title", callback=self.on_checkbox_update)
        OWGUI.checkBox(box, self, "plot.show_legend", "Show legend", callback=self.on_checkbox_update)
        OWGUI.checkBox(box, self, "plot.use_2d_symbols", "2D symbols", callback=self.update_plot)
        OWGUI.checkBox(box, self, "dark_theme", "Dark theme", callback=self.on_theme_change)
        OWGUI.checkBox(box, self, "plot.show_grid", "Show grid", callback=self.on_checkbox_update)
        OWGUI.checkBox(box, self, "plot.show_axes", "Show axes", callback=self.on_checkbox_update)
        OWGUI.checkBox(box, self, "plot.show_chassis", "Show chassis", callback=self.on_checkbox_update)
        OWGUI.checkBox(box, self, "plot.hide_outside", "Hide outside", callback=self.on_checkbox_update)
        OWGUI.rubber(box)

        box = OWGUI.widgetBox(self.settings_tab, "Mouse", orientation="horizontal")
        OWGUI.hSlider(
            box,
            self,
            "plot.mouse_sensitivity",
            label="Sensitivity",
            minValue=1,
            maxValue=10,
            step=1,
            callback=self.plot.update,
            tooltip="Change mouse sensitivity",
        )

        gui = self.plot.gui
        buttons = gui.default_zoom_select_buttons
        buttons.insert(2, (gui.UserButton, "Rotate", "state", ROTATING, None, "Dlg_undo"))
        self.zoom_select_toolbar = gui.zoom_select_toolbar(self.main_tab, buttons=buttons)
        self.connect(self.zoom_select_toolbar.buttons[gui.SendSelection], SIGNAL("clicked()"), self.send_selection)
        self.connect(self.zoom_select_toolbar.buttons[gui.Zoom], SIGNAL("clicked()"), self.plot.unselect_all_points)
        self.plot.set_selection_behavior(OWPlot.ReplaceSelection)

        self.tooltip_kind = TooltipKind.NONE
        box = OWGUI.widgetBox(self.settings_tab, "Tooltips Settings")
        OWGUI.comboBox(
            box, self, "tooltip_kind", items=["Don't Show Tooltips", "Show Visible Attributes", "Show All Attributes"]
        )

        self.plot.mouseover_callback = self.mouseover_callback

        self.main_tab.layout().addStretch(100)
        self.settings_tab.layout().addStretch(100)

        self.mainArea.layout().addWidget(self.plot)
        self.connect(self.graphButton, SIGNAL("clicked()"), self.plot.save_to_file)

        self.loadSettings()
        self.plot.update_camera()
        self.on_theme_change()

        self.data = None
        self.subset_data = None
        self.resize(1100, 600)
Ejemplo n.º 17
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.º 18
0
    def __init__(self, parent=None, signalManager=None, name='TreeViewer2D'):
        OWWidget.__init__(self, parent, signalManager, name)
        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.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
        #        OWGUI.hSlider(NodeTab, self, 'NodeSize', box='Node width',
        #                      minValue=1, maxValue=10, step=1,
        #                      callback=self.toggleNodeSize, ticks=1)

        # Node information
        OWGUI.button(self.controlArea,
                     self,
                     "Navigator",
                     self.toggleNavigator,
                     debuggingEnabled=0)
        findbox = OWGUI.widgetBox(self.controlArea, orientation="horizontal")
        self.centerRootButton = OWGUI.button(
            findbox,
            self,
            "Find Root",
            callback=lambda: self.rootNode and self.sceneView.centerOn(
                self.rootNode.x(), self.rootNode.y()))
        self.centerNodeButton=OWGUI.button(findbox, self, "Find Selected",
                                           callback=lambda :self.selectedNode and \
                                     self.sceneView.centerOn(self.selectedNode.scenePos()))
        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)
    def __init__(self, parent=None, signalManager=None,
                 name="Multi Dimensional Scaling"):
        OWWidget.__init__(self, parent, signalManager, name, wantGraph=True)

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

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

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

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

        self.loadSettings()

        tabs = OWGUI.tabWidget(self.controlArea)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        self.controlArea.setMinimumWidth(250)

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

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

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

        self.resize(900, 630)

        self.done = True
        self.data = None
        self.selectedInputExamples = []
        self.selectedInput = []
    def __init__(self, parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "Interaction graph")

        self.inputs = [("Data", ExampleTable, self.setData)]
        self.outputs = [("Data", ExampleTable), ("Interacting Features", list), ("Selected Features", list)] #, ("Network", Network)]


        #set default settings
        self.originalData = None
        self.data = None
        self.graph = None
        self.dataSize = 1
        self.rest = None
        self.interactionMatrix = None
        self.rectIndices = {}   # QRect rectangles
        self.rectNames   = {}   # info about rectangle names (attributes)
        self.lines = []         # dict of form (rectName1, rectName2):(labelQPoint, [p1QPoint, p2QPoint, ...])
        self.interactionRects = []
        self.rectItems = []

        self.shownAttributes = []
        self.selectedShown = []
        self.hiddenAttributes = []
        self.selectedHidden = []
        self.mergeAttributes = 0
        self.onlyImportantInteractions = 1

        #load settings
        self.loadSettings()

        # add a settings dialog and initialize its values
        self.tabs = OWGUI.tabWidget(self.mainArea)
        
        self.listTab = OWGUI.createTabPage(self.tabs, "List")
        self.listTab.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
        self.graphTab = OWGUI.createTabPage(self.tabs, "Graph")
        
        self.splitter = QSplitter(Qt.Horizontal, self.listTab)
        self.listTab.layout().addWidget(self.splitter)

        self.splitCanvas = QSplitter(self.listTab)

        self.canvasL = QGraphicsScene()
        self.canvasViewL = IntGraphView(self, "interactions", self.canvasL, self)
        self.splitter.addWidget(self.canvasViewL)
        self.canvasViewL.setAlignment(Qt.AlignLeft | Qt.AlignTop)
        
        self.canvasM = QGraphicsScene()
        self.canvasViewM = IntGraphView(self, "correlations", self.canvasM, self)
        self.splitter.addWidget(self.canvasViewM)

        self.canvasR = QGraphicsScene()
        self.canvasViewR = IntGraphView(self, "graph", self.canvasR, self)
        self.graphTab.layout().addWidget(self.canvasViewR)

        #GUI
        #add controls to self.controlArea widget
        self.shownAttribsGroup = OWGUI.widgetBox(self.controlArea, "Selected Attributes")
        self.addRemoveGroup = OWGUI.widgetBox(self.controlArea, 1, orientation = "horizontal" )
        self.hiddenAttribsGroup = OWGUI.widgetBox(self.controlArea, "Unselected Attributes")

        self.shownAttribsLB = OWGUI.listBox(self.shownAttribsGroup, self, "selectedShown", "shownAttributes", selectionMode = QListWidget.ExtendedSelection)

        self.attrAddButton =    OWGUI.button(self.addRemoveGroup, self, "", callback = self.addAttributeClick, tooltip="Add (show) selected attributes")
        self.attrAddButton.setIcon(QIcon(os.path.join(self.widgetDir, "icons/Dlg_up3.png")))
        self.attrRemoveButton = OWGUI.button(self.addRemoveGroup, self, "", callback = self.removeAttributeClick, tooltip="Remove (hide) selected attributes")
        self.attrRemoveButton.setIcon(QIcon(os.path.join(self.widgetDir, "icons/Dlg_down3.png")))

        self.hiddenAttribsLB = OWGUI.listBox(self.hiddenAttribsGroup, self, "selectedHidden", "hiddenAttributes", selectionMode = QListWidget.ExtendedSelection)

        settingsBox = OWGUI.widgetBox(self.controlArea, "Settings")
        self.mergeAttributesCB = OWGUI.checkBox(settingsBox, self, "mergeAttributes", 'Merge attributes', callback = self.mergeAttributesEvent, tooltip = "Enable or disable attribute merging. If enabled, you can merge \ntwo attributes with a right mouse click inside interaction rectangles in the left graph.\nA merged attribute is then created as a cartesian product of corresponding attributes \nand added to the list of attributes.")
        self.importantInteractionsCB = OWGUI.checkBox(settingsBox, self, "onlyImportantInteractions", 'Important interactions only', callback = self.showImportantInteractions)

        self.selectionButton = OWGUI.button(self.controlArea, self, "Show selection", callback = self.selectionClick, tooltip = "Sends 'selection' signal to any successor visualization widgets.\nThis signal contains a list of selected attributes to visualize.")

        self.saveLCanvas = OWGUI.button(self.controlArea, self, "Save left canvas", callback = self.saveToFileLCanvas)
        self.saveRCanvas = OWGUI.button(self.controlArea, self, "Save right canvas", callback = self.saveToFileRCanvas)

        self.listTab.layout().addStretch(1)
        self.graphTab.layout().addStretch(1)
        
        
        #self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile)
        #self.connect(self.settingsButton, SIGNAL("clicked()"), self.options.show)
        
        self.activateLoadedSettings()
Ejemplo n.º 21
0
 def __init__(self, parent=None, signalManager=None):
     OWWidget.__init__(self, parent, signalManager, "Nx Analysis", noReport=True, wantMainArea=False)
     
     self.inputs = [("Network", Orange.network.Graph, self.set_graph), 
                     ("Items", Orange.data.Table, self.set_items)]
     
     self.outputs = [("Network", Orange.network.Graph), 
                     ("Items", Orange.data.Table)]
 
     self.methods = [
         ("number_of_nodes", True, "Number of nodes", GRAPHLEVEL, lambda G: G.number_of_nodes()),
         ("number_of_edges", True, "Number of edges", GRAPHLEVEL, lambda G: G.number_of_edges()),
         ("average_degree", True, "Average degree", GRAPHLEVEL, lambda G: numpy.average(G.degree().values())),
         ("diameter", False, "Diameter", GRAPHLEVEL, nx.diameter),
         ("radius", False, "Radius", GRAPHLEVEL, nx.radius),
         ("average_shortest_path_length", False, "Average shortest path length", GRAPHLEVEL, nx.average_shortest_path_length),
         ("density", True, "Density", GRAPHLEVEL, nx.density),
         ("degree_assortativity_coefficient", False, "Degree assortativity coefficient", GRAPHLEVEL, nx.degree_assortativity_coefficient),
         # additional attr needed
         #("attribute_assortativity_coefficient", False, "Attribute assortativity coefficient", GRAPHLEVEL, nx.attribute_assortativity_coefficient),
         #("numeric_assortativity_coefficient", False, "Numeric assortativity coefficient", GRAPHLEVEL, nx.numeric_assortativity_coefficient),
         ("degree_pearson_correlation_coefficient", False, "Degree pearson correlation coefficient", GRAPHLEVEL, nx.degree_pearson_correlation_coefficient),
         ("estrada_index", False, "Estrada index", GRAPHLEVEL, nx.estrada_index),
         ("graph_clique_number", False, "Graph clique number", GRAPHLEVEL, nx.graph_clique_number),
         ("graph_number_of_cliques", False, "Graph number of cliques", GRAPHLEVEL, nx.graph_number_of_cliques),
         ("transitivity", False, "Graph transitivity", GRAPHLEVEL, nx.transitivity),
         ("average_clustering", False, "Average clustering coefficient", GRAPHLEVEL, nx.average_clustering),
         ("number_connected_components", False, "Number of connected components", GRAPHLEVEL, nx.number_connected_components),
         ("number_strongly_connected_components", False, "Number of strongly connected components", GRAPHLEVEL, nx.number_strongly_connected_components),
         ("number_weakly_connected_components", False, "Number of weakly connected components", GRAPHLEVEL, nx.number_weakly_connected_components),
         ("number_attracting_components", False, "Number of attracting components", GRAPHLEVEL, nx.number_attracting_components),
         # TODO: input parameters
         #("max_flow", False, "Maximum flow", GRAPHLEVEL, nx.max_flow),
         #("min_cut", False, "Minimum cut", GRAPHLEVEL, nx.min_cut),
         #("ford_fulkerson", False, "Maximum single-commodity flow (Ford-Fulkerson)", GRAPHLEVEL, nx.ford_fulkerson),
         #("min_cost_flow_cost", False, "min_cost_flow_cost", GRAPHLEVEL, nx.min_cost_flow_cost),
         # returns dict of dict
         #("shortest_path_length", False, "Shortest path length", GRAPHLEVEL, nx.shortest_path_length),
         
         ("degree", False, "Degree", NODELEVEL, nx.degree),
         ("in_degree", False, "In-degree", NODELEVEL, lambda G: G.in_degree()),
         ("out_degree", False, "Out-degree", NODELEVEL, lambda G: G.out_degree()),
         ("average_neighbor_degree", False, "Average neighbor degree", NODELEVEL, nx.average_neighbor_degree),
         ("clustering", False, "Clustering coefficient", NODELEVEL, nx.clustering),
         ("triangles", False, "Number of triangles", NODELEVEL, nx.triangles),
         ("square_clustering", False, "Squares clustering coefficient", NODELEVEL, nx.square_clustering),
         ("number_of_cliques", False, "Number of cliques", NODELEVEL, nx.number_of_cliques),
         ("degree_centrality", False, "Degree centrality", NODELEVEL, nx.degree_centrality),
         ("in_degree_centrality", False, "In-egree centrality", NODELEVEL, nx.in_degree_centrality),
         ("out_degree_centrality", False, "Out-degree centrality", NODELEVEL, nx.out_degree_centrality),
         ("closeness_centrality", False, "Closeness centrality", NODELEVEL, nx.closeness_centrality),
         ("betweenness_centrality", False, "Betweenness centrality", NODELEVEL, nx.betweenness_centrality),
         ("current_flow_closeness_centrality", False, "Information centrality", NODELEVEL, nx.current_flow_closeness_centrality),
         ("current_flow_betweenness_centrality", False, "Random-walk betweenness centrality", NODELEVEL, nx.current_flow_betweenness_centrality),
         ("approximate_current_flow_betweenness_centrality", False, "Approx. random-walk betweenness centrality", NODELEVEL, nx.approximate_current_flow_betweenness_centrality),
         ("eigenvector_centrality", False, "Eigenvector centrality", NODELEVEL, nx.eigenvector_centrality),
         ("eigenvector_centrality_numpy", False, "Eigenvector centrality (NumPy)", NODELEVEL, nx.eigenvector_centrality_numpy),
         ("load_centrality", False, "Load centrality", NODELEVEL, nx.load_centrality),
         ("core_number", False, "Core number", NODELEVEL, nx.core_number),
         ("eccentricity", False, "Eccentricity", NODELEVEL, nx.eccentricity),
         ("closeness_vitality", False, "Closeness vitality", NODELEVEL, nx.closeness_vitality),                    
     ]
     
     self.auto_commit = False
     self.tab_index = 0
     self.mutex = QMutex()
     
     self.graph = None
     self.items = None          # items set by Items signal
     self.items_graph = None    # items set by graph.items by Network signal
     self.items_analysis = None # items to output and merge with analysis result
     
     self.job_queue = []
     self.job_working = []
     self.analfeatures = [] 
     self.analdata = {}
     
     for method in self.methods:
         setattr(self, method[0], method[1])
         setattr(self, "lbl_" + method[0], "")
 
     self.loadSettings()
     
     self.tabs = OWGUI.tabWidget(self.controlArea)
     self.tabs.setMinimumWidth(450)
     self.graphIndices = OWGUI.createTabPage(self.tabs, "Graph-level indices")    
     self.nodeIndices = OWGUI.createTabPage(self.tabs, "Node-level indices")
     self.tabs.setCurrentIndex(self.tab_index)
     self.connect(self.tabs, SIGNAL("currentChanged(int)"), lambda index: setattr(self, 'tab_index', index))
     
     for name, default, label, type, algorithm in self.methods:
         if type == NODELEVEL:
             box = OWGUI.widgetBox(self.nodeIndices, orientation="horizontal")
         elif type == GRAPHLEVEL:
             box = OWGUI.widgetBox(self.graphIndices, orientation="horizontal")
         
         OWGUI.checkBox(box, self, name, label=label, callback=lambda n=name: self.method_clicked(n))
         box.layout().addStretch(1)
         lbl = OWGUI.label(box, self, "%(lbl_" + name + ")s")
         setattr(self, "tool_" + name, lbl)
         
     self.graphIndices.layout().addStretch(1)
     self.nodeIndices.layout().addStretch(1)
     
     OWGUI.checkBox(self.controlArea, self, "auto_commit", label="Commit automatically")
     
     hb = OWGUI.widgetBox(self.controlArea, None, orientation='horizontal')
     self.btnCommit = OWGUI.button(hb, self, "Commit", callback=self.analyze, toggleButton=1)
     self.btnStopC = OWGUI.button(hb, self, "Stop current", callback=lambda current=True: self.stop_job(current))
     self.btnStopA = OWGUI.button(hb, self, "Stop all", callback=lambda current=False: self.stop_job(current))
     self.btnStopC.setEnabled(False)
     self.btnStopA.setEnabled(False)
     
     self.reportButton = OWGUI.button(hb, self, "&Report", self.reportAndFinish, debuggingEnabled=0)
     self.reportButton.setAutoDefault(0)
Ejemplo n.º 22
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, "Survey Plot", TRUE)

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

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

        #set default settings
        self.data = None
        self.showAllAttributes = 0
        self.graph.exampleTracking = 0
        self.graph.enabledLegend = 1
        self.graph.tooltipKind = 1
        self.attributeSelectionList = None
        self.graphCanvasColor = str(QColor(Qt.white).name())
        self.primaryAttribute = "(None)"
        self.secondaryAttribute = "(None)"
        self.colorSettings = None
        self.selectedSchemaIndex = 0

        #load settings
        self.loadSettings()

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

        #add controls to self.controlArea widget
        self.sortingAttrGB = OWGUI.widgetBox(self.GeneralTab, "Sorting")
        self.primaryAttrCombo = OWGUI.comboBoxWithCaption(
            self.sortingAttrGB,
            self,
            "primaryAttribute",
            label='1st:',
            items=["(None)"],
            sendSelectedValue=1,
            valueType=str,
            callback=self.sortingClick,
            labelWidth=25)
        self.secondaryAttrCombo = OWGUI.comboBoxWithCaption(
            self.sortingAttrGB,
            self,
            "secondaryAttribute",
            label='2nd:',
            items=["(None)"],
            sendSelectedValue=1,
            valueType=str,
            callback=self.sortingClick,
            labelWidth=25)

        self.createShowHiddenLists(self.GeneralTab, callback=self.updateGraph)

        # ##################################
        # survey plot settings
        box = OWGUI.widgetBox(self.SettingsTab, "Visual settings")
        OWGUI.checkBox(box,
                       self,
                       "graph.exampleTracking",
                       "Example tracking",
                       callback=self.updateGraph)
        OWGUI.checkBox(box,
                       self,
                       "graph.enabledLegend",
                       "Show legend",
                       callback=self.updateGraph)

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

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

        self.icons = self.createAttributeIconDict()

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

        #self.graph.setCanvasBackground(QColor(self.graphCanvasColor))
        self.cbShowAllAttributes()
        self.resize(750, 700)
Ejemplo n.º 23
0
    def __init__(self,parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "Survey Plot", TRUE)

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

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

        #set default settings
        self.data = None
        self.showAllAttributes = 0
        self.graph.exampleTracking = 0
        self.graph.enabledLegend = 1
        self.graph.tooltipKind = 1
        self.attributeSelectionList = None
        self.graphCanvasColor = str(QColor(Qt.white).name())
        self.primaryAttribute = "(None)"
        self.secondaryAttribute = "(None)"
        self.colorSettings = None
        self.selectedSchemaIndex = 0

        #load settings
        self.loadSettings()

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


        #add controls to self.controlArea widget
        self.sortingAttrGB = OWGUI.widgetBox(self.GeneralTab, "Sorting")
        self.primaryAttrCombo = OWGUI.comboBoxWithCaption(self.sortingAttrGB, self, "primaryAttribute", label = '1st:', items = ["(None)"], sendSelectedValue = 1, valueType = str, callback = self.sortingClick, labelWidth = 25)
        self.secondaryAttrCombo = OWGUI.comboBoxWithCaption(self.sortingAttrGB, self, "secondaryAttribute", label = '2nd:', items = ["(None)"], sendSelectedValue = 1, valueType = str, callback = self.sortingClick, labelWidth = 25)

        self.createShowHiddenLists(self.GeneralTab, callback = self.updateGraph)

        # ##################################
        # survey plot settings
        box = OWGUI.widgetBox(self.SettingsTab, "Visual settings")
        OWGUI.checkBox(box, self, "graph.exampleTracking", "Example tracking", callback = self.updateGraph)
        OWGUI.checkBox(box, self, "graph.enabledLegend", "Show legend", callback = self.updateGraph)

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

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

        self.icons = self.createAttributeIconDict()

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

        #self.graph.setCanvasBackground(QColor(self.graphCanvasColor))
        self.cbShowAllAttributes()
        self.resize(750,700)
Ejemplo n.º 24
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, "Calibration Plot", 1)

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

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

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

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

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

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

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

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

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

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

        self.inputs =  [("Data", ExampleTable, self.setData, Default), ("Data Subset", ExampleTable, self.setSubsetData), ("Features", AttributeList, self.setShownAttributes), ("Evaluation Results", orngTest.ExperimentResults, self.setTestResults), ("VizRank Learner", orange.Learner, self.setVizRankLearner)]
        self.outputs = [("Selected Data", ExampleTable), ("Other Data", ExampleTable)]

        self.graph = OWScatterPlotGraph(self, self.mainArea, "ScatterPlot")
        self.vizrank = OWVizRank(self, self.signalManager, self.graph, orngVizRank.SCATTERPLOT, "ScatterPlot")
        self.optimizationDlg = self.vizrank

        # local variables
        self.showGridlines = 0
        self.autoSendSelection = 1
        self.toolbarSelection = 0
        self.classificationResults = None
        self.outlierValues = None
        self.colorSettings = None
        self.selectedSchemaIndex = 0
        self.graph.sendSelectionOnUpdate = 0
        self.attributeSelectionList = None

        self.data = None
        self.subsetData = None

        #load settings
        self.loadSettings()

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

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

        #x attribute
        self.attrX = ""
        self.attrXCombo = OWGUI.comboBox(self.GeneralTab, self, "attrX", "X-axis Attribute", callback = self.majorUpdateGraph, sendSelectedValue = 1, valueType = str)

        # y attribute
        self.attrY = ""
        self.attrYCombo = OWGUI.comboBox(self.GeneralTab, self, "attrY", "Y-axis Attribute", callback = self.majorUpdateGraph, sendSelectedValue = 1, valueType = str)

        # coloring
        self.attrColor = ""
        box = OWGUI.widgetBox(self.GeneralTab, "Point Color")
        self.attrColorCombo = OWGUI.comboBox(box, self, "attrColor", callback = self.updateGraph, sendSelectedValue=1, valueType = str, emptyString = "(Same color)")

        box = OWGUI.widgetBox(self.GeneralTab, "Additional Point Properties")
        # labelling
        self.attrLabel = ""
        self.attrLabelCombo = OWGUI.comboBox(box, self, "attrLabel", label = "Point label:", callback = self.updateGraph, sendSelectedValue = 1, valueType = str, emptyString = "(No labels)", indent = 10)

        # shaping
        self.attrShape = ""
        self.attrShapeCombo = OWGUI.comboBox(box, self, "attrShape", label = "Point shape:", callback = self.updateGraph, sendSelectedValue=1, valueType = str, emptyString = "(Same shape)", indent = 10)

        # sizing
        self.attrSize = ""
        self.attrSizeCombo = OWGUI.comboBox(box, self, "attrSize", label = "Point size:", callback = self.updateGraph, sendSelectedValue=1, valueType = str, emptyString = "(Same size)", indent = 10)

        self.optimizationButtons = OWGUI.widgetBox(self.GeneralTab, "Optimization dialogs", orientation = "horizontal")
        OWGUI.button(self.optimizationButtons, self, "VizRank", callback = self.vizrank.reshow, tooltip = "Opens VizRank dialog, where you can search for interesting projections with different subsets of attributes", debuggingEnabled = 0)

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

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

        # #####
        # jittering options
        box2 = OWGUI.widgetBox(self.SettingsTab, "Jittering Options")
        self.jitterSizeCombo = OWGUI.comboBox(box2, self, "graph.jitterSize", label = 'Jittering size (% of size)'+'  ', orientation = "horizontal", callback = self.resetGraphData, items = self.jitterSizeNums, sendSelectedValue = 1, valueType = float)
        OWGUI.checkBox(box2, self, 'graph.jitterContinuous', 'Jitter continuous attributes', callback = self.resetGraphData, tooltip = "Does jittering apply also on continuous attributes?")

        # general graph settings
        box4 = OWGUI.widgetBox(self.SettingsTab, "General Graph Settings")
        OWGUI.checkBox(box4, self, 'graph.showXaxisTitle', 'X axis title', callback = self.graph.setShowXaxisTitle)
        OWGUI.checkBox(box4, self, 'graph.showYLaxisTitle', 'Y axis title', callback = self.graph.setShowYLaxisTitle)
        OWGUI.checkBox(box4, self, 'graph.showAxisScale', 'Show axis scale', callback = self.updateGraph)
        OWGUI.checkBox(box4, self, 'graph.showLegend', 'Show legend', callback = self.updateGraph)
        OWGUI.checkBox(box4, self, 'graph.showFilledSymbols', 'Show filled symbols', callback = self.updateGraph)
        OWGUI.checkBox(box4, self, 'showGridlines', 'Show gridlines', callback = self.setShowGridlines)
        OWGUI.checkBox(box4, self, 'graph.useAntialiasing', 'Use antialiasing', callback = self.updateGraph)

        box5 = OWGUI.widgetBox(box4, orientation = "horizontal")
        OWGUI.checkBox(box5, self, 'graph.showProbabilities', 'Show probabilities'+'  ', callback = self.updateGraph, tooltip = "Show a background image with class probabilities")
        smallWidget = OWGUI.SmallWidgetLabel(box5, pixmap = 1, box = "Advanced settings", tooltip = "Show advanced settings")
        #OWGUI.rubber(box5)

        box6 = OWGUI.widgetBox(smallWidget.widget, orientation = "horizontal")
        box7 = OWGUI.widgetBox(smallWidget.widget, orientation = "horizontal")

        OWGUI.widgetLabel(box6, "Granularity:"+"  ")
        OWGUI.hSlider(box6, self, 'graph.squareGranularity', minValue=1, maxValue=10, step=1, callback = self.updateGraph)

        OWGUI.checkBox(box7, self, 'graph.spaceBetweenCells', 'Show space between cells', callback = self.updateGraph)

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

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

        box = OWGUI.widgetBox(self.SettingsTab, "Auto Send Selected Data When...")
        OWGUI.checkBox(box, self, 'autoSendSelection', 'Adding/Removing selection areas', callback = self.selectionChanged, tooltip = "Send selected data whenever a selection area is added or removed")
        OWGUI.checkBox(box, self, 'graph.sendSelectionOnUpdate', 'Moving/Resizing selection areas', tooltip = "Send selected data when a user moves or resizes an existing selection area")
        self.graph.autoSendSelectionCallback = self.selectionChanged

        self.GeneralTab.layout().addStretch(100)
        self.SettingsTab.layout().addStretch(100)
        self.icons = self.createAttributeIconDict()

        self.debugSettings = ["attrX", "attrY", "attrColor", "attrLabel", "attrShape", "attrSize"]
        self.wdChildDialogs = [self.vizrank]        # used when running widget debugging

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

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

        apply([self.zoomSelectToolbar.actionZooming, self.zoomSelectToolbar.actionRectangleSelection, self.zoomSelectToolbar.actionPolygonSelection][self.toolbarSelection], [])
        #self.SettingsTab.resize(self.SettingsTab.sizeHint())

        self.resize(700, 550)
Ejemplo n.º 26
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self,
                          parent,
                          signalManager,
                          "Nx Analysis",
                          noReport=True,
                          wantMainArea=False)

        self.inputs = [("Network", Orange.network.Graph, self.set_graph),
                       ("Items", Orange.data.Table, self.set_items)]

        self.outputs = [("Network", Orange.network.Graph),
                        ("Items", Orange.data.Table)]

        self.methods = [
            ("number_of_nodes", True, "Number of nodes", GRAPHLEVEL,
             lambda G: G.number_of_nodes()),
            ("number_of_edges", True, "Number of edges", GRAPHLEVEL,
             lambda G: G.number_of_edges()),
            ("average_degree", True, "Average degree", GRAPHLEVEL,
             lambda G: numpy.average(G.degree().values())),
            ("diameter", False, "Diameter", GRAPHLEVEL, nx.diameter),
            ("radius", False, "Radius", GRAPHLEVEL, nx.radius),
            ("average_shortest_path_length", False,
             "Average shortest path length", GRAPHLEVEL,
             nx.average_shortest_path_length),
            ("density", True, "Density", GRAPHLEVEL, nx.density),
            ("degree_assortativity_coefficient", False,
             "Degree assortativity coefficient", GRAPHLEVEL,
             nx.degree_assortativity_coefficient),
            # additional attr needed
            #("attribute_assortativity_coefficient", False, "Attribute assortativity coefficient", GRAPHLEVEL, nx.attribute_assortativity_coefficient),
            #("numeric_assortativity_coefficient", False, "Numeric assortativity coefficient", GRAPHLEVEL, nx.numeric_assortativity_coefficient),
            ("degree_pearson_correlation_coefficient", False,
             "Degree pearson correlation coefficient", GRAPHLEVEL,
             nx.degree_pearson_correlation_coefficient),
            ("estrada_index", False, "Estrada index", GRAPHLEVEL,
             nx.estrada_index),
            ("graph_clique_number", False, "Graph clique number", GRAPHLEVEL,
             nx.graph_clique_number),
            ("graph_number_of_cliques", False, "Graph number of cliques",
             GRAPHLEVEL, nx.graph_number_of_cliques),
            ("transitivity", False, "Graph transitivity", GRAPHLEVEL,
             nx.transitivity),
            ("average_clustering", False, "Average clustering coefficient",
             GRAPHLEVEL, nx.average_clustering),
            ("number_connected_components", False,
             "Number of connected components", GRAPHLEVEL,
             nx.number_connected_components),
            ("number_strongly_connected_components", False,
             "Number of strongly connected components", GRAPHLEVEL,
             nx.number_strongly_connected_components),
            ("number_weakly_connected_components", False,
             "Number of weakly connected components", GRAPHLEVEL,
             nx.number_weakly_connected_components),
            ("number_attracting_components", False,
             "Number of attracting components", GRAPHLEVEL,
             nx.number_attracting_components),
            # TODO: input parameters
            #("max_flow", False, "Maximum flow", GRAPHLEVEL, nx.max_flow),
            #("min_cut", False, "Minimum cut", GRAPHLEVEL, nx.min_cut),
            #("ford_fulkerson", False, "Maximum single-commodity flow (Ford-Fulkerson)", GRAPHLEVEL, nx.ford_fulkerson),
            #("min_cost_flow_cost", False, "min_cost_flow_cost", GRAPHLEVEL, nx.min_cost_flow_cost),
            # returns dict of dict
            #("shortest_path_length", False, "Shortest path length", GRAPHLEVEL, nx.shortest_path_length),
            ("degree", False, "Degree", NODELEVEL, nx.degree),
            ("in_degree", False, "In-degree", NODELEVEL,
             lambda G: G.in_degree()),
            ("out_degree", False, "Out-degree", NODELEVEL,
             lambda G: G.out_degree()),
            ("average_neighbor_degree", False, "Average neighbor degree",
             NODELEVEL, nx.average_neighbor_degree),
            ("clustering", False, "Clustering coefficient", NODELEVEL,
             nx.clustering),
            ("triangles", False, "Number of triangles", NODELEVEL,
             nx.triangles),
            ("square_clustering", False, "Squares clustering coefficient",
             NODELEVEL, nx.square_clustering),
            ("number_of_cliques", False, "Number of cliques", NODELEVEL,
             nx.number_of_cliques),
            ("degree_centrality", False, "Degree centrality", NODELEVEL,
             nx.degree_centrality),
            ("in_degree_centrality", False, "In-egree centrality", NODELEVEL,
             nx.in_degree_centrality),
            ("out_degree_centrality", False, "Out-degree centrality",
             NODELEVEL, nx.out_degree_centrality),
            ("closeness_centrality", False, "Closeness centrality", NODELEVEL,
             nx.closeness_centrality),
            ("betweenness_centrality", False, "Betweenness centrality",
             NODELEVEL, nx.betweenness_centrality),
            ("current_flow_closeness_centrality", False,
             "Information centrality", NODELEVEL,
             nx.current_flow_closeness_centrality),
            ("current_flow_betweenness_centrality", False,
             "Random-walk betweenness centrality", NODELEVEL,
             nx.current_flow_betweenness_centrality),
            ("approximate_current_flow_betweenness_centrality", False,
             "Approx. random-walk betweenness centrality", NODELEVEL,
             nx.approximate_current_flow_betweenness_centrality),
            ("eigenvector_centrality", False, "Eigenvector centrality",
             NODELEVEL, nx.eigenvector_centrality),
            ("eigenvector_centrality_numpy", False,
             "Eigenvector centrality (NumPy)", NODELEVEL,
             nx.eigenvector_centrality_numpy),
            ("load_centrality", False, "Load centrality", NODELEVEL,
             nx.load_centrality),
            ("core_number", False, "Core number", NODELEVEL, nx.core_number),
            ("eccentricity", False, "Eccentricity", NODELEVEL,
             nx.eccentricity),
            ("closeness_vitality", False, "Closeness vitality", NODELEVEL,
             nx.closeness_vitality),
        ]

        self.auto_commit = False
        self.tab_index = 0
        self.mutex = QMutex()

        self.graph = None
        self.items = None  # items set by Items signal
        self.items_graph = None  # items set by graph.items by Network signal
        self.items_analysis = None  # items to output and merge with analysis result

        self.job_queue = []
        self.job_working = []
        self.analfeatures = []
        self.analdata = {}

        for method in self.methods:
            setattr(self, method[0], method[1])
            setattr(self, "lbl_" + method[0], "")

        self.loadSettings()

        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.tabs.setMinimumWidth(450)
        self.graphIndices = OWGUI.createTabPage(self.tabs,
                                                "Graph-level indices")
        self.nodeIndices = OWGUI.createTabPage(self.tabs, "Node-level indices")
        self.tabs.setCurrentIndex(self.tab_index)
        self.connect(self.tabs, SIGNAL("currentChanged(int)"),
                     lambda index: setattr(self, 'tab_index', index))

        for name, default, label, type, algorithm in self.methods:
            if type == NODELEVEL:
                box = OWGUI.widgetBox(self.nodeIndices,
                                      orientation="horizontal")
            elif type == GRAPHLEVEL:
                box = OWGUI.widgetBox(self.graphIndices,
                                      orientation="horizontal")

            OWGUI.checkBox(box,
                           self,
                           name,
                           label=label,
                           callback=lambda n=name: self.method_clicked(n))
            box.layout().addStretch(1)
            lbl = OWGUI.label(box, self, "%(lbl_" + name + ")s")
            setattr(self, "tool_" + name, lbl)

        self.graphIndices.layout().addStretch(1)
        self.nodeIndices.layout().addStretch(1)

        OWGUI.checkBox(self.controlArea,
                       self,
                       "auto_commit",
                       label="Commit automatically")

        hb = OWGUI.widgetBox(self.controlArea, None, orientation='horizontal')
        self.btnCommit = OWGUI.button(hb,
                                      self,
                                      "Commit",
                                      callback=self.analyze,
                                      toggleButton=1)
        self.btnStopC = OWGUI.button(
            hb,
            self,
            "Stop current",
            callback=lambda current=True: self.stop_job(current))
        self.btnStopA = OWGUI.button(
            hb,
            self,
            "Stop all",
            callback=lambda current=False: self.stop_job(current))
        self.btnStopC.setEnabled(False)
        self.btnStopA.setEnabled(False)

        self.reportButton = OWGUI.button(hb,
                                         self,
                                         "&Report",
                                         self.reportAndFinish,
                                         debuggingEnabled=0)
        self.reportButton.setAutoDefault(0)
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, 'LearningCurveC')

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

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

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

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

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

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

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

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

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

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

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

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

        self.resize(550,200)
Ejemplo n.º 28
0
    def __init__(self, parent=None, signalManager=None):
        #        self.callbackDeposit = [] # deposit for OWGUI callback function
        OWWidget.__init__(self,
                          parent,
                          signalManager,
                          'Distance Map',
                          wantGraph=True)

        self.inputs = [("Distance Matrix", orange.SymMatrix, self.setMatrix)]
        self.outputs = [("Examples", ExampleTable),
                        ("Attribute List", orange.VarList)]

        self.clicked = False
        self.offsetX = 5
        self.offsetY = 5
        self.imageWidth = 0
        self.imageHeight = 0
        self.distanceImage = None
        self.legendImage = None
        self.colorSettings = None
        self.selectedSchemaIndex = 0

        self.palette = None

        self.shiftPressed = False

        #set default settings
        self.CellWidth = 15
        self.CellHeight = 15
        self.Merge = 1
        self.savedMerge = self.Merge
        self.Gamma = 1
        self.Grid = 1
        self.savedGrid = 1
        self.CutLow = 0
        self.CutHigh = 0
        self.CutEnabled = 0
        self.Sort = 0
        self.SquareCells = 0
        self.ShowLegend = 1
        self.ShowLabels = 1
        self.ShowBalloon = 1
        self.ShowItemsInBalloon = 1
        self.SendOnRelease = 1

        self.loadSettings()

        self.maxHSize = 30
        self.maxVSize = 30
        self.sorting = [("No sorting", self.sortNone),
                        ("Adjacent distance", self.sortAdjDist),
                        ("Random order", self.sortRandom),
                        ("Clustering", self.sortClustering),
                        ("Clustering with ordered leafs",
                         self.sortClusteringOrdered)]

        self.matrix = self.order = None
        self.rootCluster = None

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

        # SETTINGS TAB
        tab = OWGUI.createTabPage(self.tabs, "Settings")
        box = OWGUI.widgetBox(tab, "Cell Size (Pixels)")
        OWGUI.qwtHSlider(box,
                         self,
                         "CellWidth",
                         label='Width: ',
                         labelWidth=38,
                         minValue=1,
                         maxValue=self.maxHSize,
                         step=1,
                         precision=0,
                         callback=[
                             lambda f="CellWidth", t="CellHeight": self.
                             adjustCellSize(f, t), self.drawDistanceMap,
                             self.manageGrid
                         ])
        OWGUI.qwtHSlider(box,
                         self,
                         "CellHeight",
                         label='Height: ',
                         labelWidth=38,
                         minValue=1,
                         maxValue=self.maxVSize,
                         step=1,
                         precision=0,
                         callback=[
                             lambda f="CellHeight", t="CellWidth": self.
                             adjustCellSize(f, t), self.drawDistanceMap,
                             self.manageGrid
                         ])
        OWGUI.checkBox(box,
                       self,
                       "SquareCells",
                       "Cells as squares",
                       callback=[self.setSquares, self.drawDistanceMap])
        self.gridChkBox = OWGUI.checkBox(
            box,
            self,
            "Grid",
            "Show grid",
            callback=self.createDistanceMap,
            disabled=lambda: min(self.CellWidth, self.CellHeight
                                 ) <= c_smallcell)

        OWGUI.separator(tab)
        OWGUI.qwtHSlider(tab,
                         self,
                         "Merge",
                         box="Merge",
                         label='Elements:',
                         labelWidth=50,
                         minValue=1,
                         maxValue=100,
                         step=1,
                         callback=self.createDistanceMap,
                         ticks=0)

        OWGUI.separator(tab)
        self.labelCombo = OWGUI.comboBox(
            tab,
            self,
            "Sort",
            box="Sort",
            items=[x[0] for x in self.sorting],
            tooltip="Sorting method for items in distance matrix.",
            callback=self.sortItems)
        OWGUI.rubber(tab)

        ##        self.tabs.insertTab(tab, "Settings")

        # FILTER TAB
        tab = OWGUI.createTabPage(self.tabs, "Colors")
        box = OWGUI.widgetBox(tab, "Color settings", addSpace=True)
        OWGUI.widgetLabel(box, "Gamma")
        OWGUI.qwtHSlider(box,
                         self,
                         "Gamma",
                         minValue=0.1,
                         maxValue=1,
                         step=0.1,
                         maxWidth=100,
                         callback=self.drawDistanceMap)

        OWGUI.separator(box)

        OWGUI.checkBox(box,
                       self,
                       'CutEnabled',
                       "Enable thresholds",
                       callback=self.setCutEnabled)
        self.sliderCutLow = OWGUI.qwtHSlider(box,
                                             self,
                                             'CutLow',
                                             label='Low:',
                                             labelWidth=33,
                                             minValue=-100,
                                             maxValue=0,
                                             step=0.1,
                                             precision=1,
                                             ticks=0,
                                             maxWidth=80,
                                             callback=self.drawDistanceMap)
        self.sliderCutHigh = OWGUI.qwtHSlider(box,
                                              self,
                                              'CutHigh',
                                              label='High:',
                                              labelWidth=33,
                                              minValue=0,
                                              maxValue=100,
                                              step=0.1,
                                              precision=1,
                                              ticks=0,
                                              maxWidth=80,
                                              callback=self.drawDistanceMap)
        if not self.CutEnabled:
            self.sliderCutLow.box.setDisabled(1)
            self.sliderCutHigh.box.setDisabled(1)

##        self.colorPalette = ColorPalette(box, self, "",
##                         additionalColors =["Cell outline", "Selected cells"],
##                         callback = self.setColor)
##        box.layout().addWidget(self.colorPalette)
        box = OWGUI.widgetBox(box, "Colors", orientation="horizontal")
        self.colorCombo = OWColorPalette.PaletteSelectorComboBox(self)
        try:
            self.colorCombo.setPalettes("palette", self.createColorDialog())
        except Exception as ex:
            print(
                ex,
                "Error loading saved color palettes!\nCreating new default palette!",
                file=sys.stderr)
            self.colorSettings = None
            self.colorCombo.setPalettes("palette", self.createColorDialog())
        self.colorCombo.setCurrentIndex(self.selectedSchemaIndex)
        self.connect(self.colorCombo, SIGNAL("activated(int)"), self.setColor)
        box.layout().addWidget(self.colorCombo, 2)
        OWGUI.button(box,
                     self,
                     "Edit colors",
                     callback=self.openColorDialog,
                     debuggingEnabled=0)
        OWGUI.rubber(tab)

        self.setColor(self.selectedSchemaIndex)

        ##        self.tabs.insertTab(tab, "Colors")

        # INFO TAB
        tab = OWGUI.createTabPage(self.tabs, "Info")
        box = OWGUI.widgetBox(tab, "Annotation && Legends")
        OWGUI.checkBox(box,
                       self,
                       'ShowLegend',
                       'Show legend',
                       callback=self.drawDistanceMap)
        OWGUI.checkBox(box,
                       self,
                       'ShowLabels',
                       'Show labels',
                       callback=self.drawDistanceMap)

        box = OWGUI.widgetBox(tab, "Balloon")
        OWGUI.checkBox(box, self, 'ShowBalloon', "Show balloon")
        OWGUI.checkBox(box, self, 'ShowItemsInBalloon', "Display item names")

        box = OWGUI.widgetBox(tab, "Select")
        box2 = OWGUI.widgetBox(box, orientation="horizontal")
        self.box2 = box2
        self.buttonUndo = OWToolbars.createButton(box2,
                                                  'Undo',
                                                  self.actionUndo,
                                                  QIcon(OWToolbars.dlg_undo),
                                                  toggle=0)
        self.buttonRemoveAllSelections = OWToolbars.createButton(
            box2,
            'Remove all selections',
            self.actionRemoveAllSelections,
            QIcon(OWToolbars.dlg_clear),
            toggle=0)

        self.buttonSendSelections = OWToolbars.createButton(
            box2,
            'Send selections',
            self.sendOutput,
            QIcon(OWToolbars.dlg_send),
            toggle=0)
        OWGUI.checkBox(box, self, 'SendOnRelease', "Send after mouse release")
        OWGUI.rubber(tab)
        ##        self.tabs.insertTab(tab, "Info")

        self.resize(700, 400)

        self.scene = EventfulGraphicsScene(self)
        self.sceneView = EventfulGraphicsView(self.scene, self.mainArea, self)
        self.mainArea.layout().addWidget(self.sceneView)

        #construct selector
        self.selector = QGraphicsRectItem(0, 0, self.CellWidth,
                                          self.CellHeight, None, self.scene)
        ##        color = self.colorPalette.getCurrentColorSchema().getAdditionalColors()["Cell outline"]
        color = self.cellOutlineColor
        self.selector.setPen(QPen(self.qrgbToQColor(color), v_sel_width))
        self.selector.setZValue(20)

        ##        self.bubble = BubbleInfo(self.scene)
        self.selection = SelectionManager()

        self.selectionLines = []
        self.annotationText = []
        self.clusterItems = []
        self.selectionRects = []

        self.legendText1 = QGraphicsSimpleTextItem(None, self.scene)
        self.legendText2 = QGraphicsSimpleTextItem(None, self.scene)

        self.errorText = QGraphicsSimpleTextItem("Bitmap is too large.", None,
                                                 self.scene)
        self.errorText.setPos(10, 10)

        #        OWGUI.button(self.controlArea, self, "&Save Graph", lambda:OWChooseImageSizeDlg(self.scene).exec_(), debuggingEnabled = 0)
        self.connect(
            self.graphButton, SIGNAL("clicked()"),
            lambda: OWChooseImageSizeDlg(self.scene, parent=self).exec_())