def __init__(self, parent=None): OWWidget.__init__(self, parent, title='X Learner') self.method= 0 self.maxi = 1 self.cheat = 0 self.autoApply = True self.settingsChanged = False OWGUI.radioButtonsInBox(self.controlArea, self, "method", ["Vanishing", "Disappearing", "Invisibilisation"], box="Minimization technique", callback = self.applyIf) OWGUI.separator(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Settings") OWGUI.checkBox(box, self, "maxi", "Post-maximize", callback = self.applyIf) OWGUI.checkBox(box, self, "cheat", "Quasi-cheating", callback = self.applyIf) OWGUI.separator(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Apply") applyButton = OWGUI.button(box, self, "Apply", callback = self.apply) autoApplyCB = OWGUI.checkBox(box, self, "autoApply", "Apply automatically") OWGUI.setStopper(self, applyButton, autoApplyCB, "settingsChanged", self.apply) self.adjustSize()
def __init__(self,parent=None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "Confusion Matrix", 1) # inputs self.inputs=[("Evaluation Results", orngTest.ExperimentResults, self.setTestResults, Default)] self.outputs=[("Selected Data", ExampleTable, 8)] self.selectedLearner = [] self.learnerNames = [] self.selectionDirty = 0 self.autoApply = True self.appendPredictions = True self.appendProbabilities = False self.shownQuantity = 0 self.learnerList = OWGUI.listBox(self.controlArea, self, "selectedLearner", "learnerNames", box = "Learners", callback = self.learnerChanged) self.learnerList.setMinimumHeight(100) OWGUI.separator(self.controlArea) OWGUI.comboBox(self.controlArea, self, "shownQuantity", items = self.quantities, box = "Show", callback=self.reprint) OWGUI.separator(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Selection") #, addSpace=True) OWGUI.button(box, self, "Correct", callback=self.selectCorrect) OWGUI.button(box, self, "Misclassified", callback=self.selectWrong) OWGUI.button(box, self, "None", callback=self.selectNone) OWGUI.separator(self.controlArea) self.outputBox = box = OWGUI.widgetBox(self.controlArea, "Output") OWGUI.checkBox(box, self, "appendPredictions", "Append class predictions", callback = self.sendIf) OWGUI.checkBox(box, self, "appendProbabilities", "Append predicted class probabilities", callback = self.sendIf) applyButton = OWGUI.button(box, self, "Commit", callback = self.sendData, default=True) autoApplyCB = OWGUI.checkBox(box, self, "autoApply", "Commit automatically") OWGUI.setStopper(self, applyButton, autoApplyCB, "selectionDirty", self.sendData) import sip sip.delete(self.mainArea.layout()) self.layout = QGridLayout(self.mainArea) self.layout.addWidget(OWGUI.widgetLabel(self.mainArea, "Prediction"), 0, 1, Qt.AlignCenter) label = TransformedLabel("Correct Class") self.layout.addWidget(label, 2, 0, Qt.AlignCenter) # self.layout.addWidget(OWGUI.widgetLabel(self.mainArea, "Correct Class "), 2, 0, Qt.AlignCenter) self.table = OWGUI.table(self.mainArea, rows = 0, columns = 0, selectionMode = QTableWidget.MultiSelection, addToLayout = 0) self.layout.addWidget(self.table, 2, 1) self.layout.setColumnStretch(1, 100) self.layout.setRowStretch(2, 100) self.connect(self.table, SIGNAL("itemSelectionChanged()"), self.sendIf) self.res = None self.matrix = None self.selectedLearner = None self.resize(700,450)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'PurgeDomain') self.settingsList=["removeValues", "removeAttributes", "removeClassAttribute", "removeClasses", "autoSend", "sortValues", "sortClasses"] self.inputs = [("Examples", ExampleTable, self.setData)] self.outputs = [("Examples", ExampleTable)] self.data = None self.preRemoveValues = self.removeValues = 1 self.removeAttributes = 1 self.removeClassAttribute = 1 self.preRemoveClasses = self.removeClasses = 1 self.autoSend = 1 self.dataChanged = False self.sortValues = self.sortClasses = True self.loadSettings() self.removedAttrs = self.reducedAttrs = self.resortedAttrs = self.classAttr = "-" boxAt = OWGUI.widgetBox(self.controlArea, "Attributes") OWGUI.checkBox(boxAt, self, 'sortValues', 'Sort attribute values', callback = self.optionsChanged) rua = OWGUI.checkBox(boxAt, self, "removeAttributes", "Remove attributes with less than two values", callback = self.removeAttributesChanged) boxH = OWGUI.widgetBox(boxAt, orientation="horizontal") OWGUI.separator(boxH, width=30, height=0) ruv = OWGUI.checkBox(boxH, self, "removeValues", "Remove unused attribute values", callback = self.optionsChanged) rua.disables = [ruv] OWGUI.separator(self.controlArea) boxAt = OWGUI.widgetBox(self.controlArea, "Classes") OWGUI.checkBox(boxAt, self, 'sortClasses', 'Sort classes', callback = self.optionsChanged) rua = OWGUI.checkBox(boxAt, self, "removeClassAttribute", "Remove class attribute if there are less than two classes", callback = self.removeClassesChanged) boxH = OWGUI.widgetBox(boxAt, orientation="horizontal") OWGUI.separator(boxH, width=30, height=0) ruv = OWGUI.checkBox(boxH, self, "removeClasses", "Remove unused class values", callback = self.optionsChanged) rua.disables = [ruv] OWGUI.separator(self.controlArea) box2 = OWGUI.widgetBox(self.controlArea) btSend = OWGUI.button(box2, self, "Send data", callback = self.process) cbAutoSend = OWGUI.checkBox(box2, self, "autoSend", "Send automatically") OWGUI.setStopper(self, btSend, cbAutoSend, "dataChanged", self.process) OWGUI.separator(self.controlArea, height=24) box3 = OWGUI.widgetBox(self.controlArea, 'Statistics') OWGUI.label(box3, self, "Removed attributes: %(removedAttrs)s") OWGUI.label(box3, self, "Reduced attributes: %(reducedAttrs)s") OWGUI.label(box3, self, "Resorted attributes: %(resortedAttrs)s") OWGUI.label(box3, self, "Class attribute: %(classAttr)s")
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'PurgeDomain', wantMainArea=False) self.settingsList=["removeValues", "removeAttributes", "removeClassAttribute", "removeClasses", "autoSend", "sortValues", "sortClasses"] self.inputs = [("Data", ExampleTable, self.setData)] self.outputs = [("Data", ExampleTable)] self.data = None self.preRemoveValues = self.removeValues = 1 self.removeAttributes = 1 self.removeClassAttribute = 1 self.preRemoveClasses = self.removeClasses = 1 self.autoSend = 1 self.dataChanged = False self.sortValues = self.sortClasses = True self.loadSettings() self.removedAttrs = self.reducedAttrs = self.resortedAttrs = self.classAttr = "-" boxAt = OWGUI.widgetBox(self.controlArea, "Attributes", addSpace=True) OWGUI.checkBox(boxAt, self, 'sortValues', 'Sort attribute values', callback = self.optionsChanged) rua = OWGUI.checkBox(boxAt, self, "removeAttributes", "Remove attributes with less than two values", callback = self.removeAttributesChanged) ruv = OWGUI.checkBox(OWGUI.indentedBox(boxAt, sep=OWGUI.checkButtonOffsetHint(rua)), self, "removeValues", "Remove unused attribute values", callback = self.optionsChanged) rua.disables = [ruv] rua.makeConsistent() boxAt = OWGUI.widgetBox(self.controlArea, "Classes", addSpace=True) OWGUI.checkBox(boxAt, self, 'sortClasses', 'Sort classes', callback = self.optionsChanged) rua = OWGUI.checkBox(boxAt, self, "removeClassAttribute", "Remove class attribute if there are less than two classes", callback = self.removeClassesChanged) ruv = OWGUI.checkBox(OWGUI.indentedBox(boxAt, sep=OWGUI.checkButtonOffsetHint(rua)), self, "removeClasses", "Remove unused class values", callback = self.optionsChanged) rua.disables = [ruv] rua.makeConsistent() box3 = OWGUI.widgetBox(self.controlArea, 'Statistics', addSpace=True) OWGUI.label(box3, self, "Removed attributes: %(removedAttrs)s") OWGUI.label(box3, self, "Reduced attributes: %(reducedAttrs)s") OWGUI.label(box3, self, "Resorted attributes: %(resortedAttrs)s") OWGUI.label(box3, self, "Class attribute: %(classAttr)s") box2 = OWGUI.widgetBox(self.controlArea, "Send") btSend = OWGUI.button(box2, self, "Send data", callback = self.process, default=True) cbAutoSend = OWGUI.checkBox(box2, self, "autoSend", "Send automatically") OWGUI.setStopper(self, btSend, cbAutoSend, "dataChanged", self.process) OWGUI.rubber(self.controlArea)
def __init__(self,parent=None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "Itemsets explorer") self.inputs = [("Itemsets", Itemsets, self.setItemsets)] self.outputs = [("Itemsets", Itemsets), ("Data", ExampleTable)] self.showWholeItemsets = 1 self.treeDepth = 2 self.autoSend = True self.dataChanged = False self.purgeAttributes = True self.purgeClasses = True self.nItemsets = self.nSelectedItemsets = self.nSelectedExamples = "" self.loadSettings() self.treeItemsets = QTreeWidget(self.mainArea) self.mainArea.layout().addWidget(self.treeItemsets) self.treeItemsets.setSelectionMode (QTreeWidget.ExtendedSelection) self.treeItemsets.setHeaderLabels(["Itemsets", "Examples"]) self.treeItemsets.setAllColumnsShowFocus ( 1) self.treeItemsets.setAlternatingRowColors(1) self.treeItemsets.setColumnCount(2) self.connect(self.treeItemsets,SIGNAL("itemSelectionChanged()"),self. selectionChanged) box = OWGUI.widgetBox(self.controlArea, "Info", addSpace = True) OWGUI.label(box, self, "Number of itemsets: %(nItemsets)s") OWGUI.label(box, self, "Selected itemsets: %(nSelectedItemsets)s") OWGUI.label(box, self, "Selected examples: %(nSelectedExamples)s") box = OWGUI.widgetBox(self.controlArea, "Tree", addSpace = True) OWGUI.spin(box, self, "treeDepth", label = "Tree depth", min = 1, max = 10, step = 1, callback = self.populateTree, callbackOnReturn = True) OWGUI.checkBox(box, self, "showWholeItemsets", "Display whole itemsets", callback = self.setWholeItemsets) OWGUI.button(box, self, "Expand All", callback = lambda: self.treeItemsets.expandAll()) OWGUI.button(box, self, "Collapse", callback = lambda: self.treeItemsets.collapseAll()) OWGUI.rubber(self.controlArea) boxSettings = OWGUI.widgetBox(self.controlArea, 'Send selection') OWGUI.checkBox(boxSettings, self, "purgeAttributes", "Purge attribute values/attributes", box=None, callback=self.purgeChanged) self.purgeClassesCB = OWGUI.checkBox(OWGUI.indentedBox(boxSettings), self, "purgeClasses", "Purge class attribute", callback=self.purgeChanged) if not self.purgeAttributes: self.purgeClassesCB.setEnabled(False) self.oldPurgeClasses = False cbSendAuto = OWGUI.checkBox(boxSettings, self, "autoSend", "Send immediately", box=None) btnUpdate = OWGUI.button(boxSettings, self, "Send", self.sendData, default=True) OWGUI.setStopper(self, btnUpdate, cbSendAuto, "dataChanged", self.sendData) self.itemsets= None
def __init__(self, parent=None, signalManger=None, title="Data Sort"): super(OWDataSort, self).__init__(parent, signalManger, title, wantMainArea=False) #: Mapping (feature.name, feature.var_type) to (sort_index, sort_order) #: where sirt index is the position of the feature in the sortByModel #: and sort_order the Qt.SortOrder flag self.sortroles = {} self.autoCommit = False self._outputChanged = False box = OWGUI.widgetBox(self.controlArea, "Sort By Features") self.sortByView = QListView() self.sortByView.setItemDelegate(SortParamDelegate(self)) self.sortByView.setSelectionMode(QListView.ExtendedSelection) self.sortByView.setDragDropMode(QListView.DragDrop) self.sortByView.setDefaultDropAction(Qt.MoveAction) self.sortByView.viewport().setAcceptDrops(True) self.sortByModel = VariableListModel( flags=Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsDragEnabled | Qt.ItemIsEditable ) self.sortByView.setModel(self.sortByModel) box.layout().addWidget(self.sortByView) box = OWGUI.widgetBox(self.controlArea, "Unused Features") self.unusedView = QListView() self.unusedView.setSelectionMode(QListView.ExtendedSelection) self.unusedView.setDragDropMode(QListView.DragDrop) self.unusedView.setDefaultDropAction(Qt.MoveAction) self.unusedView.viewport().setAcceptDrops(True) self.unusedModel = VariableListModel( flags=Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsDragEnabled ) self.unusedView.setModel(self.unusedModel) box.layout().addWidget(self.unusedView) box = OWGUI.widgetBox(self.controlArea, "Output") cb = OWGUI.checkBox(box, self, "autoCommit", "Auto commit") b = OWGUI.button(box, self, "Commit", callback=self.commit) OWGUI.setStopper(self, b, cb, "_outputChanged", callback=self.commit)
def __init__(self, parent=None): OWWidget.__init__(self, parent, title='X Learner') self.method = 0 self.maxi = 1 self.cheat = 0 self.autoApply = True self.settingsChanged = False OWGUI.radioButtonsInBox( self.controlArea, self, "method", ["Vanishing", "Disappearing", "Invisibilisation"], box="Minimization technique", callback=self.applyIf) OWGUI.separator(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Settings") OWGUI.checkBox(box, self, "maxi", "Post-maximize", callback=self.applyIf) OWGUI.checkBox(box, self, "cheat", "Quasi-cheating", callback=self.applyIf) OWGUI.separator(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Apply") applyButton = OWGUI.button(box, self, "Apply", callback=self.apply) autoApplyCB = OWGUI.checkBox(box, self, "autoApply", "Apply automatically") OWGUI.setStopper(self, applyButton, autoApplyCB, "settingsChanged", self.apply) self.adjustSize()
def __init__(self,parent=None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "Association rules viewer") self.inputs = [("Association Rules", orange.AssociationRules, self.arules)] self.outputs = [("Association Rules", orange.AssociationRules), ("Covered Data", ExampleTable), ("Matching Data", ExampleTable), ("Mismatched Data", ExampleTable)] self.showWholeRules = 1 self.treeDepth = 2 self.autoSend = True self.dataChanged = False self.purgeAttributes = True self.purgeClasses = True self.nRules = self.nSelectedRules = self.nSelectedExamples = self.nMatchingExamples = self.nMismatchingExamples = "" self.showsupport = self.showconfidence = 1 self.showlift = self.showleverage = self.showstrength = self.showcoverage = 0 self.loadSettings() # self.grid = QGridLayout() # rightUpRight = OWGUI.widgetBox(self.mainArea, box="Shown measures", orientation = self.grid) # self.cbMeasures = [OWGUI.checkBox(rightUpRight, self, "show"+attr, long, callback = self.showHideColumn, addToLayout = 0) for long, short, attr in self.measures] # for i, cb in enumerate(self.cbMeasures): # self.grid.addWidget(cb, i % 2, i / 2) box = OWGUI.widgetBox(self.mainArea, orientation = 0) OWGUI.widgetLabel(box, "Shown measures: ") self.cbMeasures = [OWGUI.checkBox(box, self, "show"+attr, long+" ", callback = self.showHideColumn) for long, short, attr in self.measures] OWGUI.rubber(box) self.treeRules = QTreeWidget(self.mainArea) self.mainArea.layout().addWidget(self.treeRules) self.treeRules.setSelectionMode (QTreeWidget.ExtendedSelection) self.treeRules.setHeaderLabels(["Rules"] + [m[1] for m in self.measures]) self.treeRules.setAllColumnsShowFocus ( 1) self.treeRules.setAlternatingRowColors(1) self.showHideColumn() self.connect(self.treeRules,SIGNAL("itemSelectionChanged()"),self. selectionChanged) box = OWGUI.widgetBox(self.controlArea, "Info", addSpace = True) OWGUI.label(box, self, "Number of rules: %(nRules)s") OWGUI.label(box, self, "Selected rules: %(nSelectedRules)s") OWGUI.label(box, self, "Selected examples: %(nSelectedExamples)s") ibox = OWGUI.indentedBox(box) OWGUI.label(ibox, self, "... matching: %(nMatchingExamples)s") OWGUI.label(ibox, self, "... mismatching: %(nMismatchingExamples)s") box = OWGUI.widgetBox(self.controlArea, "Options", addSpace = True) OWGUI.spin(box, self, "treeDepth", label = "Tree depth", min = 0, max = 10, step = 1, callback = self.displayRules, callbackOnReturn = True) OWGUI.separator(box) OWGUI.checkBox(box, self, "showWholeRules", "Display whole rules", callback = self.setWholeRules) OWGUI.rubber(self.controlArea) boxSettings = OWGUI.widgetBox(self.controlArea, 'Send selection') OWGUI.checkBox(boxSettings, self, "purgeAttributes", "Purge attribute values/attributes", box=None, callback=self.purgeChanged) self.purgeClassesCB = OWGUI.checkBox(OWGUI.indentedBox(boxSettings), self, "purgeClasses", "Purge class attribute", callback=self.purgeChanged) if not self.purgeAttributes: self.purgeClassesCB.setEnabled(False) self.oldPurgeClasses = False cbSendAuto = OWGUI.checkBox(boxSettings, self, "autoSend", "Send immediately", box=None) btnUpdate = OWGUI.button(boxSettings, self, "Send", self.sendData, default=True) OWGUI.setStopper(self, btnUpdate, cbSendAuto, "dataChanged", self.sendData) self.rules = None
def __init__(self, parent=None, signalManager=None, name="SOM visualizer"): OWWidget.__init__(self, parent, signalManager, name) self.inputs = [("SOMMap", orngSOM.SOMMap, self.setSomMap), ("Examples", ExampleTable, self.data)] self.outputs = [("Examples", ExampleTable)] self.labelNodes = 0 self.commitOnChange = 0 self.backgroundCheck = 1 self.backgroundMode = 0 self.histogram = 1 self.attribute = 0 self.discHistMode = 0 self.targetValue = 0 self.contHistMode = 0 self.inputSet = 0 self.somMap = None self.examples = None self.selectionChanged = False ## layout = QVBoxLayout(self.mainArea) #,QVBoxLayout.TopToBottom,0) self.scene = SOMScene(self, self) self.sceneView = QGraphicsView(self.scene, self.mainArea) self.sceneView.viewport().setMouseTracking(True) self.mainArea.layout().addWidget(self.sceneView) self.loadSettings() call = lambda: self.scene.redrawSom() histTab = mainTab = self.controlArea self.mainTab = mainTab self.histTab = histTab self.backgroundBox = OWGUI.widgetBox(mainTab, "Background") #OWGUI.checkBox(self.backgroundBox, self, "backgroundCheck","Show background", callback=self.setBackground) b = OWGUI.radioButtonsInBox(self.backgroundBox, self, "scene.drawMode", self.drawModes, callback=self.setBackground) b.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)) self.componentCombo = OWGUI.comboBox(OWGUI.indentedBox(b), self, "scene.component", callback=self.setBackground) self.componentCombo.setEnabled(self.scene.drawMode == 2) OWGUI.checkBox(self.backgroundBox, self, "scene.showGrid", "Show grid", callback=self.scene.updateGrid) #b=OWGUI.widgetBox(mainTab, "Histogram") #OWGUI.separator(mainTab) b = OWGUI.widgetBox(mainTab, "Histogram") ##QVButtonGroup("Histogram", mainTab) # b.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)) OWGUI.checkBox(b, self, "histogram", "Show histogram", callback=self.setHistogram) OWGUI.radioButtonsInBox(OWGUI.indentedBox(b), self, "inputSet", ["Use training set", "Use input subset"], callback=self.setHistogram) #OWGUI.separator(mainTab) b1 = OWGUI.widgetBox(mainTab) ##QVBox(mainTab) # b1.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)) b = OWGUI.hSlider(b1, self, "scene.objSize", "Plot size", 10, 100, step=10, ticks=10, callback=call) # b.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)) #OWGUI.checkBox(b1, self, "labelNodes", "Node Labeling", callback=self.canvas.updateLabels) #OWGUI.separator(b1) b1 = OWGUI.widgetBox(b1, "Tooltip Info") OWGUI.checkBox(b1, self, "scene.showToolTip", "Show tooltip", callback=self.scene.updateToolTips) OWGUI.checkBox(b1, self, "scene.includeCodebook", "Include codebook vector", callback=self.scene.updateToolTips) b1.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)) #OWGUI.separator(mainTab) self.histogramBox = OWGUI.widgetBox(histTab, "Coloring") self.attributeCombo = OWGUI.comboBox(self.histogramBox, self, "attribute", callback=self.setHistogram) self.discTab = OWGUI.radioButtonsInBox( OWGUI.indentedBox(self.histogramBox), self, "discHistMode", ["Pie chart", "Majority value", "Majority value prob."], box=1, callback=self.setHistogram) self.discTab.setSizePolicy( QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)) #self.targetValueCombo=OWGUI.comboBox(b, self, "targetValue", callback=self.setHistogram) ## QVBox(discTab) ## b=QVButtonGroup(contTab) ## b.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)) self.contTab = OWGUI.radioButtonsInBox( OWGUI.indentedBox(self.histogramBox), self, "contHistMode", ["Default", "Average value"], box=1, callback=self.setHistogram) self.contTab.setSizePolicy( QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)) ## QVBox(contTab) ## OWGUI.rubber(mainTab) b = OWGUI.widgetBox(self.controlArea, "Selection") OWGUI.button(b, self, "&Invert selection", callback=self.scene.invertSelection) button = OWGUI.button(b, self, "&Commit", callback=self.commit) check = OWGUI.checkBox(b, self, "commitOnChange", "Commit on change") OWGUI.setStopper(self, button, check, "selectionChanged", self.commit) OWGUI.separator(self.controlArea) OWGUI.button(self.controlArea, self, "&Save Graph", callback=self.saveGraph, debuggingEnabled=0) self.selectionList = [] self.ctrlPressed = False ## self.setFocusPolicy(QWidget.StrongFocus) self.resize(800, 500)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "Association rules viewer") self.inputs = [("Association Rules", orange.AssociationRules, self.arules)] self.outputs = [("Association Rules", orange.AssociationRules), ("Covered Data", ExampleTable), ("Matching Data", ExampleTable), ("Mismatched Data", ExampleTable)] self.showWholeRules = 1 self.treeDepth = 2 self.autoSend = True self.dataChanged = False self.purgeAttributes = True self.purgeClasses = True self.nRules = self.nSelectedRules = self.nSelectedExamples = self.nMatchingExamples = self.nMismatchingExamples = "" self.showsupport = self.showconfidence = 1 self.showlift = self.showleverage = self.showstrength = self.showcoverage = 0 self.loadSettings() # self.grid = QGridLayout() # rightUpRight = OWGUI.widgetBox(self.mainArea, box="Shown measures", orientation = self.grid) # self.cbMeasures = [OWGUI.checkBox(rightUpRight, self, "show"+attr, long, callback = self.showHideColumn, addToLayout = 0) for long, short, attr in self.measures] # for i, cb in enumerate(self.cbMeasures): # self.grid.addWidget(cb, i % 2, i / 2) box = OWGUI.widgetBox(self.mainArea, orientation=0) OWGUI.widgetLabel(box, "Shown measures: ") self.cbMeasures = [ OWGUI.checkBox(box, self, "show" + attr, long + " ", callback=self.showHideColumn) for long, short, attr in self.measures ] OWGUI.rubber(box) self.treeRules = QTreeWidget(self.mainArea) self.mainArea.layout().addWidget(self.treeRules) self.treeRules.setSelectionMode(QTreeWidget.ExtendedSelection) self.treeRules.setHeaderLabels(["Rules"] + [m[1] for m in self.measures]) self.treeRules.setAllColumnsShowFocus(1) self.treeRules.setAlternatingRowColors(1) self.showHideColumn() self.connect(self.treeRules, SIGNAL("itemSelectionChanged()"), self.selectionChanged) box = OWGUI.widgetBox(self.controlArea, "Info", addSpace=True) OWGUI.label(box, self, "Number of rules: %(nRules)s") OWGUI.label(box, self, "Selected rules: %(nSelectedRules)s") OWGUI.label(box, self, "Selected examples: %(nSelectedExamples)s") ibox = OWGUI.indentedBox(box) OWGUI.label(ibox, self, "... matching: %(nMatchingExamples)s") OWGUI.label(ibox, self, "... mismatching: %(nMismatchingExamples)s") box = OWGUI.widgetBox(self.controlArea, "Options", addSpace=True) OWGUI.spin(box, self, "treeDepth", label="Tree depth", min=0, max=10, step=1, callback=self.displayRules, callbackOnReturn=True) OWGUI.separator(box) OWGUI.checkBox(box, self, "showWholeRules", "Display whole rules", callback=self.setWholeRules) OWGUI.rubber(self.controlArea) boxSettings = OWGUI.widgetBox(self.controlArea, 'Send selection') OWGUI.checkBox(boxSettings, self, "purgeAttributes", "Purge attribute values/attributes", box=None, callback=self.purgeChanged) self.purgeClassesCB = OWGUI.checkBox(OWGUI.indentedBox(boxSettings), self, "purgeClasses", "Purge class attribute", callback=self.purgeChanged) if not self.purgeAttributes: self.purgeClassesCB.setEnabled(False) self.oldPurgeClasses = False cbSendAuto = OWGUI.checkBox(boxSettings, self, "autoSend", "Send immediately", box=None) btnUpdate = OWGUI.button(boxSettings, self, "Send", self.sendData, default=True) OWGUI.setStopper(self, btnUpdate, cbSendAuto, "dataChanged", self.sendData) self.rules = None
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, 'Hierarchical Clustering', wantGraph=True) self.inputs = [("Distances", Orange.misc.SymMatrix, self.set_matrix)] self.outputs = [("Selected Data", Orange.data.Table), ("Other Data", Orange.data.Table), ("Centroids", Orange.data.Table)] self.linkage = [ ("Single linkage", hierarchical.HierarchicalClustering.Single), ("Average linkage", hierarchical.HierarchicalClustering.Average), ("Ward's linkage", hierarchical.HierarchicalClustering.Ward), ("Complete linkage", hierarchical.HierarchicalClustering.Complete), ] self.Linkage = 3 self.Annotation = 0 self.PrintDepthCheck = 0 self.PrintDepth = 10 # initial horizontal and vertical dendrogram size self.HDSize = 500 self.VDSize = 800 self.ManualHorSize = 0 self.AutoResize = 0 self.TextSize = 8 self.LineSpacing = 4 self.SelectionMode = 0 self.AppendClusters = 0 self.CommitOnChange = 0 self.ClassifyName = "HC_class" self.addIdAs = 0 self.loadSettings() self.inputMatrix = None self.root_cluster = None self.selectedExamples = None self.selectionChanged = False self.linkageMethods = [a[0] for a in self.linkage] ################################# ##GUI ################################# #HC Settings OWGUI.comboBox(self.controlArea, self, "Linkage", box="Linkage", items=self.linkageMethods, tooltip="Choose linkage method", callback=self.run_clustering, addSpace=True) #Label box = OWGUI.widgetBox(self.controlArea, "Annotation", addSpace=True) self.labelCombo = OWGUI.comboBox( box, self, "Annotation", items=["None"], tooltip="Choose label attribute", callback=self.update_labels ) OWGUI.spin(box, self, "TextSize", label="Text size", min=5, max=15, step=1, callback=self.update_font, controlWidth=40, keyboardTracking=False) # Dendrogram graphics settings dendrogramBox = OWGUI.widgetBox(self.controlArea, "Limits", addSpace=True) form = QFormLayout() form.setLabelAlignment(Qt.AlignLeft) # Depth settings sw = OWGUI.widgetBox(dendrogramBox, orientation="horizontal", addToLayout=False) cw = OWGUI.widgetBox(dendrogramBox, orientation="horizontal", addToLayout=False) OWGUI.hSlider(sw, self, "PrintDepth", minValue=1, maxValue=50, callback=self.on_depth_change) cblp = OWGUI.checkBox(cw, self, "PrintDepthCheck", "Show to depth", callback=self.on_depth_change, disables=[sw]) form.addRow(cw, sw) checkWidth = OWGUI.checkButtonOffsetHint(cblp) # Width settings sw = OWGUI.widgetBox(dendrogramBox, orientation="horizontal", addToLayout=False) cw = OWGUI.widgetBox(dendrogramBox, orientation="horizontal", addToLayout=False) hsb = OWGUI.spin(sw, self, "HDSize", min=200, max=10000, step=10, callback=self.on_width_changed, callbackOnReturn=False, keyboardTracking=False) OWGUI.checkBox(cw, self, "ManualHorSize", "Horizontal size", callback=self.on_width_changed, disables=[sw]) sw.setEnabled(self.ManualHorSize) self.hSizeBox = hsb form.addRow(cw, sw) dendrogramBox.layout().addLayout(form) # Selection settings box = OWGUI.widgetBox(self.controlArea, "Selection") OWGUI.checkBox(box, self, "SelectionMode", "Show cutoff line", callback=self.update_cutoff_line) cb = OWGUI.checkBox(box, self, "AppendClusters", "Append cluster IDs", callback=self.commit_data_if) self.classificationBox = ib = OWGUI.widgetBox(box, margin=0) form = QWidget() le = OWGUI.lineEdit(form, self, "ClassifyName", None, callback=None, orientation="horizontal") self.connect(le, SIGNAL("editingFinished()"), self.commit_data_if) aa = OWGUI.comboBox(form, self, "addIdAs", label=None, orientation="horizontal", items=["Class attribute", "Attribute", "Meta attribute"], callback=self.commit_data_if) layout = QFormLayout() layout.setSpacing(8) layout.setContentsMargins(0, 5, 0, 5) layout.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow) layout.setLabelAlignment(Qt.AlignLeft) layout.addRow("Name ", le) layout.addRow("Place ", aa) form.setLayout(layout) ib.layout().addWidget(form) ib.layout().setContentsMargins(checkWidth, 5, 5, 5) cb.disables.append(ib) cb.makeConsistent() OWGUI.separator(box) cbAuto = OWGUI.checkBox(box, self, "CommitOnChange", "Commit on change") btCommit = OWGUI.button(box, self, "&Commit", self.commit_data, default=True) OWGUI.setStopper(self, btCommit, cbAuto, "selectionChanged", self.commit_data) OWGUI.rubber(self.controlArea) self.connect(self.graphButton, SIGNAL("clicked()"), self.saveGraph) self.scale_scene = scale = ScaleScene(self, self) self.headerView = ScaleView(scale, self) self.footerView = ScaleView(scale, self) self.dendrogram = DendrogramScene(self) self.dendrogramView = DendrogramView(self.dendrogram, self.mainArea) self.connect(self.dendrogram, SIGNAL("clusterSelectionChanged()"), self.on_selection_change) self.connect(self.dendrogram, SIGNAL("sceneRectChanged(QRectF)"), scale.scene_rect_update) self.connect(self.dendrogram, SIGNAL("dendrogramGeometryChanged(QRectF)"), self.on_dendrogram_geometry_change) self.connect(self.dendrogram, SIGNAL("cutoffValueChanged(float)"), self.on_cuttof_value_changed) self.connect(self.dendrogramView, SIGNAL("viewportResized(QSize)"), self.on_width_changed) self.connect(self.dendrogramView, SIGNAL("transformChanged(QTransform)"), self.headerView.setTransform) self.connect(self.dendrogramView, SIGNAL("transformChanged(QTransform)"), self.footerView.setTransform) self.mainArea.layout().addWidget(self.headerView) self.mainArea.layout().addWidget(self.dendrogramView) self.mainArea.layout().addWidget(self.footerView) self.dendrogram.header = self.headerView self.dendrogram.footer = self.footerView self.connect(self.dendrogramView.horizontalScrollBar(), SIGNAL("valueChanged(int)"), self.footerView.horizontalScrollBar().setValue) self.connect(self.dendrogramView.horizontalScrollBar(), SIGNAL("valueChanged(int)"), self.headerView.horizontalScrollBar().setValue) self.dendrogram.setSceneRect(0, 0, self.HDSize, self.VDSize) self.dendrogram.update() self.resize(800, 500) self.natural_dendrogram_width = 800 self.dendrogramView.set_fit_to_width(not self.ManualHorSize) self.matrix = None self.selectionList = [] self.selected_clusters = []
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, 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, title="PCA"): OWWidget.__init__(self, parent, signalManager, title, wantGraph=True) self.inputs = [("Input Data", Orange.data.Table, self.set_data)] self.outputs = [("Transformed Data", Orange.data.Table, Default), ("Eigen Vectors", Orange.data.Table)] self.standardize = True self.max_components = 0 self.variance_covered = 100.0 self.use_generalized_eigenvectors = False self.auto_commit = False self.loadSettings() self.data = None self.changed_flag = False ##### # GUI ##### grid = QGridLayout() box = OWGUI.widgetBox(self.controlArea, "Components Selection", orientation=grid) label1 = QLabel("Max components", box) grid.addWidget(label1, 1, 0) sb1 = OWGUI.spin(box, self, "max_components", 0, 1000, tooltip="Maximum number of components", callback=self.on_update, addToLayout=False, keyboardTracking=False ) self.max_components_spin = sb1.control self.max_components_spin.setSpecialValueText("All") grid.addWidget(sb1.control, 1, 1) label2 = QLabel("Variance covered", box) grid.addWidget(label2, 2, 0) sb2 = OWGUI.doubleSpin(box, self, "variance_covered", 1.0, 100.0, 1.0, tooltip="Percent of variance covered.", callback=self.on_update, decimals=1, addToLayout=False, keyboardTracking=False ) sb2.control.setSuffix("%") grid.addWidget(sb2.control, 2, 1) OWGUI.rubber(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Commit") cb = OWGUI.checkBox(box, self, "auto_commit", "Commit on any change") b = OWGUI.button(box, self, "Commit", callback=self.update_components) OWGUI.setStopper(self, b, cb, "changed_flag", self.update_components) self.plot = Graph() canvas = self.plot.canvas() canvas.setFrameStyle(QFrame.StyledPanel) self.mainArea.layout().addWidget(self.plot) self.plot.setAxisTitle(QwtPlot.yLeft, "Proportion of Variance") self.plot.setAxisTitle(QwtPlot.xBottom, "Principal Components") self.plot.setAxisScale(QwtPlot.yLeft, 0.0, 1.0) self.plot.enableGridXB(True) self.plot.enableGridYL(True) self.plot.setGridColor(Qt.lightGray) self.variance_curve = plot_curve( "Variance", pen=QPen(Qt.red, 2), symbol=QwtSymbol.NoSymbol, xaxis=QwtPlot.xBottom, yaxis=QwtPlot.yLeft ) self.cumulative_variance_curve = plot_curve( "Cumulative Variance", pen=QPen(Qt.darkYellow, 2), symbol=QwtSymbol.NoSymbol, xaxis=QwtPlot.xBottom, yaxis=QwtPlot.yLeft ) self.variance_curve.attach(self.plot) self.cumulative_variance_curve.attach(self.plot) self.selection_tool = CutoffControler(parent=self.plot.canvas()) self.selection_tool.cutoffMoved.connect(self.on_cutoff_moved) self.graphButton.clicked.connect(self.saveToFile) self.components = None self.variances = None self.variances_sum = None self.projector_full = None self.currently_selected = 0 self.resize(800, 400)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "SampleData", wantMainArea=0) self.inputs = [("Data", ExampleTable, self.setData)] self.outputs = [("Data Sample", ExampleTable), ("Remaining Data", ExampleTable)] # initialization of variables self.data = None # dataset (incoming stream) self.indices = None # indices that control sampling self.Stratified = 1 # use stratified sampling if possible? self.Repeat = 0 # can elements repeat in a sample? self.UseSpecificSeed = 0 # use a specific random seed? self.RandomSeed = 1 # specific seed used self.GroupSeed = 1 # current seed for multiple group selection self.outFold = 1 # folder/group to output self.Folds = 1 # total number of folds/groups self.SelectType = 0 # sampling type (LOO, CV, ...) self.useCases = 0 # use a specific number of cases? self.nCases = 25 # number of cases to use self.selPercentage = 30 # sample size in % self.CVFolds = 10 # number of CV folds self.nGroups = 3 # number of groups self.pGroups = [0.1, 0.25, 0.5] # sizes of groups self.GroupText = "0.1,0.25,0.5" # assigned to Groups Control (for internal use) self.autocommit = False # Invalidated settings flag. self.outputInvalidateFlag = False self.loadSettings() # GUI # Info Box box1 = OWGUI.widgetBox(self.controlArea, "Information", addSpace=True) # Input data set info self.infoa = OWGUI.widgetLabel(box1, "No data on input.") # Sampling type/parameters info self.infob = OWGUI.widgetLabel(box1, " ") # Output data set info self.infoc = OWGUI.widgetLabel(box1, " ") # Options Box box2 = OWGUI.widgetBox(self.controlArea, "Options", addSpace=True) OWGUI.checkBox(box2, self, "Stratified", "Stratified (if possible)", callback=self.settingsChanged) OWGUI.checkWithSpin( box2, self, "Set random seed:", 0, 32767, "UseSpecificSeed", "RandomSeed", checkCallback=self.settingsChanged, spinCallback=self.settingsChanged, ) # Sampling Type Box self.s = [None, None, None, None] self.sBox = OWGUI.widgetBox(self.controlArea, "Sampling type", addSpace=True) self.sBox.buttons = [] # Random Sampling self.s[0] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", "Random sampling") # indent indent = OWGUI.checkButtonOffsetHint(self.s[0]) # repeat checkbox self.h1Box = OWGUI.indentedBox(self.sBox, sep=indent, orientation="horizontal") OWGUI.checkBox(self.h1Box, self, "Repeat", "With replacement", callback=self.settingsChanged) # specified number of elements checkbox self.h2Box = OWGUI.indentedBox(self.sBox, sep=indent, orientation="horizontal") check, _ = OWGUI.checkWithSpin( self.h2Box, self, "Sample size (instances):", 1, 1000000000, "useCases", "nCases", checkCallback=self.settingsChanged, spinCallback=self.settingsChanged, ) # percentage slider self.h3Box = OWGUI.indentedBox(self.sBox, sep=indent) OWGUI.widgetLabel(self.h3Box, "Sample size:") self.slidebox = OWGUI.widgetBox(self.h3Box, orientation="horizontal") OWGUI.hSlider( self.slidebox, self, "selPercentage", minValue=1, maxValue=100, step=1, ticks=10, labelFormat=" %d%%", callback=self.settingsChanged, ) # Sample size (instances) check disables the Percentage slider. # TODO: Should be an exclusive option (radio buttons) check.disables.extend([(-1, self.h3Box)]) check.makeConsistent() # Cross Validation sampling options self.s[1] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", "Cross validation") box = OWGUI.indentedBox(self.sBox, sep=indent, orientation="horizontal") OWGUI.spin(box, self, "CVFolds", 2, 100, step=1, label="Number of folds: ", callback=self.settingsChanged) # Leave-One-Out self.s[2] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", "Leave-one-out") # Multiple Groups self.s[3] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", "Multiple subsets") gbox = OWGUI.indentedBox(self.sBox, sep=indent, orientation="horizontal") OWGUI.lineEdit( gbox, self, "GroupText", label='Subset sizes (e.g. "0.1, 0.2, 0.5"):', callback=self.multipleChanged ) # Output Group Box box = OWGUI.widgetBox(self.controlArea, "Output Data for Fold / Group", addSpace=True) self.foldcombo = OWGUI.comboBox( box, self, "outFold", items=range(1, 101), label="Fold / group:", orientation="horizontal", sendSelectedValue=1, valueType=int, callback=self.invalidate, ) self.foldcombo.setEnabled(self.SelectType != 0) # Sample Data box OWGUI.rubber(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Sample Data") cb = OWGUI.checkBox(box, self, "autocommit", "Sample on any change") self.sampleButton = OWGUI.button(box, self, "Sample &Data", callback=self.sdata, default=True) OWGUI.setStopper(self, self.sampleButton, cb, "outputInvalidateFlag", callback=self.sdata) # set initial radio button on (default sample type) self.s[self.SelectType].setChecked(True) # Connect radio buttons (SelectType) for i, button in enumerate(self.s): button.toggled[bool].connect(lambda state, i=i: self.samplingTypeChanged(state, i)) self.process() self.resize(200, 275)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'SampleData', wantMainArea=0) self.inputs = [("Data", ExampleTable, self.setData)] self.outputs = [("Data Sample", ExampleTable), ("Remaining Data", ExampleTable)] # initialization of variables self.data = None # dataset (incoming stream) self.indices = None # indices that control sampling self.Stratified = 1 # use stratified sampling if possible? self.Repeat = 0 # can elements repeat in a sample? self.UseSpecificSeed = 0 # use a specific random seed? self.RandomSeed = 1 # specific seed used self.GroupSeed = 1 # current seed for multiple group selection self.outFold = 1 # folder/group to output self.Folds = 1 # total number of folds/groups self.SelectType = 0 # sampling type (LOO, CV, ...) self.useCases = 0 # use a specific number of cases? self.nCases = 25 # number of cases to use self.selPercentage = 30 # sample size in % self.CVFolds = 10 # number of CV folds self.nGroups = 3 # number of groups self.pGroups = [0.1, 0.25, 0.5] # sizes of groups self.GroupText = '0.1,0.25,0.5' # assigned to Groups Control (for internal use) self.autocommit = False # Invalidated settings flag. self.outputInvalidateFlag = False self.loadSettings() # GUI # Info Box box1 = OWGUI.widgetBox(self.controlArea, "Information", addSpace=True) # Input data set info self.infoa = OWGUI.widgetLabel(box1, 'No data on input.') # Sampling type/parameters info self.infob = OWGUI.widgetLabel(box1, ' ') # Output data set info self.infoc = OWGUI.widgetLabel(box1, ' ') # Options Box box2 = OWGUI.widgetBox(self.controlArea, 'Options', addSpace=True) OWGUI.checkBox(box2, self, 'Stratified', 'Stratified (if possible)', callback=self.settingsChanged) OWGUI.checkWithSpin(box2, self, 'Set random seed:', 0, 32767, 'UseSpecificSeed', 'RandomSeed', checkCallback=self.settingsChanged, spinCallback=self.settingsChanged) # Sampling Type Box self.s = [None, None, None, None] self.sBox = OWGUI.widgetBox(self.controlArea, "Sampling type", addSpace=True) self.sBox.buttons = [] # Random Sampling self.s[0] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", 'Random sampling') # indent indent = OWGUI.checkButtonOffsetHint(self.s[0]) # repeat checkbox self.h1Box = OWGUI.indentedBox(self.sBox, sep=indent, orientation="horizontal") OWGUI.checkBox(self.h1Box, self, 'Repeat', 'With replacement', callback=self.settingsChanged) # specified number of elements checkbox self.h2Box = OWGUI.indentedBox(self.sBox, sep=indent, orientation="horizontal") check, _ = OWGUI.checkWithSpin(self.h2Box, self, 'Sample size (instances):', 1, 1000000000, 'useCases', 'nCases', checkCallback=self.settingsChanged, spinCallback=self.settingsChanged) # percentage slider self.h3Box = OWGUI.indentedBox(self.sBox, sep=indent) OWGUI.widgetLabel(self.h3Box, "Sample size:") self.slidebox = OWGUI.widgetBox(self.h3Box, orientation="horizontal") OWGUI.hSlider(self.slidebox, self, 'selPercentage', minValue=1, maxValue=100, step=1, ticks=10, labelFormat=" %d%%", callback=self.settingsChanged) # Sample size (instances) check disables the Percentage slider. # TODO: Should be an exclusive option (radio buttons) check.disables.extend([(-1, self.h3Box)]) check.makeConsistent() # Cross Validation sampling options self.s[1] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", "Cross validation") box = OWGUI.indentedBox(self.sBox, sep=indent, orientation="horizontal") OWGUI.spin(box, self, 'CVFolds', 2, 100, step=1, label='Number of folds: ', callback=self.settingsChanged) # Leave-One-Out self.s[2] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", "Leave-one-out") # Multiple Groups self.s[3] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", 'Multiple subsets') gbox = OWGUI.indentedBox(self.sBox, sep=indent, orientation="horizontal") OWGUI.lineEdit(gbox, self, 'GroupText', label='Subset sizes (e.g. "0.1, 0.2, 0.5"):', callback=self.multipleChanged) # Output Group Box box = OWGUI.widgetBox(self.controlArea, 'Output Data for Fold / Group', addSpace=True) self.foldcombo = OWGUI.comboBox(box, self, "outFold", items=range(1, 101), label='Fold / group:', orientation="horizontal", sendSelectedValue=1, valueType=int, callback=self.invalidate) self.foldcombo.setEnabled(self.SelectType != 0) # Sample Data box OWGUI.rubber(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Sample Data") cb = OWGUI.checkBox(box, self, "autocommit", "Sample on any change") self.sampleButton = OWGUI.button(box, self, 'Sample &Data', callback=self.sdata, default=True) OWGUI.setStopper(self, self.sampleButton, cb, "outputInvalidateFlag", callback=self.sdata) # set initial radio button on (default sample type) self.s[self.SelectType].setChecked(True) # Connect radio buttons (SelectType) for i, button in enumerate(self.s): button.toggled[bool].connect( lambda state, i=i: self.samplingTypeChanged(state, i)) self.process() self.resize(200, 275)
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()
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'k-Means Clustering') self.inputs = [("Examples", ExampleTable, self.setData)] self.outputs = [("Examples", ExampleTable), ("Centroids", ExampleTable)] #set default settings self.K = 2 self.optimized = True self.optimizationFrom = 2 self.optimizationTo = 5 self.scoring = 0 self.distanceMeasure = 0 self.initializationType = 0 self.restarts = 1 self.classifySelected = 1 self.addIdAs = 0 self.runAnyChange = 1 self.classifyName = "Cluster" self.settingsChanged = False self.loadSettings() self.data = None # holds input data self.km = None # holds clustering object # GUI definition # settings box = OWGUI.widgetBox(self.controlArea, "Clusters (k)") bg = OWGUI.radioButtonsInBox(box, self, "optimized", [], callback=self.setOptimization) fixedBox = OWGUI.widgetBox(box, orientation="horizontal") button = OWGUI.appendRadioButton(bg, self, "optimized", "Fixed", insertInto=fixedBox, tooltip="Fixed number of clusters") self.fixedSpinBox = OWGUI.spin(OWGUI.widgetBox(fixedBox), self, "K", min=2, max=30, tooltip="Fixed number of clusters", callback=self.update, callbackOnReturn=True) OWGUI.rubber(fixedBox) optimizedBox = OWGUI.widgetBox(box) button = OWGUI.appendRadioButton(bg, self, "optimized", "Optimized", insertInto=optimizedBox) option = QStyleOptionButton() option.initFrom(button) box = OWGUI.indentedBox( optimizedBox, qApp.style().subElementRect(QStyle.SE_CheckBoxIndicator, option, button).width() - 3) self.optimizationBox = box OWGUI.spin(box, self, "optimizationFrom", label="From", min=2, max=99, tooltip="Minimum number of clusters to try", callback=self.updateOptimizationFrom, callbackOnReturn=True) b = OWGUI.spin(box, self, "optimizationTo", label="To", min=3, max=100, tooltip="Maximum number of clusters to try", callback=self.updateOptimizationTo, callbackOnReturn=True) # b.control.setLineEdit(OWGUI.LineEditWFocusOut(b)) OWGUI.comboBox(box, self, "scoring", label="Scoring", orientation="horizontal", items=[m[0] for m in self.scoringMethods], callback=self.update) box = OWGUI.widgetBox(self.controlArea, "Settings", addSpace=True) # OWGUI.spin(box, self, "K", label="Number of clusters"+" ", min=1, max=30, step=1, # callback = self.initializeClustering) OWGUI.comboBox(box, self, "distanceMeasure", label="Distance measures", items=[name for name, _ in self.distanceMeasures], tooltip=None, indent=20, callback=self.update) cb = OWGUI.comboBox(box, self, "initializationType", label="Initialization", items=[name for name, _ in self.initializations], tooltip=None, indent=20, callback=self.update) OWGUI.spin(cb.box, self, "restarts", label="Restarts", orientation="horizontal", min=1, max=100, callback=self.update, callbackOnReturn=True) box = OWGUI.widgetBox(self.controlArea, "Cluster IDs") cb = OWGUI.checkBox(box, self, "classifySelected", "Append cluster indices") box = OWGUI.indentedBox(box) form = QWidget() le = OWGUI.lineEdit( form, self, "classifyName", None, #"Name" + " ", orientation="horizontal", #controlWidth=100, valueType=str, # callback=self.sendData, # callbackOnReturn=True ) cc = OWGUI.comboBox( form, self, "addIdAs", label=" ", #"Place" + " ", orientation="horizontal", items=["Class attribute", "Attribute", "Meta attribute"], ) layout = QFormLayout() layout.setSpacing(8) layout.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow) layout.setLabelAlignment(Qt.AlignLeft | Qt.AlignJustify) layout.addRow("Name ", le) layout.addRow("Place ", cc) # le.setFixedWidth(cc.sizeHint().width()) form.setLayout(layout) box.layout().addWidget(form) cb.disables.append(box) # cb.disables.append(cc.box) cb.makeConsistent() # OWGUI.separator(box) box = OWGUI.widgetBox(self.controlArea, "Run", addSpace=True) cb = OWGUI.checkBox(box, self, "runAnyChange", "Run after any change") self.runButton = b = OWGUI.button(box, self, "Run Clustering", callback=self.run) OWGUI.setStopper(self, b, cb, "settingsChanged", callback=self.run) OWGUI.rubber(self.controlArea) # display of clustering results self.optimizationReportBox = OWGUI.widgetBox(self.mainArea) tableBox = OWGUI.widgetBox(self.optimizationReportBox, "Optimization Report") self.table = OWGUI.table(tableBox, selectionMode=QTableWidget.SingleSelection) self.table.setHorizontalScrollMode(QTableWidget.ScrollPerPixel) self.table.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.table.setSelectionBehavior(QAbstractItemView.SelectRows) self.table.setColumnCount(3) self.table.setHorizontalHeaderLabels(["k", "Best", "Score"]) self.table.verticalHeader().hide() self.table.horizontalHeader().setStretchLastSection(True) self.table.setItemDelegateForColumn( 2, OWGUI.TableBarItem(self, self.table)) self.table.setItemDelegateForColumn(1, OWGUI.IndicatorItemDelegate(self)) self.table.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) self.table.hide() self.connect(self.table, SIGNAL("itemSelectionChanged()"), self.tableItemSelected) self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) self.mainArea.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) OWGUI.rubber(self.topWidgetPart) self.updateOptimizationGui()
def __init__(self, parent=None, signalManager=None, title="PCA"): OWWidget.__init__(self, parent, signalManager, title, wantGraph=True) self.inputs = [("Input Data", Orange.data.Table, self.set_data)] self.outputs = [("Transformed Data", Orange.data.Table, Default), ("Eigen Vectors", Orange.data.Table)] self.standardize = True self.max_components = 0 self.variance_covered = 100.0 self.use_generalized_eigenvectors = False self.auto_commit = False self.loadSettings() self.data = None self.changed_flag = False ##### # GUI ##### grid = QGridLayout() box = OWGUI.widgetBox(self.controlArea, "Components Selection", orientation=grid) label1 = QLabel("Max components", box) grid.addWidget(label1, 1, 0) sb1 = OWGUI.spin(box, self, "max_components", 0, 1000, tooltip="Maximum number of components", callback=self.on_update, addToLayout=False, keyboardTracking=False) self.max_components_spin = sb1.control self.max_components_spin.setSpecialValueText("All") grid.addWidget(sb1.control, 1, 1) label2 = QLabel("Variance covered", box) grid.addWidget(label2, 2, 0) sb2 = OWGUI.doubleSpin(box, self, "variance_covered", 1.0, 100.0, 1.0, tooltip="Percent of variance covered.", callback=self.on_update, decimals=1, addToLayout=False, keyboardTracking=False) sb2.control.setSuffix("%") grid.addWidget(sb2.control, 2, 1) OWGUI.rubber(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Commit") cb = OWGUI.checkBox(box, self, "auto_commit", "Commit on any change") b = OWGUI.button(box, self, "Commit", callback=self.update_components) OWGUI.setStopper(self, b, cb, "changed_flag", self.update_components) self.scree_plot = ScreePlot(self) # self.scree_plot.set_main_title("Scree Plot") # self.scree_plot.set_show_main_title(True) self.scree_plot.set_axis_title(owaxis.xBottom, "Principal Components") self.scree_plot.set_show_axis_title(owaxis.xBottom, 1) self.scree_plot.set_axis_title(owaxis.yLeft, "Proportion of Variance") self.scree_plot.set_show_axis_title(owaxis.yLeft, 1) self.variance_curve = self.scree_plot.add_curve( "Variance", Qt.red, Qt.red, 2, xData=[], yData=[], style=OWCurve.Lines, enableLegend=True, lineWidth=2, autoScale=1, x_axis_key=owaxis.xBottom, y_axis_key=owaxis.yLeft, ) self.cumulative_variance_curve = self.scree_plot.add_curve( "Cumulative Variance", Qt.darkYellow, Qt.darkYellow, 2, xData=[], yData=[], style=OWCurve.Lines, enableLegend=True, lineWidth=2, autoScale=1, x_axis_key=owaxis.xBottom, y_axis_key=owaxis.yLeft, ) self.mainArea.layout().addWidget(self.scree_plot) self.connect(self.scree_plot, SIGNAL("cutoff_moved(double)"), self.on_cutoff_moved) self.connect(self.graphButton, SIGNAL("clicked()"), self.scree_plot.save_to_file) self.components = None self.variances = None self.variances_sum = None self.projector_full = None self.currently_selected = 0 self.resize(800, 400)
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, "Confusion Matrix", 1) # inputs self.inputs = [("Evaluation Results", orngTest.ExperimentResults, self.setTestResults, Default)] self.outputs = [("Selected Examples", ExampleTable, 8)] self.selectedLearner = [] self.learnerNames = [] self.selectionDirty = 0 self.autoApply = True self.appendPredictions = True self.appendProbabilities = False self.shownQuantity = 0 self.learnerList = OWGUI.listBox(self.controlArea, self, "selectedLearner", "learnerNames", box="Learners", callback=self.learnerChanged) self.learnerList.setMinimumHeight(100) OWGUI.separator(self.controlArea) OWGUI.comboBox(self.controlArea, self, "shownQuantity", items=self.quantities, box="Show", callback=self.reprint) box = OWGUI.widgetBox(self.controlArea, "Selection", addSpace=True) OWGUI.button(box, self, "Correct", callback=self.selectCorrect) OWGUI.button(box, self, "Misclassified", callback=self.selectWrong) OWGUI.button(box, self, "None", callback=self.selectNone) box = OWGUI.widgetBox(self.controlArea, "Output") OWGUI.checkBox(box, self, "appendPredictions", "Append class predictions", callback=self.sendIf) OWGUI.checkBox(box, self, "appendProbabilities", "Append predicted class probabilities", callback=self.sendIf) applyButton = OWGUI.button(box, self, "Commit", callback=self.sendData) autoApplyCB = OWGUI.checkBox(box, self, "autoApply", "Commit automatically") OWGUI.setStopper(self, applyButton, autoApplyCB, "selectionDirty", self.sendData) import sip sip.delete(self.mainArea.layout()) self.layout = QGridLayout(self.mainArea) self.layout.addWidget(OWGUI.widgetLabel(self.mainArea, "Prediction"), 0, 1, Qt.AlignCenter) self.layout.addWidget( OWGUI.widgetLabel(self.mainArea, "Correct Class "), 2, 0, Qt.AlignCenter) self.table = OWGUI.table(self.mainArea, rows=0, columns=0, selectionMode=QTableWidget.MultiSelection, addToLayout=0) self.layout.addWidget(self.table, 2, 1) self.layout.setColumnStretch(1, 100) self.layout.setRowStretch(2, 100) self.connect(self.table, SIGNAL("itemSelectionChanged()"), self.sendIf) self.resize(700, 450)
def __init__(self, parent=None, signalManager=None, title="Distances"): OWWidget.__init__(self, parent, signalManager, title, wantMainArea=False, resizingEnabled=False) self.axis = 0 self.metric = 0 self.normalize = True self.label = 0 self.autocommit = False self._canceled = False self.loadSettings() self.labels = [] self.data = None self.data_t = None self.matrix = None self.metric = min(max(self.metric, 0), len(METRICS) - 1) self._invalidated = False box = OWGUI.widgetBox(self.controlArea, "Distances between", addSpace=True) OWGUI.radioButtonsInBox( box, self, "axis", ["rows", "columns"], callback=self.distAxisChanged ) box = OWGUI.widgetBox(self.controlArea, "Distance Metric", addSpace=True) cb = OWGUI.comboBox( box, self, "metric", items=[m.name for m in METRICS], tooltip=("Choose metric to measure pairwise distances between " "examples."), callback=self.distMetricChanged, valueType=str ) cb.setMinimumWidth(170) box = OWGUI.widgetBox(box, "Settings", flat=True) self.normalizeCB = OWGUI.checkBox( box, self, "normalize", "Normalized", callback=self.distMetricChanged ) self.normalizeCB.setEnabled(self.metric in [0, 3]) self.labelCombo = OWGUI.comboBox( self.controlArea, self, "label", box="Label", items=[], tooltip="Attribute used for matrix item labels", callback=self.invalidate, ) self.labelCombo.setDisabled(True) OWGUI.separator(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Commit") cb = OWGUI.checkBox(box, self, "autocommit", "Commit on any change") b = OWGUI.button(box, self, "Commit", callback=self.commit, default=True) OWGUI.setStopper(self, b, cb, "_invalidated", self.commit)
def __init__(self, parent=None, signalManager=None, title="Reliability"): OWWidget.__init__(self, parent, signalManager, title, wantMainArea=False) self.inputs = [("Learner", Orange.core.Learner, self.set_learner), ("Training Data", Orange.data.Table, self.set_train_data), ("Test Data", Orange.data.Table, self.set_test_data)] self.outputs = [("Reliability Scores", Orange.data.Table)] self.variance_checked = False self.bias_checked = False self.bagged_variance = False self.local_cv = False self.local_model_pred_error = False self.bagging_variance_cn = False self.mahalanobis_distance = True self.var_e = "0.01, 0.1, 0.5, 1.0, 2.0" self.bias_e = "0.01, 0.1, 0.5, 1.0, 2.0" self.bagged_m = 10 self.local_cv_k = 2 self.local_pe_k = 5 self.bagged_cn_m = 5 self.bagged_cn_k = 1 self.mahalanobis_k = 3 self.include_error = True self.include_class = True self.include_input_features = False self.auto_commit = False # (selected attr name, getter function, count of returned estimators, indices of estimator results to use) self.estimators = \ [("variance_checked", self.get_SAVar, 3, [0]), ("bias_checked", self.get_SABias, 3, [1, 2]), ("bagged_variance", self.get_BAGV, 1, [0]), ("local_cv", self.get_LCV, 1, [0]), ("local_model_pred_error", self.get_CNK, 2, [0, 1]), ("bagging_variance_cn", self.get_BVCK, 4, [0]), ("mahalanobis_distance", self.get_Mahalanobis, 1, [0])] ##### # GUI ##### self.loadSettings() box = OWGUI.widgetBox(self.controlArea, "Info", addSpace=True) self.info_box = OWGUI.widgetLabel(box, "\n\n") rbox = OWGUI.widgetBox(self.controlArea, "Methods", addSpace=True) def method_box(parent, name, value): box = OWGUI.widgetBox(rbox, name, flat=False) box.setCheckable(True) box.setChecked(bool(getattr(self, value))) self.connect( box, SIGNAL("toggled(bool)"), lambda on: (setattr( self, value, on), self.method_selection_changed(value))) return box e_validator = QRegExpValidator( QRegExp(r"\s*(-?[0-9]+(\.[0-9]*)\s*,\s*)+"), self) variance_box = method_box(rbox, "Sensitivity analysis (variance)", "variance_checked") OWGUI.lineEdit( variance_box, self, "var_e", "Sensitivities:", tooltip= "List of possible e values (comma separated) for SAvar reliability estimates.", callback=partial(self.method_param_changed, 0), validator=e_validator) bias_box = method_box(rbox, "Sensitivity analysis (bias)", "bias_checked") OWGUI.lineEdit( bias_box, self, "bias_e", "Sensitivities:", tooltip= "List of possible e values (comma separated) for SAbias reliability estimates.", callback=partial(self.method_param_changed, 1), validator=e_validator) bagged_box = method_box(rbox, "Variance of bagged models", "bagged_variance") OWGUI.spin( bagged_box, self, "bagged_m", 2, 100, step=1, label="Models:", tooltip="Number of bagged models to be used with BAGV estimate.", callback=partial(self.method_param_changed, 2), keyboardTracking=False) local_cv_box = method_box(rbox, "Local cross validation", "local_cv") OWGUI.spin(local_cv_box, self, "local_cv_k", 2, 20, step=1, label="Nearest neighbors:", tooltip="Number of nearest neighbors used in LCV estimate.", callback=partial(self.method_param_changed, 3), keyboardTracking=False) local_pe = method_box(rbox, "Local modeling of prediction error", "local_model_pred_error") OWGUI.spin(local_pe, self, "local_pe_k", 1, 20, step=1, label="Nearest neighbors:", tooltip="Number of nearest neighbors used in CNK estimate.", callback=partial(self.method_param_changed, 4), keyboardTracking=False) bagging_cnn = method_box(rbox, "Bagging variance c-neighbors", "bagging_variance_cn") OWGUI.spin( bagging_cnn, self, "bagged_cn_m", 2, 100, step=1, label="Models:", tooltip="Number of bagged models to be used with BVCK estimate.", callback=partial(self.method_param_changed, 5), keyboardTracking=False) OWGUI.spin( bagging_cnn, self, "bagged_cn_k", 1, 20, step=1, label="Nearest neighbors:", tooltip="Number of nearest neighbors used in BVCK estimate.", callback=partial(self.method_param_changed, 5), keyboardTracking=False) mahalanobis_box = method_box(rbox, "Mahalanobis distance", "mahalanobis_distance") OWGUI.spin( mahalanobis_box, self, "mahalanobis_k", 1, 20, step=1, label="Nearest neighbors:", tooltip="Number of nearest neighbors used in BVCK estimate.", callback=partial(self.method_param_changed, 6), keyboardTracking=False) box = OWGUI.widgetBox(self.controlArea, "Output") OWGUI.checkBox(box, self, "include_error", "Include prediction error", tooltip="Include prediction error in the output", callback=self.commit_if) OWGUI.checkBox( box, self, "include_class", "Include original class and prediction", tooltip="Include original class and prediction in the output.", callback=self.commit_if) OWGUI.checkBox(box, self, "include_input_features", "Include input features", tooltip="Include features from the input data set.", callback=self.commit_if) cb = OWGUI.checkBox(box, self, "auto_commit", "Commit on any change", callback=self.commit_if) self.commit_button = b = OWGUI.button(box, self, "Commit", callback=self.commit, autoDefault=True) OWGUI.setStopper(self, b, cb, "output_changed", callback=self.commit) self.commit_button.setEnabled(any([getattr(self, selected) \ for selected, _, _, _ in self.estimators])) self.learner = None self.train_data = None self.test_data = None self.output_changed = False self.train_data_has_no_class = False self.train_data_has_discrete_class = False self.invalidate_results()
def __init__(self, parent=None, signalManager=None, name="Image viewer"): OWWidget.__init__(self, parent, signalManager, name, wantGraph=True) self.inputs = [("Data", ExampleTable, self.setData)] self.outputs = [("Data", ExampleTable)] self.imageAttr = 0 self.titleAttr = 0 self.zoom = 25 self.autoCommit = False self.selectionChangedFlag = False # # GUI # self.loadSettings() self.info = OWGUI.widgetLabel( OWGUI.widgetBox(self.controlArea, "Info"), "Waiting for input\n") self.imageAttrCB = OWGUI.comboBox( self.controlArea, self, "imageAttr", box="Image Filename Attribute", tooltip="Attribute with image filenames", callback=[self.clearScene, self.setupScene], addSpace=True) self.titleAttrCB = OWGUI.comboBox(self.controlArea, self, "titleAttr", box="Title Attribute", tooltip="Attribute with image title", callback=self.updateTitles, addSpace=True) OWGUI.hSlider(self.controlArea, self, "zoom", box="Zoom", minValue=1, maxValue=100, step=1, callback=self.updateZoom, createLabel=False) OWGUI.separator(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Selection") b = OWGUI.button(box, self, "Commit", callback=self.commit) cb = OWGUI.checkBox(box, self, "autoCommit", "Commit on any change", tooltip="Send selections on any change", callback=self.commitIf) OWGUI.setStopper(self, b, cb, "selectionChangedFlag", callback=self.commit) OWGUI.rubber(self.controlArea) self.scene = GraphicsScene() self.sceneView = QGraphicsView(self.scene, self) self.sceneView.setAlignment(Qt.AlignTop | Qt.AlignLeft) self.sceneView.setRenderHint(QPainter.Antialiasing, True) self.sceneView.setRenderHint(QPainter.TextAntialiasing, True) self.sceneView.setFocusPolicy(Qt.WheelFocus) self.sceneView.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.sceneView.installEventFilter(self) self.mainArea.layout().addWidget(self.sceneView) self.scene.selectionChanged.connect(self.onSelectionChanged) self.scene.selectionRectPointChanged.connect( self.onSelectionRectPointChanged, Qt.QueuedConnection) self.graphButton.clicked.connect(self.saveScene) self.resize(800, 600) self.thumbnailWidget = None self.sceneLayout = None self.selectedExamples = [] #: List of _ImageItems self.items = [] self._errcount = 0 self._successcount = 0 self.loader = ImageLoader(self) # Add the "orange-sf" path prefix for locating files # distributed using `serverfiles`. sfdir = serverfiles.localpath() if sfdir not in [unicode(p) for p in QDir.searchPaths("orange-sf")]: QDir.addSearchPath("orange-sf", sfdir)
def __init__(self, parent=None, signalManager=None, name="Image viewer"): OWWidget.__init__(self, parent, signalManager, name, wantGraph=True) self.inputs = [("Data", ExampleTable, self.setData)] self.outputs = [("Data", ExampleTable)] self.imageAttr = 0 self.titleAttr = 0 self.zoom = 25 self.autoCommit = False self.selectionChangedFlag = False # ### # GUI # ### self.loadSettings() self.imageAttrCB = OWGUI.comboBox(self.controlArea, self, "imageAttr", box="Image Filename Attribute", tooltip="Attribute with image filenames", callback=self.setupScene, addSpace=True ) self.titleAttrCB = OWGUI.comboBox(self.controlArea, self, "titleAttr", box="Title Attribute", tooltip="Attribute with image title", callback=self.updateTitles, addSpace=True ) OWGUI.hSlider(self.controlArea, self, "zoom", box="Zoom", minValue=1, maxValue=100, step=1, callback=self.updateZoom, createLabel=False ) OWGUI.separator(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Selection") b = OWGUI.button(box, self, "Commit", callback=self.commit) cb = OWGUI.checkBox(box, self, "autoCommit", "Commit on any change", tooltip="Send selections on any change", callback=self.commitIf ) OWGUI.setStopper(self, b, cb, "selectionChangedFlag", callback=self.commit) OWGUI.rubber(self.controlArea) self.scene = GraphicsScene() self.sceneView = QGraphicsView(self.scene, self) self.sceneView.setAlignment(Qt.AlignTop | Qt.AlignLeft) self.sceneView.setRenderHint(QPainter.Antialiasing, True) self.sceneView.setRenderHint(QPainter.TextAntialiasing, True) self.sceneView.setFocusPolicy(Qt.WheelFocus) self.mainArea.layout().addWidget(self.sceneView) self.connect(self.scene, SIGNAL("selectionChanged()"), self.onSelectionChanged) self.connect(self.scene, SIGNAL("selectionRectPointChanged(QPointF)"), self.onSelectionRectPointChanged, Qt.QueuedConnection) self.connect(self.graphButton, SIGNAL("clicked()"), self.saveScene) self.resize(800, 600) self.sceneLayout = None self.selectedExamples = [] self.hasTypeImageHint = False self.updateZoom()
def __init__(self, parent=None, signalManager=None, title="Edit Domain"): OWWidget.__init__(self, parent, signalManager, title) self.inputs = [("Data", Orange.data.Table, self.set_data)] self.outputs = [("Data", Orange.data.Table)] # Settings # Domain change hints maps from input variables description to # the modified variables description as returned by # `variable_description` function self.domain_change_hints = {} self.selected_index = 0 self.auto_commit = False self.changed_flag = False self.loadSettings() ##### # GUI ##### # The list of domain's variables. box = OWGUI.widgetBox(self.controlArea, "Domain Features") self.domain_view = QListView() self.domain_view.setSelectionMode(QListView.SingleSelection) self.domain_model = VariableListModel() self.domain_view.setModel(self.domain_model) self.connect(self.domain_view.selectionModel(), SIGNAL("selectionChanged(QItemSelection, QItemSelection)"), self.on_selection_changed) box.layout().addWidget(self.domain_view) # A stack for variable editor widgets. box = OWGUI.widgetBox(self.mainArea, "Edit Feature") self.editor_stack = QStackedWidget() box.layout().addWidget(self.editor_stack) box = OWGUI.widgetBox(self.controlArea, "Reset") OWGUI.button(box, self, "Reset selected", callback=self.reset_selected, tooltip="Reset changes made to the selected feature" ) OWGUI.button(box, self, "Reset all", callback=self.reset_all, tooltip="Reset all changes made to the domain" ) box = OWGUI.widgetBox(self.controlArea, "Commit") b = OWGUI.button(box, self, "&Commit", callback=self.commit, tooltip="Commit the data with the changed domain", ) cb = OWGUI.checkBox(box, self, "auto_commit", label="Commit automatically", tooltip="Commit the changed domain on any change", callback=self.commit_if) OWGUI.setStopper(self, b, cb, "changed_flag", callback=self.commit) self._editor_cache = {} self.resize(600, 500)
def __init__(self, parent=None, signalManager=None, name="Image viewer"): OWWidget.__init__(self, parent, signalManager, name, wantGraph=True) self.inputs = [("Data", ExampleTable, self.setData)] self.outputs = [("Data", ExampleTable)] self.imageAttr = 0 self.titleAttr = 0 self.zoom = 25 self.autoCommit = False self.selectionChangedFlag = False # # GUI # self.loadSettings() self.info = OWGUI.widgetLabel( OWGUI.widgetBox(self.controlArea, "Info"), "Waiting for input\n" ) self.imageAttrCB = OWGUI.comboBox( self.controlArea, self, "imageAttr", box="Image Filename Attribute", tooltip="Attribute with image filenames", callback=[self.clearScene, self.setupScene], addSpace=True ) self.titleAttrCB = OWGUI.comboBox( self.controlArea, self, "titleAttr", box="Title Attribute", tooltip="Attribute with image title", callback=self.updateTitles, addSpace=True ) OWGUI.hSlider( self.controlArea, self, "zoom", box="Zoom", minValue=1, maxValue=100, step=1, callback=self.updateZoom, createLabel=False ) OWGUI.separator(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Selection") b = OWGUI.button(box, self, "Commit", callback=self.commit) cb = OWGUI.checkBox( box, self, "autoCommit", "Commit on any change", tooltip="Send selections on any change", callback=self.commitIf ) OWGUI.setStopper(self, b, cb, "selectionChangedFlag", callback=self.commit) OWGUI.rubber(self.controlArea) self.scene = GraphicsScene() self.sceneView = QGraphicsView(self.scene, self) self.sceneView.setAlignment(Qt.AlignTop | Qt.AlignLeft) self.sceneView.setRenderHint(QPainter.Antialiasing, True) self.sceneView.setRenderHint(QPainter.TextAntialiasing, True) self.sceneView.setFocusPolicy(Qt.WheelFocus) self.sceneView.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.sceneView.installEventFilter(self) self.mainArea.layout().addWidget(self.sceneView) self.scene.selectionChanged.connect(self.onSelectionChanged) self.scene.selectionRectPointChanged.connect( self.onSelectionRectPointChanged, Qt.QueuedConnection ) self.graphButton.clicked.connect(self.saveScene) self.resize(800, 600) self.thumbnailWidget = None self.sceneLayout = None self.selectedExamples = [] #: List of _ImageItems self.items = [] self._errcount = 0 self._successcount = 0 self.loader = ImageLoader(self) # Add the "orange-sf" path prefix for locating files # distributed using `serverfiles`. sfdir = serverfiles.localpath() if sfdir not in [unicode(p) for p in QDir.searchPaths("orange-sf")]: QDir.addSearchPath("orange-sf", sfdir)
def __init__(self, parent=None, signalManager=None, name="CN2 Rules Viewer"): OWWidget.__init__(self, parent, signalManager, name) self.inputs = [("Rule Classifier", orange.RuleClassifier, self.setRuleClassifier)] self.outputs = [("Data", ExampleTable), ("Features", AttributeList)] self.show_Rule_length = True self.show_Rule_quality = True self.show_Coverage = True self.show_Predicted_class = True self.show_Distribution = True self.show_Rule = True self.autoCommit = False self.selectedAttrsOnly = True self.loadSettings() ##### # GUI ##### box = OWGUI.widgetBox(self.controlArea, "Show Info", addSpace=True) box.layout().setSpacing(3) self.headers = ["Rule length", "Rule quality", "Coverage", "Predicted class", "Distribution", "Rule"] for i, header in enumerate(self.headers): OWGUI.checkBox(box, self, "show_%s" % header.replace(" ", "_"), header, tooltip="Show %s column" % header.lower(), callback=self.updateVisibleColumns) box = OWGUI.widgetBox(self.controlArea, "Output") box.layout().setSpacing(3) cb = OWGUI.checkBox(box, self, "autoCommit", "Commit on any change", callback=self.commitIf) OWGUI.checkBox(box, self, "selectedAttrsOnly", "Selected attributes only", tooltip="Send selected attributes only", callback=self.commitIf) b = OWGUI.button(box, self, "Commit", callback=self.commit, default=True) OWGUI.setStopper(self, b, cb, "changedFlag", callback=self.commit) OWGUI.rubber(self.controlArea) self.tableView = QTableView() self.tableView.setItemDelegate(PyObjectItemDelegate(self)) self.tableView.setItemDelegateForColumn(1, PyFloatItemDelegate(self)) self.tableView.setItemDelegateForColumn(2, PyFloatItemDelegate(self)) self.tableView.setItemDelegateForColumn(4, DistributionItemDelegate(self)) self.tableView.setItemDelegateForColumn(5, MultiLineStringItemDelegate(self)) self.tableView.setSortingEnabled(True) self.tableView.setSelectionBehavior(QTableView.SelectRows) self.tableView.setAlternatingRowColors(True) self.rulesTableModel = PyTableModel([], self.headers) self.proxyModel = QSortFilterProxyModel(self) self.proxyModel.setSourceModel(self.rulesTableModel) self.tableView.setModel(self.proxyModel) self.connect(self.tableView.selectionModel(), SIGNAL("selectionChanged(QItemSelection, QItemSelection)"), lambda is1, is2: self.commitIf()) self.connect(self.tableView.horizontalHeader(), SIGNAL("sectionClicked(int)"), lambda section: self.tableView.resizeRowsToContents()) self.mainArea.layout().addWidget(self.tableView) self.updateVisibleColumns() self.changedFlag = False self.classifier = None self.rules = [] self.resize(800, 600)
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, "Confusion Matrix", 1) # inputs self.inputs = [("Evaluation Results", orngTest.ExperimentResults, self.setTestResults, Default)] self.outputs = [("Selected Examples", ExampleTable, 8)] self.selectedLearner = [] self.learnerNames = [] self.selectionDirty = 0 self.autoApply = True self.appendPredictions = True self.appendProbabilities = False self.shownQuantity = 0 self.learnerList = OWGUI.listBox(self.controlArea, self, "selectedLearner", "learnerNames", box="Learners", callback=self.learnerChanged) self.learnerList.setMinimumHeight(100) OWGUI.separator(self.controlArea) OWGUI.comboBox(self.controlArea, self, "shownQuantity", items=self.quantities, box="Show", callback=self.reprint) box = OWGUI.widgetBox(self.controlArea, "Selection", addSpace=True) OWGUI.button(box, self, "Correct", callback=self.selectCorrect) OWGUI.button(box, self, "Misclassified", callback=self.selectWrong) OWGUI.button(box, self, "None", callback=self.selectNone) box = OWGUI.widgetBox(self.controlArea, "Output") OWGUI.checkBox(box, self, "appendPredictions", "Append class predictions", callback=self.sendIf) OWGUI.checkBox(box, self, "appendProbabilities", "Append predicted class probabilities", callback=self.sendIf) applyButton = OWGUI.button(box, self, "Commit", callback=self.sendData) autoApplyCB = OWGUI.checkBox(box, self, "autoApply", "Commit automatically") OWGUI.setStopper(self, applyButton, autoApplyCB, "selectionDirty", self.sendData) import sip sip.delete(self.mainArea.layout()) self.layout = QGridLayout(self.mainArea) self.layout.addWidget(OWGUI.widgetLabel(self.mainArea, "Prediction"), 0, 1, Qt.AlignCenter) self.layout.addWidget( OWGUI.widgetLabel(self.mainArea, "Correct Class "), 2, 0, Qt.AlignCenter) self.table = OWGUI.table(self.mainArea, rows=0, columns=0, selectionMode=QTableWidget.MultiSelection, addToLayout=0) self.layout.addWidget(self.table, 2, 1) self.layout.setColumnStretch(1, 100) self.layout.setRowStretch(2, 100) self.connect(self.table, SIGNAL("itemSelectionChanged()"), self.sendIf) ##scPA # Get location of model file self.filePath = os.path.join(os.getcwd(), "ConfusionMat.txt") boxFile = OWGUI.widgetBox(self.controlArea, "File for saving results", addSpace=True, orientation=0) L1 = OWGUI.lineEdit( boxFile, self, "filePath", labelWidth=80, orientation="horizontal", tooltip= "Enter full file path to save the displayed results to a tab separated file." ) L1.setMinimumWidth(200) button = OWGUI.button(boxFile, self, '...', callback=self.browseFile, disabled=0, tooltip="Browse for a location...") button.setMaximumWidth(25) # Save the model OWGUI.button(self.controlArea, self, "&Save Results", callback=self.saveRes) ##ecPA self.resize(700, 450)
def __init__(self, parent=None, signalManager=None, name="Preprocess"): OWWidget.__init__(self, parent, signalManager, name) self.inputs = [("Example Table", ExampleTable, self.setData) ] #, ("Learner", orange.Learner, self.setLearner)] self.outputs = [("Preprocess", orngWrap.PreprocessedLearner), ("Preprocessed Example Table", ExampleTable) ] #, ("Preprocessor", orange.Preprocessor)] self.autoCommit = False self.changedFlag = False # self.allSchemas = [PreprocessorSchema("Default" , [Preprocessor_discretize(method=orange.EntropyDiscretization()), Preprocessor_dropMissing()])] self.allSchemas = [("Default", [ Preprocessor_discretizeEntropy( method=orange.EntropyDiscretization()), Preprocessor_dropMissing() ], 0)] self.lastSelectedSchemaIndex = 0 self.preprocessorsList = PyListModel([], self) box = OWGUI.widgetBox(self.controlArea, "Preprocessors", addSpace=True) box.layout().setSpacing(1) self.setStyleSheet("QListView::item { margin: 1px;}") self.preprocessorsListView = QListView() self.preprocessorsListSelectionModel = ListSingleSelectionModel( self.preprocessorsList, self) self.preprocessorsListView.setItemDelegate( PreprocessorItemDelegate(self)) self.preprocessorsListView.setModel(self.preprocessorsList) self.preprocessorsListView.setSelectionModel( self.preprocessorsListSelectionModel) self.preprocessorsListView.setSelectionMode(QListView.SingleSelection) self.connect(self.preprocessorsListSelectionModel, SIGNAL("selectedIndexChanged(QModelIndex)"), self.onPreprocessorSelection) self.connect(self.preprocessorsList, SIGNAL("dataChanged(QModelIndex, QModelIndex)"), lambda arg1, arg2: self.commitIf) box.layout().addWidget(self.preprocessorsListView) self.addPreprocessorAction = QAction("+", self) self.addPreprocessorAction.pyqtConfigure( toolTip="Add a new preprocessor to the list") self.removePreprocessorAction = QAction("-", self) self.removePreprocessorAction.pyqtConfigure( toolTip="Remove selected preprocessor from the list") self.removePreprocessorAction.setEnabled(False) self.connect( self.preprocessorsListSelectionModel, SIGNAL("selectedIndexChanged(QModelIndex)"), lambda index: self. removePreprocessorAction.setEnabled(index.isValid())) actionsWidget = ModelActionsWidget( [self.addPreprocessorAction, self.removePreprocessorAction]) actionsWidget.layout().setSpacing(1) actionsWidget.layout().addStretch(10) box.layout().addWidget(actionsWidget) self.connect(self.addPreprocessorAction, SIGNAL("triggered()"), self.onAddPreprocessor) self.connect(self.removePreprocessorAction, SIGNAL("triggered()"), self.onRemovePreprocessor) box = OWGUI.widgetBox(self.controlArea, "Saved Schemas", addSpace=True) self.schemaFilterEdit = OWGUIEx.LineEditFilter(self) box.layout().addWidget(self.schemaFilterEdit) self.schemaList = PyListModel([], self, flags=Qt.ItemIsSelectable | Qt.ItemIsEditable | Qt.ItemIsEnabled) self.schemaListProxy = PySortFilterProxyModel(filter_fmt="{0.name}", parent=self) self.schemaListProxy.setFilterCaseSensitivity(Qt.CaseInsensitive) self.schemaListProxy.setSourceModel(self.schemaList) self.schemaListView = QListView() self.schemaListView.setItemDelegate(PreprocessorSchemaDelegate(self)) # self.schemaListView.setModel(self.schemaList) self.schemaListView.setModel(self.schemaListProxy) self.connect(self.schemaFilterEdit, SIGNAL("textEdited(QString)"), self.schemaListProxy.setFilterRegExp) box.layout().addWidget(self.schemaListView) self.schemaListSelectionModel = ListSingleSelectionModel( self.schemaListProxy, self) self.schemaListView.setSelectionMode(QListView.SingleSelection) self.schemaListView.setSelectionModel(self.schemaListSelectionModel) self.connect(self.schemaListSelectionModel, SIGNAL("selectedIndexChanged(QModelIndex)"), self.onSchemaSelection) self.addSchemaAction = QAction("+", self) self.addSchemaAction.pyqtConfigure( toolTip="Add a new preprocessor schema") self.updateSchemaAction = QAction("Update", self) self.updateSchemaAction.pyqtConfigure( toolTip="Save changes made in the current schema") self.removeSchemaAction = QAction("-", self) self.removeSchemaAction.pyqtConfigure(toolTip="Remove selected schema") self.updateSchemaAction.setEnabled(False) self.removeSchemaAction.setEnabled(False) actionsWidget = ModelActionsWidget([]) actionsWidget.addAction(self.addSchemaAction) actionsWidget.addAction(self.updateSchemaAction).setSizePolicy( QSizePolicy.MinimumExpanding, QSizePolicy.Fixed) actionsWidget.addAction(self.removeSchemaAction) actionsWidget.layout().setSpacing(1) box.layout().addWidget(actionsWidget) self.connect(self.addSchemaAction, SIGNAL("triggered()"), self.onAddSchema) self.connect(self.updateSchemaAction, SIGNAL("triggered()"), self.onUpdateSchema) self.connect(self.removeSchemaAction, SIGNAL("triggered()"), self.onRemoveSchema) self.addPreprocessorsMenuActions = actions = [] for name, pp, kwargs in self.preprocessors: action = QAction(name, self) self.connect(action, SIGNAL("triggered()"), lambda pp=pp, kwargs=kwargs: self.addPreprocessor( pp(**kwargs))) actions.append(action) box = OWGUI.widgetBox(self.controlArea, "Output") cb = OWGUI.checkBox(box, self, "autoCommit", "Commit on any change", callback=self.commitIf) b = OWGUI.button(box, self, "Commit", callback=self.commit) OWGUI.setStopper(self, b, cb, "changedFlag", callback=self.commitIf) self.mainAreaStack = QStackedLayout() self.stackedEditorsCache = {} OWGUI.widgetBox(self.mainArea, orientation=self.mainAreaStack) self.data = None self.learner = None self.loadSettings() self.activateLoadedSettings()
def __init__(self, parent=None, signalManager=None): #OWWidget.__init__(self, parent, 'Hierarchical Clustering') OWWidget.__init__(self, parent, signalManager, 'Hierarchical Clustering') self.parent = parent self.callbackDeposit = [] self.inputs = [("Distance matrix", orange.SymMatrix, self.dataset)] self.outputs = [("Selected Examples", ExampleTable), ("Unselected Examples", ExampleTable), ("Structured Data Files", DataFiles)] self.linkage = [ ("Single linkage", orange.HierarchicalClustering.Single), ("Average linkage", orange.HierarchicalClustering.Average), ("Ward's linkage", orange.HierarchicalClustering.Ward), ("Complete linkage", orange.HierarchicalClustering.Complete), ] self.Linkage = 0 self.OverwriteMatrix = 0 self.Annotation = 0 self.Brightness = 5 self.PrintDepthCheck = 0 self.PrintDepth = 100 self.HDSize = 500 #initial horizontal and vertical dendrogram size self.VDSize = 800 self.ManualHorSize = 0 self.AutoResize = 0 self.TextSize = 8 self.LineSpacing = 4 self.SelectionMode = 0 self.ZeroOffset = 1 self.DisableHighlights = 0 self.DisableBubble = 0 self.ClassifySelected = 0 self.CommitOnChange = 0 self.ClassifyName = "HC_class" self.loadSettings() self.AutoResize = False self.inputMatrix = None self.matrixSource = "Unknown" self.rootCluster = None self.selectedExamples = None self.ctrlPressed = FALSE self.addIdAs = 0 self.settingsChanged = False self.linkageMethods = [a[0] for a in self.linkage] ################################# ##GUI ################################# #Tabs ## self.tabs = OWGUI.tabWidget(self.controlArea) ## self.settingsTab = OWGUI.createTabPage(self.tabs, "Settings") ## self.selectionTab= OWGUI.createTabPage(self.tabs, "Selection") #HC Settings OWGUI.comboBox(self.controlArea, self, "Linkage", box="Linkage", items=self.linkageMethods, tooltip="Choose linkage method", callback=self.constructTree, addSpace=16) #Label box = OWGUI.widgetBox(self.controlArea, "Annotation", addSpace=16) self.labelCombo = OWGUI.comboBox(box, self, "Annotation", items=["None"], tooltip="Choose label attribute", callback=self.updateLabel) OWGUI.spin(box, self, "TextSize", label="Text font size", min=5, max=15, step=1, callback=self.applySettings, controlWidth=40) OWGUI.spin(box, self, "LineSpacing", label="Line spacing", min=2, max=8, step=1, callback=self.applySettings, controlWidth=40) # OWGUI.checkBox(box, self, "DisableBubble", "Disable bubble info") #Dendrogram graphics settings dendrogramBox = OWGUI.widgetBox(self.controlArea, "Dendrogram settings", addSpace=16) #OWGUI.spin(dendrogramBox, self, "Brightness", label="Brigthtness",min=1,max=9,step=1) cblp = OWGUI.checkBox(dendrogramBox, self, "PrintDepthCheck", "Limit print depth", callback=self.applySettings) ib = OWGUI.indentedBox(dendrogramBox, orientation=0) OWGUI.widgetLabel(ib, "Depth" + " ") slpd = OWGUI.hSlider(ib, self, "PrintDepth", minValue=1, maxValue=50, callback=self.applySettings) cblp.disables.append(ib) cblp.makeConsistent() OWGUI.separator(dendrogramBox) #OWGUI.spin(dendrogramBox, self, "VDSize", label="Vertical size", min=100, # max=10000, step=10) cbhs = OWGUI.checkBox( dendrogramBox, self, "ManualHorSize", "Manually set horizontal size", callback=[ lambda: self.hSizeBox.setDisabled(self.ManualHorSize), self.applySettings ]) self.hSizeBox = OWGUI.spin(OWGUI.indentedBox(dendrogramBox), self, "HDSize", label="Size" + " ", min=200, max=10000, step=10, callback=self.applySettings, callbackOnReturn=True, controlWidth=45) cbhs.disables.append(self.hSizeBox) cbhs.makeConsistent() #OWGUI.checkBox(dendrogramBox, self, "ManualHorSize", "Fit horizontal size") #OWGUI.checkBox(dendrogramBox, self, "AutoResize", "Auto resize") box = OWGUI.widgetBox(self.controlArea, "Selection") OWGUI.checkBox(box, self, "SelectionMode", "Show cutoff line", callback=self.updateCutOffLine) cb = OWGUI.checkBox(box, self, "ClassifySelected", "Append cluster indices", callback=self.commitDataIf) self.classificationBox = ib = OWGUI.indentedBox(box) le = OWGUI.lineEdit(ib, self, "ClassifyName", "Name" + " ", callback=self.commitDataIf, orientation=0, controlWidth=75) OWGUI.separator(ib, height=4) aa = OWGUI.comboBox( ib, self, "addIdAs", label="Place" + " ", orientation=0, items=["Class attribute", "Attribute", "Meta attribute"], callback=self.commitDataIf) cb.disables.append(ib) cb.makeConsistent() OWGUI.separator(box) cbAuto = OWGUI.checkBox(box, self, "CommitOnChange", "Commit on change") btCommit = OWGUI.button(box, self, "&Commit", self.commitData) OWGUI.setStopper(self, btCommit, cbAuto, "settingsChanged", self.commitData) OWGUI.rubber(self.controlArea) OWGUI.button(self.controlArea, self, "&Save Graph", self.saveGraph, debuggingEnabled=0) scale = QGraphicsScene(self) self.headerView = ScaleView(self, scale, self.mainArea) self.footerView = ScaleView(self, scale, self.mainArea) self.dendrogram = Dendrogram(self) self.dendrogramView = DendrogramView(self.dendrogram, self.mainArea) self.mainArea.layout().addWidget(self.headerView) self.mainArea.layout().addWidget(self.dendrogramView) self.mainArea.layout().addWidget(self.footerView) self.dendrogram.header = self.headerView self.dendrogram.footer = self.footerView self.connect(self.dendrogramView.horizontalScrollBar(), SIGNAL("valueChanged(int)"), self.footerView.horizontalScrollBar().setValue) self.connect(self.dendrogramView.horizontalScrollBar(), SIGNAL("valueChanged(int)"), self.headerView.horizontalScrollBar().setValue) self.dendrogram.setSceneRect(0, 0, self.HDSize, self.VDSize) self.dendrogram.update() self.resize(800, 500) self.matrix = None
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'k-Means Clustering') self.inputs = [("Data", ExampleTable, self.setData)] self.outputs = [("Data", ExampleTable), ("Centroids", ExampleTable)] #set default settings self.K = 2 self.optimized = True self.optimizationFrom = 2 self.optimizationTo = 5 self.scoring = 0 self.distanceMeasure = 0 self.initializationType = 0 self.restarts = 1 self.classifySelected = 1 self.addIdAs = 0 self.runAnyChange = 1 self.classifyName = "Cluster" self.settingsChanged = False self.loadSettings() self.data = None # holds input data self.km = None # holds clustering object # GUI definition # settings box = OWGUI.widgetBox(self.controlArea, "Clusters (k)", addSpace=True, spacing=0) # left, top, right, bottom = box.getContentsMargins() # box.setContentsMargins(left, 0, right, 0) bg = OWGUI.radioButtonsInBox(box, self, "optimized", [], callback=self.setOptimization) fixedBox = OWGUI.widgetBox(box, orientation="horizontal", margin=0, spacing=bg.layout().spacing()) button = OWGUI.appendRadioButton(bg, self, "optimized", "Fixed", insertInto=fixedBox, tooltip="Fixed number of clusters") button.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) fixedBox.layout().setAlignment(button, Qt.AlignLeft) self.fixedSpinBox = OWGUI.spin(OWGUI.widgetBox(fixedBox), self, "K", min=2, max=30, tooltip="Fixed number of clusters", callback=self.update, callbackOnReturn=True) optimizedBox = OWGUI.widgetBox(box, margin=0, spacing=bg.layout().spacing()) button = OWGUI.appendRadioButton(bg, self, "optimized", "Optimized", insertInto=optimizedBox) box = OWGUI.indentedBox(optimizedBox, sep=OWGUI.checkButtonOffsetHint(button)) box.layout().setSpacing(0) self.optimizationBox = box OWGUI.spin(box, self, "optimizationFrom", label="From", min=2, max=99, tooltip="Minimum number of clusters to try", callback=self.updateOptimizationFrom, callbackOnReturn=True) OWGUI.spin(box, self, "optimizationTo", label="To", min=3, max=100, tooltip="Maximum number of clusters to try", callback=self.updateOptimizationTo, callbackOnReturn=True) OWGUI.comboBox(box, self, "scoring", label="Scoring", orientation="horizontal", items=[m[0] for m in self.scoringMethods], callback=self.update) box = OWGUI.widgetBox(self.controlArea, "Settings", addSpace=True) OWGUI.comboBox(box, self, "distanceMeasure", label="Distance measures", items=[name for name, _ in self.distanceMeasures], tooltip=None, indent=20, callback=self.update) cb = OWGUI.comboBox(box, self, "initializationType", label="Initialization", items=[name for name, _ in self.initializations], tooltip=None, indent=20, callback=self.update) OWGUI.spin(cb.box, self, "restarts", label="Restarts", orientation="horizontal", min=1, max=100 if not orngDebugging.orngDebuggingEnabled else 5, callback=self.update, callbackOnReturn=True) box = OWGUI.widgetBox(self.controlArea, "Cluster IDs", addSpace=True) cb = OWGUI.checkBox(box, self, "classifySelected", "Append cluster indices") box = OWGUI.indentedBox(box, sep=OWGUI.checkButtonOffsetHint(cb)) form = QWidget() le = OWGUI.lineEdit(form, self, "classifyName", None, orientation="horizontal", valueType=str) cc = OWGUI.comboBox(form, self, "addIdAs", label=" ", orientation="horizontal", items=["Class attribute", "Attribute", "Meta attribute"]) layout = QFormLayout() layout.setSpacing(8) layout.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow) layout.setLabelAlignment(Qt.AlignLeft | Qt.AlignJustify) layout.addRow("Name ", le) layout.addRow("Place ", cc) form.setLayout(layout) box.layout().addWidget(form) left, top, right, bottom = layout.getContentsMargins() layout.setContentsMargins(0, top, right, bottom) cb.disables.append(box) cb.makeConsistent() box = OWGUI.widgetBox(self.controlArea, "Run") cb = OWGUI.checkBox(box, self, "runAnyChange", "Run after any change") self.runButton = b = OWGUI.button(box, self, "Run Clustering", callback=self.run) OWGUI.setStopper(self, b, cb, "settingsChanged", callback=self.run) OWGUI.rubber(self.controlArea) # display of clustering results self.optimizationReportBox = OWGUI.widgetBox(self.mainArea) self.tableBox = OWGUI.widgetBox(self.optimizationReportBox, "Optimization Report") self.table = OWGUI.table(self.tableBox, selectionMode=QTableWidget.SingleSelection) self.table.setHorizontalScrollMode(QTableWidget.ScrollPerPixel) self.table.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.table.setSelectionBehavior(QAbstractItemView.SelectRows) self.table.setColumnCount(3) self.table.setHorizontalHeaderLabels(["k", "Best", "Score"]) self.table.verticalHeader().hide() self.table.horizontalHeader().setStretchLastSection(True) self.table.setItemDelegateForColumn( 2, OWGUI.TableBarItem(self, self.table)) self.table.setItemDelegateForColumn( 1, OWGUI.IndicatorItemDelegate(self)) self.table.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) self.connect(self.table, SIGNAL("itemSelectionChanged()"), self.tableItemSelected) self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) self.mainArea.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) OWGUI.rubber(self.topWidgetPart) self.updateOptimizationGui()
def __init__(self, parent=None, signalManager=None, title="Reliability"): OWWidget.__init__(self, parent, signalManager, title, wantMainArea=False) self.inputs = [ ("Learner", Orange.core.Learner, self.set_learner), ("Training Data", Orange.data.Table, self.set_train_data), ("Test Data", Orange.data.Table, self.set_test_data), ] self.outputs = [("Reliability Scores", Orange.data.Table)] self.variance_checked = False self.bias_checked = False self.bagged_variance = False self.local_cv = False self.local_model_pred_error = False self.bagging_variance_cn = False self.mahalanobis_distance = True self.var_e = "0.01, 0.1, 0.5, 1.0, 2.0" self.bias_e = "0.01, 0.1, 0.5, 1.0, 2.0" self.bagged_m = 10 self.local_cv_k = 2 self.local_pe_k = 5 self.bagged_cn_m = 5 self.bagged_cn_k = 1 self.mahalanobis_k = 3 self.include_error = True self.include_class = True self.include_input_features = False self.auto_commit = False # (selected attr name, getter function, count of returned estimators, indices of estimator results to use) self.estimators = [ ("variance_checked", self.get_SAVar, 3, [0]), ("bias_checked", self.get_SABias, 3, [1, 2]), ("bagged_variance", self.get_BAGV, 1, [0]), ("local_cv", self.get_LCV, 1, [0]), ("local_model_pred_error", self.get_CNK, 2, [0, 1]), ("bagging_variance_cn", self.get_BVCK, 4, [0]), ("mahalanobis_distance", self.get_Mahalanobis, 1, [0]), ] ##### # GUI ##### self.loadSettings() box = OWGUI.widgetBox(self.controlArea, "Info", addSpace=True) self.info_box = OWGUI.widgetLabel(box, "\n\n") rbox = OWGUI.widgetBox(self.controlArea, "Methods", addSpace=True) def method_box(parent, name, value): box = OWGUI.widgetBox(rbox, name, flat=False) box.setCheckable(True) box.setChecked(bool(getattr(self, value))) self.connect( box, SIGNAL("toggled(bool)"), lambda on: (setattr(self, value, on), self.method_selection_changed(value)), ) return box e_validator = QRegExpValidator(QRegExp(r"\s*(-?[0-9]+(\.[0-9]*)\s*,\s*)+"), self) variance_box = method_box(rbox, "Sensitivity analysis (variance)", "variance_checked") OWGUI.lineEdit( variance_box, self, "var_e", "Sensitivities:", tooltip="List of possible e values (comma separated) for SAvar reliability estimates.", callback=partial(self.method_param_changed, 0), validator=e_validator, ) bias_box = method_box(rbox, "Sensitivity analysis (bias)", "bias_checked") OWGUI.lineEdit( bias_box, self, "bias_e", "Sensitivities:", tooltip="List of possible e values (comma separated) for SAbias reliability estimates.", callback=partial(self.method_param_changed, 1), validator=e_validator, ) bagged_box = method_box(rbox, "Variance of bagged models", "bagged_variance") OWGUI.spin( bagged_box, self, "bagged_m", 2, 100, step=1, label="Models:", tooltip="Number of bagged models to be used with BAGV estimate.", callback=partial(self.method_param_changed, 2), keyboardTracking=False, ) local_cv_box = method_box(rbox, "Local cross validation", "local_cv") OWGUI.spin( local_cv_box, self, "local_cv_k", 2, 20, step=1, label="Nearest neighbors:", tooltip="Number of nearest neighbors used in LCV estimate.", callback=partial(self.method_param_changed, 3), keyboardTracking=False, ) local_pe = method_box(rbox, "Local modeling of prediction error", "local_model_pred_error") OWGUI.spin( local_pe, self, "local_pe_k", 1, 20, step=1, label="Nearest neighbors:", tooltip="Number of nearest neighbors used in CNK estimate.", callback=partial(self.method_param_changed, 4), keyboardTracking=False, ) bagging_cnn = method_box(rbox, "Bagging variance c-neighbors", "bagging_variance_cn") OWGUI.spin( bagging_cnn, self, "bagged_cn_m", 2, 100, step=1, label="Models:", tooltip="Number of bagged models to be used with BVCK estimate.", callback=partial(self.method_param_changed, 5), keyboardTracking=False, ) OWGUI.spin( bagging_cnn, self, "bagged_cn_k", 1, 20, step=1, label="Nearest neighbors:", tooltip="Number of nearest neighbors used in BVCK estimate.", callback=partial(self.method_param_changed, 5), keyboardTracking=False, ) mahalanobis_box = method_box(rbox, "Mahalanobis distance", "mahalanobis_distance") OWGUI.spin( mahalanobis_box, self, "mahalanobis_k", 1, 20, step=1, label="Nearest neighbors:", tooltip="Number of nearest neighbors used in BVCK estimate.", callback=partial(self.method_param_changed, 6), keyboardTracking=False, ) box = OWGUI.widgetBox(self.controlArea, "Output") OWGUI.checkBox( box, self, "include_error", "Include prediction error", tooltip="Include prediction error in the output", callback=self.commit_if, ) OWGUI.checkBox( box, self, "include_class", "Include original class and prediction", tooltip="Include original class and prediction in the output.", callback=self.commit_if, ) OWGUI.checkBox( box, self, "include_input_features", "Include input features", tooltip="Include features from the input data set.", callback=self.commit_if, ) cb = OWGUI.checkBox(box, self, "auto_commit", "Commit on any change", callback=self.commit_if) self.commit_button = b = OWGUI.button(box, self, "Commit", callback=self.commit, autoDefault=True) OWGUI.setStopper(self, b, cb, "output_changed", callback=self.commit) self.commit_button.setEnabled(any([getattr(self, selected) for selected, _, _, _ in self.estimators])) self.learner = None self.train_data = None self.test_data = None self.output_changed = False self.train_data_has_no_class = False self.train_data_has_discrete_class = False self.invalidate_results()
def __init__(self, parent=None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "Predictions") self.callbackDeposit = [] self.inputs = [("Data", ExampleTable, self.setData), ("Predictors", orange.Classifier, self.setPredictor, Multiple)] self.outputs = [("Predictions", ExampleTable)] self.predictors = {} # saveble settings self.showProb = 1; self.showClass = 1 self.ShowAttributeMethod = 0 self.sendOnChange = 1 self.classes = [] self.selectedClasses = [] self.loadSettings() self.datalabel = "N/A" self.predictorlabel = "N/A" self.tasklabel = "N/A" self.precision = 2 self.doPrediction = False self.outvar = None # current output variable (set by the first predictor/data set send in) self.data = None self.changedFlag = False self.loadSettings() # GUI - Options # Options - classification ibox = OWGUI.widgetBox(self.controlArea, "Info") OWGUI.label(ibox, self, "Data: %(datalabel)s") OWGUI.label(ibox, self, "Predictors: %(predictorlabel)s") OWGUI.label(ibox, self, "Task: %(tasklabel)s") OWGUI.separator(self.controlArea) self.copt = OWGUI.widgetBox(self.controlArea, "Options (classification)") self.copt.setDisabled(1) cb = OWGUI.checkBox(self.copt, self, 'showProb', "Show predicted probabilities", callback=self.setPredictionDelegate)#self.updateTableOutcomes) # self.lbClasses = OWGUI.listBox(self.copt, self, selectionMode = QListWidget.MultiSelection, callback = self.updateTableOutcomes) ibox = OWGUI.indentedBox(self.copt, sep=OWGUI.checkButtonOffsetHint(cb)) self.lbcls = OWGUI.listBox(ibox, self, "selectedClasses", "classes", callback=[self.setPredictionDelegate, self.checksendpredictions], # callback=[self.updateTableOutcomes, self.checksendpredictions], selectionMode=QListWidget.MultiSelection) self.lbcls.setFixedHeight(50) OWGUI.spin(ibox, self, "precision", 1, 6, label="No. of decimals: ", orientation=0, callback=self.setPredictionDelegate) #self.updateTableOutcomes) cb.disables.append(ibox) ibox.setEnabled(bool(self.showProb)) OWGUI.checkBox(self.copt, self, 'showClass', "Show predicted class", callback=[self.setPredictionDelegate, self.checksendpredictions]) # callback=[self.updateTableOutcomes, self.checksendpredictions]) OWGUI.separator(self.controlArea) self.att = OWGUI.widgetBox(self.controlArea, "Data attributes") OWGUI.radioButtonsInBox(self.att, self, 'ShowAttributeMethod', ['Show all', 'Hide all'], callback=lambda :self.setDataModel(self.data)) #self.updateAttributes) self.att.setDisabled(1) OWGUI.rubber(self.controlArea) OWGUI.separator(self.controlArea) self.outbox = OWGUI.widgetBox(self.controlArea, "Output") b = self.commitBtn = OWGUI.button(self.outbox, self, "Send Predictions", callback=self.sendpredictions, default=True) cb = OWGUI.checkBox(self.outbox, self, 'sendOnChange', 'Send automatically') OWGUI.setStopper(self, b, cb, "changedFlag", callback=self.sendpredictions) OWGUI.checkBox(self.outbox, self, "doPrediction", "Replace/add predicted class", tooltip="Apply the first predictor to input examples and replace/add the predicted value as the new class variable.", callback=self.checksendpredictions) self.outbox.setDisabled(1) ## GUI table self.splitter = splitter = QSplitter(Qt.Horizontal, self.mainArea) self.dataView = QTableView() self.predictionsView = QTableView() self.dataView.verticalHeader().setDefaultSectionSize(22) self.dataView.setHorizontalScrollMode(QTableWidget.ScrollPerPixel) self.dataView.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.dataView.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.predictionsView.verticalHeader().setDefaultSectionSize(22) self.predictionsView.setHorizontalScrollMode(QTableWidget.ScrollPerPixel) self.predictionsView.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.predictionsView.verticalHeader().hide() # def syncVertical(value): # """ sync vertical scroll positions of the two views # """ # v1 = self.predictionsView.verticalScrollBar().value() # if v1 != value: # self.predictionsView.verticalScrollBar().setValue(value) # v2 = self.dataView.verticalScrollBar().value() # if v2 != value: # self.dataView.verticalScrollBar().setValue(v1) self.connect(self.dataView.verticalScrollBar(), SIGNAL("valueChanged(int)"), self.syncVertical) self.connect(self.predictionsView.verticalScrollBar(), SIGNAL("valueChanged(int)"), self.syncVertical) splitter.addWidget(self.dataView) splitter.addWidget(self.predictionsView) splitter.setHandleWidth(3) splitter.setChildrenCollapsible(False) self.mainArea.layout().addWidget(splitter) self.spliter_restore_state = -1, 0 self.dataModel = None self.predictionsModel = None self.resize(800, 600) self.handledAllSignalsFlag = False
def __init__(self, parent=None, signalManager=None, title="PCA"): OWWidget.__init__(self, parent, signalManager, title, wantGraph=True) self.inputs = [("Input Data", Orange.data.Table, self.set_data)] self.outputs = [("Transformed Data", Orange.data.Table, Default), ("Eigen Vectors", Orange.data.Table)] self.standardize = True self.max_components = 0 self.variance_covered = 100.0 self.use_generalized_eigenvectors = False self.auto_commit = False self.loadSettings() self.data = None self.changed_flag = False ##### # GUI ##### grid = QGridLayout() box = OWGUI.widgetBox(self.controlArea, "Components Selection", orientation=grid) label1 = QLabel("Max components", box) grid.addWidget(label1, 1, 0) sb1 = OWGUI.spin(box, self, "max_components", 0, 1000, tooltip="Maximum number of components", callback=self.on_update, addToLayout=False, keyboardTracking=False) self.max_components_spin = sb1.control self.max_components_spin.setSpecialValueText("All") grid.addWidget(sb1.control, 1, 1) label2 = QLabel("Variance covered", box) grid.addWidget(label2, 2, 0) sb2 = OWGUI.doubleSpin(box, self, "variance_covered", 1.0, 100.0, 1.0, tooltip="Percent of variance covered.", callback=self.on_update, decimals=1, addToLayout=False, keyboardTracking=False) sb2.control.setSuffix("%") grid.addWidget(sb2.control, 2, 1) OWGUI.rubber(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Commit") cb = OWGUI.checkBox(box, self, "auto_commit", "Commit on any change") b = OWGUI.button(box, self, "Commit", callback=self.update_components) OWGUI.setStopper(self, b, cb, "changed_flag", self.update_components) self.plot = Graph() canvas = self.plot.canvas() canvas.setFrameStyle(QFrame.StyledPanel) self.mainArea.layout().addWidget(self.plot) self.plot.setAxisTitle(QwtPlot.yLeft, "Proportion of Variance") self.plot.setAxisTitle(QwtPlot.xBottom, "Principal Components") self.plot.setAxisScale(QwtPlot.yLeft, 0.0, 1.0) self.plot.enableGridXB(True) self.plot.enableGridYL(True) self.plot.setGridColor(Qt.lightGray) self.variance_curve = plot_curve("Variance", pen=QPen(Qt.red, 2), symbol=QwtSymbol.NoSymbol, xaxis=QwtPlot.xBottom, yaxis=QwtPlot.yLeft) self.cumulative_variance_curve = plot_curve("Cumulative Variance", pen=QPen(Qt.darkYellow, 2), symbol=QwtSymbol.NoSymbol, xaxis=QwtPlot.xBottom, yaxis=QwtPlot.yLeft) self.variance_curve.attach(self.plot) self.cumulative_variance_curve.attach(self.plot) self.selection_tool = CutoffControler(parent=self.plot.canvas()) self.selection_tool.cutoffMoved.connect(self.on_cutoff_moved) self.graphButton.clicked.connect(self.saveToFile) self.components = None self.variances = None self.variances_sum = None self.projector_full = None self.currently_selected = 0 self.resize(800, 400)
def __init__(self, parent=None, signalManager=None, title="Edit Domain"): OWWidget.__init__(self, parent, signalManager, title) self.inputs = [("Data", Orange.data.Table, self.set_data)] self.outputs = [("Data", Orange.data.Table)] # Settings # Domain change hints maps from input variables description to # the modified variables description as returned by # `variable_description` function self.domain_change_hints = {} self.selected_index = 0 self.auto_commit = False self.changed_flag = False self.loadSettings() ##### # GUI ##### # The list of domain's variables. box = OWGUI.widgetBox(self.controlArea, "Domain Features") self.domain_view = QListView() self.domain_view.setSelectionMode(QListView.SingleSelection) self.domain_model = VariableListModel() self.domain_view.setModel(self.domain_model) self.connect( self.domain_view.selectionModel(), SIGNAL("selectionChanged(QItemSelection, QItemSelection)"), self.on_selection_changed) box.layout().addWidget(self.domain_view) # A stack for variable editor widgets. box = OWGUI.widgetBox(self.mainArea, "Edit Feature") self.editor_stack = QStackedWidget() box.layout().addWidget(self.editor_stack) box = OWGUI.widgetBox(self.controlArea, "Reset") OWGUI.button(box, self, "Reset selected", callback=self.reset_selected, tooltip="Reset changes made to the selected feature") OWGUI.button(box, self, "Reset all", callback=self.reset_all, tooltip="Reset all changes made to the domain") box = OWGUI.widgetBox(self.controlArea, "Commit") b = OWGUI.button( box, self, "&Commit", callback=self.commit, tooltip="Commit the data with the changed domain", ) cb = OWGUI.checkBox(box, self, "auto_commit", label="Commit automatically", tooltip="Commit the changed domain on any change", callback=self.commit_if) OWGUI.setStopper(self, b, cb, "changed_flag", callback=self.commit) self._editor_cache = {} self.data = None self.edited_variable_index = -1 self.resize(600, 500)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'Hierarchical Clustering', wantGraph=True) self.inputs = [("Distances", Orange.misc.SymMatrix, self.set_matrix)] self.outputs = [("Selected Data", Orange.data.Table), ("Other Data", Orange.data.Table), ("Centroids", Orange.data.Table)] self.linkage = [ ("Single linkage", hierarchical.HierarchicalClustering.Single), ("Average linkage", hierarchical.HierarchicalClustering.Average), ("Ward's linkage", hierarchical.HierarchicalClustering.Ward), ("Complete linkage", hierarchical.HierarchicalClustering.Complete), ] self.Linkage = 3 self.Annotation = 0 self.PrintDepthCheck = 0 self.PrintDepth = 10 # initial horizontal and vertical dendrogram size self.HDSize = 500 self.VDSize = 800 self.ManualHorSize = 0 self.AutoResize = 0 self.TextSize = 8 self.LineSpacing = 4 self.SelectionMode = 0 self.AppendClusters = 0 self.CommitOnChange = 0 self.ClassifyName = "HC_class" self.addIdAs = 0 self.loadSettings() self.inputMatrix = None self.root_cluster = None self.selectedExamples = None self.selectionChanged = False self.linkageMethods = [a[0] for a in self.linkage] ################################# ##GUI ################################# #HC Settings OWGUI.comboBox(self.controlArea, self, "Linkage", box="Linkage", items=self.linkageMethods, tooltip="Choose linkage method", callback=self.run_clustering, addSpace=True) #Label box = OWGUI.widgetBox(self.controlArea, "Annotation", addSpace=True) self.labelCombo = OWGUI.comboBox(box, self, "Annotation", items=["None"], tooltip="Choose label attribute", callback=self.update_labels) OWGUI.spin(box, self, "TextSize", label="Text size", min=5, max=15, step=1, callback=self.update_font, controlWidth=40, keyboardTracking=False) # Dendrogram graphics settings dendrogramBox = OWGUI.widgetBox(self.controlArea, "Limits", addSpace=True) form = QFormLayout() form.setLabelAlignment(Qt.AlignLeft) # Depth settings sw = OWGUI.widgetBox(dendrogramBox, orientation="horizontal", addToLayout=False) cw = OWGUI.widgetBox(dendrogramBox, orientation="horizontal", addToLayout=False) OWGUI.hSlider(sw, self, "PrintDepth", minValue=1, maxValue=50, callback=self.on_depth_change) cblp = OWGUI.checkBox(cw, self, "PrintDepthCheck", "Show to depth", callback=self.on_depth_change, disables=[sw]) form.addRow(cw, sw) checkWidth = OWGUI.checkButtonOffsetHint(cblp) # Width settings sw = OWGUI.widgetBox(dendrogramBox, orientation="horizontal", addToLayout=False) cw = OWGUI.widgetBox(dendrogramBox, orientation="horizontal", addToLayout=False) hsb = OWGUI.spin(sw, self, "HDSize", min=200, max=10000, step=10, callback=self.on_width_changed, callbackOnReturn=False, keyboardTracking=False) OWGUI.checkBox(cw, self, "ManualHorSize", "Horizontal size", callback=self.on_width_changed, disables=[sw]) sw.setEnabled(self.ManualHorSize) self.hSizeBox = hsb form.addRow(cw, sw) dendrogramBox.layout().addLayout(form) # Selection settings box = OWGUI.widgetBox(self.controlArea, "Selection") OWGUI.checkBox(box, self, "SelectionMode", "Show cutoff line", callback=self.update_cutoff_line) cb = OWGUI.checkBox(box, self, "AppendClusters", "Append cluster IDs", callback=self.commit_data_if) self.classificationBox = ib = OWGUI.widgetBox(box, margin=0) form = QWidget() le = OWGUI.lineEdit(form, self, "ClassifyName", None, callback=None, orientation="horizontal") self.connect(le, SIGNAL("editingFinished()"), self.commit_data_if) aa = OWGUI.comboBox( form, self, "addIdAs", label=None, orientation="horizontal", items=["Class attribute", "Attribute", "Meta attribute"], callback=self.commit_data_if) layout = QFormLayout() layout.setSpacing(8) layout.setContentsMargins(0, 5, 0, 5) layout.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow) layout.setLabelAlignment(Qt.AlignLeft) layout.addRow("Name ", le) layout.addRow("Place ", aa) form.setLayout(layout) ib.layout().addWidget(form) ib.layout().setContentsMargins(checkWidth, 5, 5, 5) cb.disables.append(ib) cb.makeConsistent() OWGUI.separator(box) cbAuto = OWGUI.checkBox(box, self, "CommitOnChange", "Commit on change") btCommit = OWGUI.button(box, self, "&Commit", self.commit_data, default=True) OWGUI.setStopper(self, btCommit, cbAuto, "selectionChanged", self.commit_data) OWGUI.rubber(self.controlArea) self.connect(self.graphButton, SIGNAL("clicked()"), self.saveGraph) self.scale_scene = scale = ScaleScene(self, self) self.headerView = ScaleView(scale, self) self.footerView = ScaleView(scale, self) self.dendrogram = DendrogramScene(self) self.dendrogramView = DendrogramView(self.dendrogram, self.mainArea) self.connect(self.dendrogram, SIGNAL("clusterSelectionChanged()"), self.on_selection_change) self.connect(self.dendrogram, SIGNAL("sceneRectChanged(QRectF)"), scale.scene_rect_update) self.connect(self.dendrogram, SIGNAL("dendrogramGeometryChanged(QRectF)"), self.on_dendrogram_geometry_change) self.connect(self.dendrogram, SIGNAL("cutoffValueChanged(float)"), self.on_cuttof_value_changed) self.connect(self.dendrogramView, SIGNAL("viewportResized(QSize)"), self.on_width_changed) self.connect(self.dendrogramView, SIGNAL("transformChanged(QTransform)"), self.headerView.setTransform) self.connect(self.dendrogramView, SIGNAL("transformChanged(QTransform)"), self.footerView.setTransform) self.mainArea.layout().addWidget(self.headerView) self.mainArea.layout().addWidget(self.dendrogramView) self.mainArea.layout().addWidget(self.footerView) self.dendrogram.header = self.headerView self.dendrogram.footer = self.footerView self.connect(self.dendrogramView.horizontalScrollBar(), SIGNAL("valueChanged(int)"), self.footerView.horizontalScrollBar().setValue) self.connect(self.dendrogramView.horizontalScrollBar(), SIGNAL("valueChanged(int)"), self.headerView.horizontalScrollBar().setValue) self.dendrogram.setSceneRect(0, 0, self.HDSize, self.VDSize) self.dendrogram.update() self.resize(800, 500) self.natural_dendrogram_width = 800 self.dendrogramView.set_fit_to_width(not self.ManualHorSize) self.matrix = None self.selectionList = [] self.selected_clusters = []
def __init__(self, parent=None, signalManager=None, name="CN2 Rules Viewer"): OWWidget.__init__(self, parent, signalManager, name) self.inputs = [("Rule Classifier", orange.RuleClassifier, self.setRuleClassifier)] self.outputs = [("Data", ExampleTable), ("Features", AttributeList)] self.show_Rule_length = True self.show_Rule_quality = True self.show_Coverage = True self.show_Predicted_class = True self.show_Distribution = True self.show_Rule = True self.autoCommit = False self.selectedAttrsOnly = True self.loadSettings() ##### # GUI ##### box = OWGUI.widgetBox(self.controlArea, "Show Info", addSpace=True) box.layout().setSpacing(3) self.headers = [ "Rule length", "Rule quality", "Coverage", "Predicted class", "Distribution", "Rule" ] for i, header in enumerate(self.headers): OWGUI.checkBox(box, self, "show_%s" % header.replace(" ", "_"), header, tooltip="Show %s column" % header.lower(), callback=self.updateVisibleColumns) box = OWGUI.widgetBox(self.controlArea, "Output") box.layout().setSpacing(3) cb = OWGUI.checkBox(box, self, "autoCommit", "Commit on any change", callback=self.commitIf) OWGUI.checkBox(box, self, "selectedAttrsOnly", "Selected attributes only", tooltip="Send selected attributes only", callback=self.commitIf) b = OWGUI.button(box, self, "Commit", callback=self.commit, default=True) OWGUI.setStopper(self, b, cb, "changedFlag", callback=self.commit) OWGUI.rubber(self.controlArea) self.tableView = QTableView() self.tableView.setItemDelegate(PyObjectItemDelegate(self)) self.tableView.setItemDelegateForColumn(1, PyFloatItemDelegate(self)) self.tableView.setItemDelegateForColumn(2, PyFloatItemDelegate(self)) self.tableView.setItemDelegateForColumn(4, DistributionItemDelegate(self)) self.tableView.setItemDelegateForColumn( 5, MultiLineStringItemDelegate(self)) self.tableView.setSortingEnabled(True) self.tableView.setSelectionBehavior(QTableView.SelectRows) self.tableView.setAlternatingRowColors(True) self.rulesTableModel = PyTableModel([], self.headers) self.proxyModel = QSortFilterProxyModel(self) self.proxyModel.setSourceModel(self.rulesTableModel) self.tableView.setModel(self.proxyModel) self.connect( self.tableView.selectionModel(), SIGNAL("selectionChanged(QItemSelection, QItemSelection)"), lambda is1, is2: self.commitIf()) self.connect(self.tableView.horizontalHeader(), SIGNAL("sectionClicked(int)"), lambda section: self.tableView.resizeRowsToContents()) self.mainArea.layout().addWidget(self.tableView) self.updateVisibleColumns() self.changedFlag = False self.classifier = None self.rules = [] self.resize(800, 600)
def __init__(self, parent=None, signalManager=None, title="PCA"): OWWidget.__init__(self, parent, signalManager, title, wantGraph=True) self.inputs = [("Input Data", Orange.data.Table, self.set_data)] self.outputs = [("Transformed Data", Orange.data.Table, Default), ("Eigen Vectors", Orange.data.Table)] self.standardize = True self.max_components = 0 self.variance_covered = 100.0 self.use_generalized_eigenvectors = False self.auto_commit = False self.loadSettings() self.data = None self.changed_flag = False ##### # GUI ##### grid = QGridLayout() box = OWGUI.widgetBox(self.controlArea, "Components Selection", orientation=grid) label1 = QLabel("Max components", box) grid.addWidget(label1, 1, 0) sb1 = OWGUI.spin(box, self, "max_components", 0, 1000, tooltip="Maximum number of components", callback=self.on_update, addToLayout=False, keyboardTracking=False ) self.max_components_spin = sb1.control self.max_components_spin.setSpecialValueText("All") grid.addWidget(sb1.control, 1, 1) label2 = QLabel("Variance covered", box) grid.addWidget(label2, 2, 0) sb2 = OWGUI.doubleSpin(box, self, "variance_covered", 1.0, 100.0, 1.0, tooltip="Percent of variance covered.", callback=self.on_update, decimals=1, addToLayout=False, keyboardTracking=False ) sb2.control.setSuffix("%") grid.addWidget(sb2.control, 2, 1) OWGUI.rubber(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Commit") cb = OWGUI.checkBox(box, self, "auto_commit", "Commit on any change") b = OWGUI.button(box, self, "Commit", callback=self.update_components) OWGUI.setStopper(self, b, cb, "changed_flag", self.update_components) self.scree_plot = ScreePlot(self) # self.scree_plot.set_main_title("Scree Plot") # self.scree_plot.set_show_main_title(True) self.scree_plot.set_axis_title(owaxis.xBottom, "Principal Components") self.scree_plot.set_show_axis_title(owaxis.xBottom, 1) self.scree_plot.set_axis_title(owaxis.yLeft, "Proportion of Variance") self.scree_plot.set_show_axis_title(owaxis.yLeft, 1) self.variance_curve = self.scree_plot.add_curve( "Variance", Qt.red, Qt.red, 2, xData=[], yData=[], style=OWCurve.Lines, enableLegend=True, lineWidth=2, autoScale=1, x_axis_key=owaxis.xBottom, y_axis_key=owaxis.yLeft, ) self.cumulative_variance_curve = self.scree_plot.add_curve( "Cumulative Variance", Qt.darkYellow, Qt.darkYellow, 2, xData=[], yData=[], style=OWCurve.Lines, enableLegend=True, lineWidth=2, autoScale=1, x_axis_key=owaxis.xBottom, y_axis_key=owaxis.yLeft, ) self.mainArea.layout().addWidget(self.scree_plot) self.connect(self.scree_plot, SIGNAL("cutoff_moved(double)"), self.on_cutoff_moved ) self.connect(self.graphButton, SIGNAL("clicked()"), self.scree_plot.save_to_file) self.components = None self.variances = None self.variances_sum = None self.projector_full = None self.currently_selected = 0 self.resize(800, 400)
def __init__(self, parent=None, signalManager=None): #OWWidget.__init__(self, parent, 'Hierarchical Clustering') OWWidget.__init__(self, parent, signalManager, 'Hierarchical Clustering', wantGraph=True) self.inputs = [("Distance matrix", orange.SymMatrix, self.dataset)] self.outputs = [("Selected Examples", ExampleTable), ("Unselected Examples", ExampleTable), ("Centroids", ExampleTable), ("Structured Data Files", DataFiles)] self.linkage = [ ("Single linkage", orange.HierarchicalClustering.Single), ("Average linkage", orange.HierarchicalClustering.Average), ("Ward's linkage", orange.HierarchicalClustering.Ward), ("Complete linkage", orange.HierarchicalClustering.Complete), ] self.Linkage = 3 self.OverwriteMatrix = 0 self.Annotation = 0 self.Brightness = 5 self.PrintDepthCheck = 0 self.PrintDepth = 100 self.HDSize = 500 #initial horizontal and vertical dendrogram size self.VDSize = 800 self.ManualHorSize = 0 self.AutoResize = 0 self.TextSize = 8 self.LineSpacing = 4 self.SelectionMode = 0 self.ZeroOffset = 1 self.DisableHighlights = 0 self.DisableBubble = 0 self.ClassifySelected = 0 self.CommitOnChange = 0 self.ClassifyName = "HC_class" self.loadSettings() self.AutoResize = False self.inputMatrix = None self.matrixSource = "Unknown" self.rootCluster = None self.selectedExamples = None self.ctrlPressed = FALSE self.addIdAs = 0 self.settingsChanged = False self.linkageMethods = [a[0] for a in self.linkage] ################################# ##GUI ################################# #Tabs ## self.tabs = OWGUI.tabWidget(self.controlArea) ## self.settingsTab = OWGUI.createTabPage(self.tabs, "Settings") ## self.selectionTab= OWGUI.createTabPage(self.tabs, "Selection") #HC Settings OWGUI.comboBox(self.controlArea, self, "Linkage", box="Linkage", items=self.linkageMethods, tooltip="Choose linkage method", callback=self.constructTree, addSpace=True) #Label box = OWGUI.widgetBox(self.controlArea, "Annotation", addSpace=True) self.labelCombo = OWGUI.comboBox(box, self, "Annotation", items=["None"], tooltip="Choose label attribute", callback=self.updateLabel) OWGUI.spin(box, self, "TextSize", label="Text size", min=5, max=15, step=1, callback=self.applySettings, controlWidth=40) OWGUI.spin(box, self, "LineSpacing", label="Line spacing", min=2, max=8, step=1, callback=self.applySettings, controlWidth=40) # OWGUI.checkBox(box, self, "DisableBubble", "Disable bubble info") #Dendrogram graphics settings dendrogramBox = OWGUI.widgetBox(self.controlArea, "Limits", addSpace=True) #OWGUI.spin(dendrogramBox, self, "Brightness", label="Brigthtness",min=1,max=9,step=1) form = QFormLayout() form.setLabelAlignment(Qt.AlignLeft) sw = OWGUI.widgetBox(dendrogramBox, orientation="horizontal", addToLayout=False) #QWidget(dendrogramBox) cw = OWGUI.widgetBox(dendrogramBox, orientation="horizontal", addToLayout=False) #QWidget(dendrogramBox) sllp = OWGUI.hSlider(sw, self, "PrintDepth", minValue=1, maxValue=50, callback=self.applySettings) cblp = OWGUI.checkBox(cw, self, "PrintDepthCheck", "Show to depth", callback=self.applySettings, disables=[sw]) form.addRow(cw, sw) # dendrogramBox.layout().addLayout(form) # box = OWGUI.widgetBox(dendrogramBox, orientation=form) option = QStyleOptionButton() cblp.initStyleOption(option) checkWidth = cblp.style().subElementRect(QStyle.SE_CheckBoxContents, option, cblp).x() # ib = OWGUI.indentedBox(dendrogramBox, orientation = 0) # ib = OWGUI.widgetBox(dendrogramBox, margin=0) # ib.layout().setContentsMargins(checkWidth, 5, 5, 5) # OWGUI.widgetLabel(ib, "Depth"+ " ") # slpd = OWGUI.hSlider(ib, self, "PrintDepth", minValue=1, maxValue=50, label="Depth ", callback=self.applySettings) # cblp.disables.append(ib) # cblp.makeConsistent() # OWGUI.separator(dendrogramBox) #OWGUI.spin(dendrogramBox, self, "VDSize", label="Vertical size", min=100, # max=10000, step=10) # form = QFormLayout() sw = OWGUI.widgetBox(dendrogramBox, orientation="horizontal", addToLayout=False) #QWidget(dendrogramBox) cw = OWGUI.widgetBox(dendrogramBox, orientation="horizontal", addToLayout=False) #QWidget(dendrogramBox) hsb = OWGUI.spin(sw, self, "HDSize", min=200, max=10000, step=10, callback=self.applySettings, callbackOnReturn=False) cbhs = OWGUI.checkBox(cw, self, "ManualHorSize", "Horizontal size", callback=self.applySettings, disables=[sw]) # ib = OWGUI.widgetBox(dendrogramBox, margin=0) # self.hSizeBox=OWGUI.spin(ib, self, "HDSize", label="Size"+" ", min=200, # max=10000, step=10, callback=self.applySettings, callbackOnReturn = True, controlWidth=45) # self.hSizeBox.layout().setContentsMargins(checkWidth, 5, 5, 5) self.hSizeBox = hsb form.addRow(cw, sw) dendrogramBox.layout().addLayout(form) # cbhs.disables.append(self.hSizeBox) # cbhs.makeConsistent() #OWGUI.checkBox(dendrogramBox, self, "ManualHorSize", "Fit horizontal size") #OWGUI.checkBox(dendrogramBox, self, "AutoResize", "Auto resize") box = OWGUI.widgetBox(self.controlArea, "Selection") OWGUI.checkBox(box, self, "SelectionMode", "Show cutoff line", callback=self.updateCutOffLine) cb = OWGUI.checkBox(box, self, "ClassifySelected", "Append cluster IDs", callback=self.commitDataIf) # self.classificationBox = ib = OWGUI.indentedBox(box, sep=0) self.classificationBox = ib = OWGUI.widgetBox(box, margin=0) form = QWidget() le = OWGUI.lineEdit(form, self, "ClassifyName", None, callback=None, orientation="horizontal") self.connect(le, SIGNAL("editingFinished()"), self.commitDataIf) # le_layout.addWidget(le.placeHolder) # OWGUI.separator(ib, height = 4) aa = OWGUI.comboBox( form, self, "addIdAs", label=None, orientation="horizontal", items=["Class attribute", "Attribute", "Meta attribute"], callback=self.commitDataIf) layout = QFormLayout() layout.setSpacing(8) layout.setContentsMargins(0, 5, 0, 5) layout.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow) layout.setLabelAlignment(Qt.AlignLeft) # | Qt.AlignJustify) layout.addRow("Name ", le) layout.addRow("Place ", aa) form.setLayout(layout) ib.layout().addWidget(form) ib.layout().setContentsMargins(checkWidth, 5, 5, 5) cb.disables.append(ib) cb.makeConsistent() OWGUI.separator(box) cbAuto = OWGUI.checkBox(box, self, "CommitOnChange", "Commit on change") btCommit = OWGUI.button(box, self, "&Commit", self.commitData) OWGUI.setStopper(self, btCommit, cbAuto, "settingsChanged", self.commitData) OWGUI.rubber(self.controlArea) # OWGUI.button(self.controlArea, self, "&Save Graph", self.saveGraph, debuggingEnabled = 0) self.connect(self.graphButton, SIGNAL("clicked()"), self.saveGraph) scale = QGraphicsScene(self) self.headerView = ScaleView(self, scale, self.mainArea) self.footerView = ScaleView(self, scale, self.mainArea) self.dendrogram = Dendrogram(self) self.dendrogramView = DendrogramView(self.dendrogram, self.mainArea) self.connect(self.dendrogram, SIGNAL("sceneRectChanged(QRectF)"), self.footerView.sceneRectUpdated) self.mainArea.layout().addWidget(self.headerView) self.mainArea.layout().addWidget(self.dendrogramView) self.mainArea.layout().addWidget(self.footerView) self.dendrogram.header = self.headerView self.dendrogram.footer = self.footerView self.connect(self.dendrogramView.horizontalScrollBar(), SIGNAL("valueChanged(int)"), self.footerView.horizontalScrollBar().setValue) self.connect(self.dendrogramView.horizontalScrollBar(), SIGNAL("valueChanged(int)"), self.headerView.horizontalScrollBar().setValue) self.dendrogram.setSceneRect(0, 0, self.HDSize, self.VDSize) self.dendrogram.update() self.resize(800, 500) self.matrix = None self.selectionList = []