def __init__(self, parent=None, signalManager=None, name="Interactive Discretization"): OWWidget.__init__(self, parent, signalManager, name) self.showBaseLine=1 self.showLookaheadLine=1 self.showTargetClassProb=1 self.showRug=0 self.snap=1 self.measure=0 self.targetClass=0 self.discretization = self.classDiscretization = self.indiDiscretization = 1 self.intervals = self.classIntervals = self.indiIntervals = 3 self.outputOriginalClass = True self.indiData = [] self.indiLabels = [] self.resetIndividuals = 0 self.customClassSplits = "" self.selectedAttr = 0 self.customSplits = ["", "", ""] self.autoApply = True self.dataChanged = False self.autoSynchronize = True self.pointsChanged = False self.customLineEdits = [] self.needsDiscrete = [] self.data = self.originalData = None self.loadSettings() self.inputs=[("Data", ExampleTable, self.setData)] self.outputs=[("Data", ExampleTable)] self.measures=[("Information gain", orange.MeasureAttribute_info()), #("Gain ratio", orange.MeasureAttribute_gainRatio), ("Gini", orange.MeasureAttribute_gini()), ("chi-square", orange.MeasureAttribute_chiSquare()), ("chi-square prob.", orange.MeasureAttribute_chiSquare(computeProbabilities=1)), ("Relevance", orange.MeasureAttribute_relevance()), ("ReliefF", orange.MeasureAttribute_relief())] self.discretizationMethods=["Leave continuous", "Entropy-MDL discretization", "Equal-frequency discretization", "Equal-width discretization", "Remove continuous attributes"] self.classDiscretizationMethods=["Equal-frequency discretization", "Equal-width discretization"] self.indiDiscretizationMethods=["Default", "Leave continuous", "Entropy-MDL discretization", "Equal-frequency discretization", "Equal-width discretization", "Remove attribute"] self.mainHBox = OWGUI.widgetBox(self.mainArea, orientation=0) vbox = self.controlArea box = OWGUI.radioButtonsInBox(vbox, self, "discretization", self.discretizationMethods[:-1], "Default discretization", callback=[self.clearLineEditFocus, self.defaultMethodChanged]) self.needsDiscrete.append(box.buttons[1]) box.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)) indent = OWGUI.checkButtonOffsetHint(self.needsDiscrete[-1]) self.interBox = OWGUI.widgetBox(OWGUI.indentedBox(box, sep=indent)) OWGUI.widgetLabel(self.interBox, "Number of intervals (for equal width/frequency)") OWGUI.separator(self.interBox, height=4) self.intervalSlider=OWGUI.hSlider(OWGUI.indentedBox(self.interBox), self, "intervals", None, 2, 10, callback=[self.clearLineEditFocus, self.defaultMethodChanged]) OWGUI.appendRadioButton(box, self, "discretization", self.discretizationMethods[-1]) OWGUI.separator(vbox) ribg = OWGUI.radioButtonsInBox(vbox, self, "resetIndividuals", ["Use default discretization for all attributes", "Explore and set individual discretizations"], "Individual attribute treatment", callback = self.setAllIndividuals) ll = QWidget(ribg) ll.setFixedHeight(1) OWGUI.widgetLabel(ribg, "Set discretization of all attributes to") hcustbox = OWGUI.widgetBox(OWGUI.indentedBox(ribg), 0, 0) for c in range(1, 4): OWGUI.appendRadioButton(ribg, self, "resetIndividuals", "Custom %i" % c, insertInto = hcustbox) OWGUI.separator(vbox) box = self.classDiscBox = OWGUI.radioButtonsInBox(vbox, self, "classDiscretization", self.classDiscretizationMethods, "Class discretization", callback=[self.clearLineEditFocus, self.classMethodChanged]) cinterBox = OWGUI.widgetBox(box) self.intervalSlider=OWGUI.hSlider(OWGUI.indentedBox(cinterBox, sep=indent), self, "classIntervals", None, 2, 10, callback=[self.clearLineEditFocus, self.classMethodChanged], label="Number of intervals") hbox = OWGUI.widgetBox(box, orientation = 0) OWGUI.appendRadioButton(box, self, "discretization", "Custom" + " ", insertInto = hbox) self.classCustomLineEdit = OWGUI.lineEdit(hbox, self, "customClassSplits", callback = self.classCustomChanged, focusInCallback = self.classCustomSelected) # Can't validate - need to allow spaces box.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)) OWGUI.separator(box) self.classIntervalsLabel = OWGUI.widgetLabel(box, "Current splits: ") OWGUI.separator(box) OWGUI.checkBox(box, self, "outputOriginalClass", "Output original class", callback = self.commitIf) OWGUI.widgetLabel(box, "("+"Widget always uses discretized class internally."+")") OWGUI.separator(vbox) #OWGUI.rubber(vbox) box = OWGUI.widgetBox(vbox, "Commit") applyButton = OWGUI.button(box, self, "Commit", callback = self.commit, default=True) autoApplyCB = OWGUI.checkBox(box, self, "autoApply", "Commit automatically", callback=[self.clearLineEditFocus]) OWGUI.setStopper(self, applyButton, autoApplyCB, "dataChanged", self.commit) OWGUI.rubber(vbox) #self.mainSeparator = OWGUI.separator(self.mainHBox, width=25) # space between control and main area self.mainIABox = OWGUI.widgetBox(self.mainHBox, "Individual attribute settings") self.mainBox = OWGUI.widgetBox(self.mainIABox, orientation=0) OWGUI.separator(self.mainIABox)#, height=30) graphBox = OWGUI.widgetBox(self.mainIABox, "", orientation=0) # self.needsDiscrete.append(graphBox) graphOptBox = OWGUI.widgetBox(graphBox) OWGUI.separator(graphBox, width=10) graphGraphBox = OWGUI.widgetBox(graphBox) self.graph = DiscGraph(self, graphGraphBox) graphGraphBox.layout().addWidget(self.graph) reportButton2 = OWGUI.button(graphGraphBox, self, "Report Graph", callback = self.reportGraph, debuggingEnabled=0) #graphOptBox.layout().setSpacing(4) box = OWGUI.widgetBox(graphOptBox, "Split gain measure", addSpace=True) self.measureCombo=OWGUI.comboBox(box, self, "measure", orientation=0, items=[e[0] for e in self.measures], callback=[self.clearLineEditFocus, self.graph.invalidateBaseScore, self.graph.plotBaseCurve]) OWGUI.checkBox(box, self, "showBaseLine", "Show discretization gain", callback=[self.clearLineEditFocus, self.graph.plotBaseCurve]) OWGUI.checkBox(box, self, "showLookaheadLine", "Show lookahead gain", callback=self.clearLineEditFocus) self.needsDiscrete.append(box) box = OWGUI.widgetBox(graphOptBox, "Target class", addSpace=True) self.targetCombo=OWGUI.comboBox(box, self, "targetClass", orientation=0, callback=[self.clearLineEditFocus, self.graph.targetClassChanged]) stc = OWGUI.checkBox(box, self, "showTargetClassProb", "Show target class probability", callback=[self.clearLineEditFocus, self.graph.plotProbCurve]) OWGUI.checkBox(box, self, "showRug", "Show rug (may be slow)", callback=[self.clearLineEditFocus, self.graph.plotRug]) self.needsDiscrete.extend([self.targetCombo, stc]) box = OWGUI.widgetBox(graphOptBox, "Editing", addSpace=True) OWGUI.checkBox(box, self, "snap", "Snap to grid", callback=[self.clearLineEditFocus]) syncCB = OWGUI.checkBox(box, self, "autoSynchronize", "Apply on the fly", callback=self.clearLineEditFocus) syncButton = OWGUI.button(box, self, "Apply", callback = self.synchronizePressed) OWGUI.setStopper(self, syncButton, syncCB, "pointsChanged", self.synchronize) OWGUI.rubber(graphOptBox) self.attrList = OWGUI.listBox(self.mainBox, self, callback = self.individualSelected) self.attrList.setItemDelegate(CustomListItemDelegate(self.attrList)) self.attrList.setFixedWidth(300) self.defaultMethodChanged() OWGUI.separator(self.mainBox, width=10) box = OWGUI.radioButtonsInBox(OWGUI.widgetBox(self.mainBox), self, "indiDiscretization", [], callback=[self.clearLineEditFocus, self.indiMethodChanged]) #hbbox = OWGUI.widgetBox(box) #hbbox.layout().setSpacing(4) for meth in self.indiDiscretizationMethods[:-1]: OWGUI.appendRadioButton(box, self, "indiDiscretization", meth) self.needsDiscrete.append(box.buttons[2]) self.indiInterBox = OWGUI.indentedBox(box, sep=indent, orientation = "horizontal") OWGUI.widgetLabel(self.indiInterBox, "Num. of intervals: ") self.indiIntervalSlider = OWGUI.hSlider(self.indiInterBox, self, "indiIntervals", None, 2, 10, callback=[self.clearLineEditFocus, self.indiMethodChanged], width = 100) OWGUI.rubber(self.indiInterBox) OWGUI.appendRadioButton(box, self, "indiDiscretization", self.indiDiscretizationMethods[-1]) #OWGUI.rubber(hbbox) #OWGUI.separator(box) #hbbox = OWGUI.widgetBox(box) for i in range(3): hbox = OWGUI.widgetBox(box, orientation = "horizontal") OWGUI.appendRadioButton(box, self, "indiDiscretization", "Custom %i" % (i+1) + " ", insertInto = hbox) le = OWGUI.lineEdit(hbox, self, "", callback = lambda w=i: self.customChanged(w), focusInCallback = lambda w=i: self.customSelected(w)) le.setFixedWidth(110) self.customLineEdits.append(le) OWGUI.toolButton(hbox, self, "CC", width=30, callback = lambda w=i: self.copyToCustom(w)) OWGUI.rubber(hbox) OWGUI.rubber(box) #self.controlArea.setFixedWidth(0) self.contAttrIcon = self.createAttributeIconDict()[orange.VarTypes.Continuous] self.setAllIndividuals()
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "Parallel Coordinates", 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.enabledLegend = 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.useAntialiasing', 'Use antialiasing', callback=self.updateGraph) OWGUI.checkBox(box, self, 'graph.useSplines', 'Show splines', callback=self.updateGraph, tooltip="Show lines using splines") OWGUI.checkBox(box, self, 'graph.enabledLegend', 'Show legend', callback=self.updateGraph) 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)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "Rank") self.inputs = [("Examples", ExampleTable, self.setData)] self.outputs = [("Reduced Example Table", ExampleTable, Default + Single), ("ExampleTable Attributes", ExampleTable, NonDefault)] self.settingsList += self.measuresAttrs self.logORIdx = self.measuresShort.index("log OR") self.nDecimals = 3 self.reliefK = 10 self.reliefN = 20 self.nIntervals = 4 self.sortBy = 0 self.selectMethod = 3 self.nSelected = 5 self.autoApply = True self.showDistributions = 1 self.distColorRgb = (220, 220, 220, 255) self.distColor = QColor(*self.distColorRgb) self.minmax = {} self.data = None for meas in self.measuresAttrs: setattr(self, meas, True) self.loadSettings() labelWidth = 80 box = OWGUI.widgetBox(self.controlArea, "Measures", addSpace=True) for meas, valueName in zip(self.measures, self.measuresAttrs): if valueName == "computeReliefF": hbox = OWGUI.widgetBox(box, orientation="horizontal") OWGUI.checkBox(hbox, self, valueName, meas, callback=self.measuresChanged) hbox.layout().addSpacing(5) smallWidget = OWGUI.SmallWidgetLabel( hbox, pixmap=1, box="ReliefF Parameters", tooltip="Show ReliefF parameters") OWGUI.spin(smallWidget.widget, self, "reliefK", 1, 20, label="Neighbours", labelWidth=labelWidth, orientation=0, callback=self.reliefChanged, callbackOnReturn=True) OWGUI.spin(smallWidget.widget, self, "reliefN", 20, 100, label="Examples", labelWidth=labelWidth, orientation=0, callback=self.reliefChanged, callbackOnReturn=True) OWGUI.button(smallWidget.widget, self, "Load defaults", callback=self.loadReliefDefaults) OWGUI.rubber(hbox) else: OWGUI.checkBox(box, self, valueName, meas, callback=self.measuresChanged) OWGUI.separator(box) OWGUI.comboBox( box, self, "sortBy", label="Sort by" + " ", items=["No Sorting", "Attribute Name", "Number of Values"] + self.measures, orientation=0, valueType=int, callback=self.sortingChanged) box = OWGUI.widgetBox(self.controlArea, "Discretization") OWGUI.spin(box, self, "nIntervals", 2, 20, label="Intervals: ", orientation=0, callback=self.discretizationChanged, callbackOnReturn=True) box = OWGUI.widgetBox(self.controlArea, "Precision", addSpace=True) OWGUI.spin(box, self, "nDecimals", 1, 6, label="No. of decimals: ", orientation=0, callback=self.decimalsChanged) OWGUI.rubber(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Distributions", addSpace=True) self.cbShowDistributions = OWGUI.checkBox( box, self, "showDistributions", 'Visualize values', callback=self.cbShowDistributions) colBox = OWGUI.indentedBox(box, orientation="horizontal") OWGUI.widgetLabel(colBox, "Color: ") self.colButton = OWGUI.toolButton(colBox, self, self.changeColor, width=20, height=20, debuggingEnabled=0) OWGUI.rubber(colBox) selMethBox = OWGUI.radioButtonsInBox( self.controlArea, self, "selectMethod", ["None", "All", "Manual", "Best ranked"], box="Select attributes", callback=self.selectMethodChanged) OWGUI.spin(OWGUI.indentedBox(selMethBox), self, "nSelected", 1, 100, label="No. selected" + " ", orientation=0, callback=self.nSelectedChanged) OWGUI.separator(selMethBox) applyButton = OWGUI.button(selMethBox, self, "Commit", callback=self.apply) autoApplyCB = OWGUI.checkBox(selMethBox, self, "autoApply", "Commit automatically") OWGUI.setStopper(self, applyButton, autoApplyCB, "dataChanged", self.apply) self.table = QTableWidget() self.mainArea.layout().addWidget(self.table) self.table.setSelectionBehavior(QAbstractItemView.SelectRows) self.table.setSelectionMode(QAbstractItemView.MultiSelection) self.table.verticalHeader().setResizeMode(QHeaderView.ResizeToContents) self.table.setItemDelegate(RankItemDelegate(self, self.table)) self.topheader = self.table.horizontalHeader() self.topheader.setSortIndicatorShown(1) self.topheader.setHighlightSections(0) self.setMeasures() self.resetInternals() self.connect(self.table.horizontalHeader(), SIGNAL("sectionClicked(int)"), self.headerClick) self.connect(self.table, SIGNAL("clicked (const QModelIndex&)"), self.selectItem) self.resize(690, 500) self.updateColor()
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "Data Table") self.inputs = [("Data", ExampleTable, self.dataset, Multiple + Default)] self.outputs = [("Selected Data", ExampleTable, Default), ("Other Data", ExampleTable)] self.data = {} # key: id, value: ExampleTable self.showMetas = {} # key: id, value: (True/False, columnList) self.showMeta = 1 self.showAttributeLabels = 1 self.showDistributions = 1 self.distColorRgb = (220, 220, 220, 255) self.distColor = QColor(*self.distColorRgb) self.locale = QLocale() self.autoCommit = False self.colorSettings = None self.selectedSchemaIndex = 0 self.colorByClass = True self.loadSettings() # info box infoBox = OWGUI.widgetBox(self.controlArea, "Info") self.infoEx = OWGUI.widgetLabel(infoBox, "No data on input.") self.infoMiss = OWGUI.widgetLabel(infoBox, " ") OWGUI.widgetLabel(infoBox, " ") self.infoAttr = OWGUI.widgetLabel(infoBox, " ") self.infoMeta = OWGUI.widgetLabel(infoBox, " ") OWGUI.widgetLabel(infoBox, " ") self.infoClass = OWGUI.widgetLabel(infoBox, " ") infoBox.setMinimumWidth(200) OWGUI.separator(self.controlArea) # settings box boxSettings = OWGUI.widgetBox(self.controlArea, "Settings", addSpace=True) self.cbShowMeta = OWGUI.checkBox( boxSettings, self, "showMeta", "Show meta attributes", callback=self.cbShowMetaClicked ) self.cbShowMeta.setEnabled(False) self.cbShowAttLbls = OWGUI.checkBox( boxSettings, self, "showAttributeLabels", "Show attribute labels (if any)", callback=self.cbShowAttLabelsClicked, ) self.cbShowAttLbls.setEnabled(True) box = OWGUI.widgetBox(self.controlArea, "Colors") OWGUI.checkBox(box, self, "showDistributions", "Visualize continuous values", callback=self.cbShowDistributions) OWGUI.checkBox(box, self, "colorByClass", "Color by class value", callback=self.cbShowDistributions) OWGUI.button( box, self, "Set colors", self.setColors, tooltip="Set the canvas background color and color palette for coloring continuous variables", debuggingEnabled=0, ) resizeColsBox = OWGUI.widgetBox(boxSettings, 0, "horizontal", 0) OWGUI.label(resizeColsBox, self, "Resize columns: ") OWGUI.toolButton( resizeColsBox, self, "+", self.increaseColWidth, tooltip="Increase the width of the columns", width=20, height=20, ) OWGUI.toolButton( resizeColsBox, self, "-", self.decreaseColWidth, tooltip="Decrease the width of the columns", width=20, height=20, ) OWGUI.rubber(resizeColsBox) self.btnResetSort = OWGUI.button( boxSettings, self, "Restore Order of Examples", callback=self.btnResetSortClicked, tooltip="Show examples in the same order as they appear in the file", ) OWGUI.separator(self.controlArea) selectionBox = OWGUI.widgetBox(self.controlArea, "Selection") self.sendButton = OWGUI.button(selectionBox, self, "Send selections", self.commit, default=True) cb = OWGUI.checkBox(selectionBox, self, "autoCommit", "Commit on any change", callback=self.commitIf) OWGUI.setStopper(self, self.sendButton, cb, "selectionChangedFlag", self.commit) OWGUI.rubber(self.controlArea) dlg = self.createColorDialog() self.discPalette = dlg.getDiscretePalette("discPalette") # GUI with tabs self.tabs = OWGUI.tabWidget(self.mainArea) self.id2table = {} # key: widget id, value: table self.table2id = {} # key: table, value: widget id self.connect(self.tabs, SIGNAL("currentChanged(QWidget*)"), self.tabClicked) self.selectionChangedFlag = False
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)
def __init__(self, parent=None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "Data Table") self.inputs = [("Data", ExampleTable, self.dataset, Multiple + Default)] self.outputs = [("Selected Data", ExampleTable, Default), ("Other Data", ExampleTable)] self.data = {} # key: id, value: ExampleTable self.showMetas = {} # key: id, value: (True/False, columnList) self.showMeta = 1 self.showAttributeLabels = 1 self.showDistributions = 1 self.distColorRgb = (220,220,220, 255) self.distColor = QColor(*self.distColorRgb) self.locale = QLocale() self.autoCommit = False self.colorSettings = None self.selectedSchemaIndex = 0 self.colorByClass = True self.loadSettings() # info box infoBox = OWGUI.widgetBox(self.controlArea, "Info") self.infoEx = OWGUI.widgetLabel(infoBox, 'No data on input.') self.infoMiss = OWGUI.widgetLabel(infoBox, ' ') OWGUI.widgetLabel(infoBox, ' ') self.infoAttr = OWGUI.widgetLabel(infoBox, ' ') self.infoMeta = OWGUI.widgetLabel(infoBox, ' ') OWGUI.widgetLabel(infoBox, ' ') self.infoClass = OWGUI.widgetLabel(infoBox, ' ') infoBox.setMinimumWidth(200) OWGUI.separator(self.controlArea) # settings box boxSettings = OWGUI.widgetBox(self.controlArea, "Settings", addSpace=True) self.cbShowMeta = OWGUI.checkBox(boxSettings, self, "showMeta", 'Show meta attributes', callback = self.cbShowMetaClicked) self.cbShowMeta.setEnabled(False) self.cbShowAttLbls = OWGUI.checkBox(boxSettings, self, "showAttributeLabels", 'Show attribute labels (if any)', callback = self.cbShowAttLabelsClicked) self.cbShowAttLbls.setEnabled(True) box = OWGUI.widgetBox(self.controlArea, "Colors") OWGUI.checkBox(box, self, "showDistributions", 'Visualize continuous values', callback = self.cbShowDistributions) OWGUI.checkBox(box, self, "colorByClass", 'Color by class value', callback = self.cbShowDistributions) OWGUI.button(box, self, "Set colors", self.setColors, tooltip = "Set the canvas background color and color palette for coloring continuous variables", debuggingEnabled = 0) resizeColsBox = OWGUI.widgetBox(boxSettings, 0, "horizontal", 0) OWGUI.label(resizeColsBox, self, "Resize columns: ") OWGUI.toolButton(resizeColsBox, self, "+", self.increaseColWidth, tooltip = "Increase the width of the columns", width=20, height=20) OWGUI.toolButton(resizeColsBox, self, "-", self.decreaseColWidth, tooltip = "Decrease the width of the columns", width=20, height=20) OWGUI.rubber(resizeColsBox) self.btnResetSort = OWGUI.button(boxSettings, self, "Restore Order of Examples", callback = self.btnResetSortClicked, tooltip = "Show examples in the same order as they appear in the file") OWGUI.separator(self.controlArea) selectionBox = OWGUI.widgetBox(self.controlArea, "Selection") self.sendButton = OWGUI.button(selectionBox, self, "Send selections", self.commit, default=True) cb = OWGUI.checkBox(selectionBox, self, "autoCommit", "Commit on any change", callback=self.commitIf) OWGUI.setStopper(self, self.sendButton, cb, "selectionChangedFlag", self.commit) OWGUI.rubber(self.controlArea) dlg = self.createColorDialog() self.discPalette = dlg.getDiscretePalette("discPalette") # GUI with tabs self.tabs = OWGUI.tabWidget(self.mainArea) self.id2table = {} # key: widget id, value: table self.table2id = {} # key: table, value: widget id self.connect(self.tabs, SIGNAL("currentChanged(QWidget*)"), self.tabClicked) self.selectionChangedFlag = False
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "Data Table") self.inputs = [("Examples", ExampleTable, self.dataset, Multiple + Default)] self.outputs = [("Selected Examples", ExampleTable)] self.data = {} # key: id, value: ExampleTable self.showMetas = {} # key: id, value: (True/False, columnList) self.showMeta = 1 self.showAttributeLabels = 1 self.showDistributions = 1 self.distColorRgb = (220, 220, 220, 255) self.distColor = QColor(*self.distColorRgb) self.locale = QLocale() self.autoCommit = False self.loadSettings() # info box infoBox = OWGUI.widgetBox(self.controlArea, "Info") self.infoEx = OWGUI.widgetLabel(infoBox, 'No data on input.') self.infoMiss = OWGUI.widgetLabel(infoBox, ' ') OWGUI.widgetLabel(infoBox, ' ') self.infoAttr = OWGUI.widgetLabel(infoBox, ' ') self.infoMeta = OWGUI.widgetLabel(infoBox, ' ') OWGUI.widgetLabel(infoBox, ' ') self.infoClass = OWGUI.widgetLabel(infoBox, ' ') infoBox.setMinimumWidth(200) OWGUI.separator(self.controlArea) # settings box boxSettings = OWGUI.widgetBox(self.controlArea, "Settings") self.cbShowMeta = OWGUI.checkBox(boxSettings, self, "showMeta", 'Show meta attributes', callback=self.cbShowMetaClicked) self.cbShowMeta.setEnabled(False) self.cbShowAttLbls = OWGUI.checkBox( boxSettings, self, "showAttributeLabels", 'Show attribute labels (if any)', callback=self.cbShowAttLabelsClicked) self.cbShowAttLbls.setEnabled(True) self.cbShowDistributions = OWGUI.checkBox( boxSettings, self, "showDistributions", 'Visualize continuous values', callback=self.cbShowDistributions) colBox = OWGUI.indentedBox(boxSettings, sep=OWGUI.checkButtonOffsetHint( self.cbShowDistributions), orientation="horizontal") OWGUI.widgetLabel(colBox, "Color: ") self.colButton = OWGUI.toolButton(colBox, self, self.changeColor, width=20, height=20, debuggingEnabled=0) OWGUI.rubber(colBox) resizeColsBox = OWGUI.widgetBox(boxSettings, 0, "horizontal", 0) OWGUI.label(resizeColsBox, self, "Resize columns: ") OWGUI.toolButton(resizeColsBox, self, self.increaseColWidth, tooltip="Increase the width of the columns", width=20, height=20).setText("+") OWGUI.toolButton(resizeColsBox, self, self.decreaseColWidth, tooltip="Decrease the width of the columns", width=20, height=20).setText("-") OWGUI.rubber(resizeColsBox) self.btnResetSort = OWGUI.button( boxSettings, self, "Restore Order of Examples", callback=self.btnResetSortClicked, tooltip="Show examples in the same order as they appear in the file" ) OWGUI.separator(self.controlArea) selectionBox = OWGUI.widgetBox(self.controlArea, "Selection") self.sendButton = OWGUI.button(selectionBox, self, "Send selections", self.commit) cb = OWGUI.checkBox(selectionBox, self, "autoCommit", "Commit on any change", callback=self.commitIf) OWGUI.setStopper(self, self.sendButton, cb, "selectionChangedFlag", self.commit) OWGUI.rubber(self.controlArea) # GUI with tabs self.tabs = OWGUI.tabWidget(self.mainArea) self.id2table = {} # key: widget id, value: table self.table2id = {} # key: table, value: widget id self.connect(self.tabs, SIGNAL("currentChanged(QWidget*)"), self.tabClicked) self.selectionChangedFlag = False self.updateColor()
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "Rank") # ,wantMainArea = 0) self.inputs = [("Examples", ExampleTable, self.setData)] self.outputs = [ ("Reduced Example Table", ExampleTable, Default + Single), ("ExampleTable Attributes", ExampleTable, NonDefault), ] self.settingsList += self.measuresAttrs self.nDecimals = 3 self.reliefK = 10 self.reliefN = 20 self.nIntervals = 4 self.sortBy = 0 self.selectMethod = 3 self.nSelected = 5 self.showDistributions = 1 self.distColorRgb = (220, 220, 220, 255) self.distColor = QColor(*self.distColorRgb) self.autoApply = True for meas in self.measuresAttrs: setattr(self, meas, True) self.loadSettings() labelWidth = 80 box = OWGUI.widgetBox(self.controlArea, "Measures", addSpace=True) for meas, valueName in zip(self.measures, self.measuresAttrs): OWGUI.checkBox(box, self, valueName, meas, callback=self.measuresChanged) if valueName == "computeReliefF": ibox = OWGUI.indentedBox(box) OWGUI.spin( ibox, self, "reliefK", 1, 20, label="Neighbours", labelWidth=labelWidth, orientation=0, callback=self.reliefChanged, callbackOnReturn=True, ) OWGUI.spin( ibox, self, "reliefN", 20, 100, label="Examples", labelWidth=labelWidth, orientation=0, callback=self.reliefChanged, callbackOnReturn=True, ) OWGUI.separator(box) OWGUI.comboBox( box, self, "sortBy", label="Sort by" + " ", items=["No Sorting", "Attribute Name", "Number of Values"] + self.measures, orientation=0, valueType=int, callback=self.sortingChanged, ) box = OWGUI.widgetBox(self.controlArea, "Discretization", addSpace=True) OWGUI.spin( box, self, "nIntervals", 2, 20, label="Intervals", labelWidth=labelWidth, orientation=0, callback=self.discretizationChanged, callbackOnReturn=True, ) box = OWGUI.widgetBox(self.controlArea, "Precision", addSpace=True) OWGUI.spin( box, self, "nDecimals", 1, 6, label="No. of decimals", labelWidth=labelWidth, orientation=0, callback=self.decimalsChanged, ) box = OWGUI.widgetBox(self.controlArea, "Distributions", addSpace=True) self.cbShowDistributions = OWGUI.checkBox( box, self, "showDistributions", "Visualize values", callback=self.cbShowDistributions ) colBox = OWGUI.indentedBox(box, orientation="horizontal") OWGUI.widgetLabel(colBox, "Color: ") self.colButton = OWGUI.toolButton(colBox, self, self.changeColor, width=20, height=20, debuggingEnabled=0) OWGUI.rubber(colBox) OWGUI.rubber(self.controlArea) selMethBox = OWGUI.radioButtonsInBox( self.controlArea, self, "selectMethod", ["None", "All", "Manual", "Best ranked"], box="Select attributes", callback=self.selectMethodChanged, ) self.selNAttr = OWGUI.spin( OWGUI.indentedBox(selMethBox), self, "nSelected", 1, 100, label="No. selected" + " ", orientation=0, callback=self.nSelectedChanged, ) OWGUI.separator(selMethBox) applyButton = OWGUI.button(selMethBox, self, "Commit", callback=self.apply) autoApplyCB = OWGUI.checkBox(selMethBox, self, "autoApply", "Commit automatically") OWGUI.setStopper(self, applyButton, autoApplyCB, "dataChanged", self.apply) self.table = QTableWidget() self.mainArea.layout().addWidget(self.table) self.table.setSelectionBehavior(QAbstractItemView.SelectRows) self.table.setSelectionMode(QAbstractItemView.MultiSelection) self.table.verticalHeader().setResizeMode(QHeaderView.ResizeToContents) self.table.setItemDelegate(RankItemDelegate(self, self.table)) self.topheader = self.table.horizontalHeader() self.topheader.setSortIndicatorShown(1) self.topheader.setHighlightSections(0) self.resetInternals() self.apply() self.connect(self.table.horizontalHeader(), SIGNAL("sectionClicked(int)"), self.headerClick) self.connect(self.table, SIGNAL("clicked (const QModelIndex&)"), self.selectItem) self.resize(690, 500) self.updateColor()