def defineGUI(self): # Set the number of hidden neurons throught the GUI OWGUI.lineEdit(self.controlArea, self, 'name', box='Learner/Classifier Name', \ tooltip='Name to be used by other widgets to identify your learner/classifier.<br>This should be a unique name!') # Apply the settings and send the learner to the output channel OWGUI.button(self.controlArea, self,"&Apply settings", callback=self.applySettings) # Get desired location of model file boxFile = OWGUI.widgetBox(self.controlArea, "Path for saving Model", addSpace = True, orientation=0) L1 = OWGUI.lineEdit(boxFile, self, "modelFile", labelWidth=80, orientation = "horizontal", \ tooltip = "Once a model is created (connect this widget with a data widget), \nit can be saved by giving a \ file name here and clicking the save button.") L1.setMinimumWidth(200) button = OWGUI.button(boxFile, self, '...', callback = self.browseFile, disabled=0,tooltip = "Choose the dir where to save. After chosen, add a name for the model file!") button.setMaximumWidth(25) # Save the model OWGUI.button(self.controlArea, self,"&Save model to file", callback=self.saveModel) # Status Label #box = OWGUI.widgetBox(self.controlArea, "Info ") self.info = OWGUI.widgetLabel(self.controlArea, '') self.applySettings() self.adjustSize()
def __init__(self, parent=None, signalManager = None, name='Histogram'): OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0) self.callbackDeposit = [] self.inputs = [("Data", Clusters, self.setData)] self.outputs = [("Histogram", Histograms)] # , ("Histograms", ExampleTable)] self.useLazyEvaluation = pynopticon.useLazyEvaluation # Settings self.name = name self.histogram = None self.bins = 200 self.loadSettings() self.data = None # input data set wbN = OWGUI.widgetBox(self.controlArea, "Histogram Settings") OWGUI.spin(wbN, self, "bins", 1, 100000, 100, None, "Number of bins ", orientation="horizontal") OWGUI.separator(self.controlArea) wbS = OWGUI.widgetBox(self.controlArea, "Widget Settings") OWGUI.checkBox(wbS, self, "useLazyEvaluation", "Use lazy evaluation") OWGUI.button(self.controlArea, self, "&Apply Settings", callback = self.applySettings, disabled=0) self.resize(100,150)
def _check_box(self, widget, value, label, cb_name): """ Adds a :obj:`.QCheckBox` to ``widget``. When the checkbox is toggled, the attribute ``value`` of the plot object is set to the checkbox' check state, and the callback ``cb_name`` is called. """ OWGUI.checkBox(widget, self._plot, value, label, callback=self._get_callback(cb_name))
def __init__(self, parent=None, signalManager = None, name='filter'): OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0) self.callbackDeposit = [] self.inputs = [("Untransformed Data", SeqContainer, self.setData), ("Labels", SeqContainer, self.setLabels)] self.outputs = [("Transformed Data", SeqContainer)] self.useLazyEvaluation = armor.useLazyEvaluation # Settings self.name = name self.transform = None self.transidx = 1 self.transtype = None self.transtypes = ['none', 'PCA','KPCA', 'LLE'] self.kernel = None self.kernelidx = 1 self.kerneltypes = ['linear_kernel', 'gaussian_kernel', 'chi2_kernel'] self.loadSettings() self.data = None # input data set wbN = OWGUI.widgetBox(self.controlArea, "Transformation Settings") self.transcombo = OWGUI.comboBoxWithCaption(wbN, self, "transidx", "Transform type: ", items=self.transtypes, valueType = int) self.kernelcombo = OWGUI.comboBoxWithCaption(wbN, self, "kernelidx", "Kernel type: ", items=self.kerneltypes, valueType = int) wbS = OWGUI.widgetBox(self.controlArea, "Widget Settings") OWGUI.checkBox(wbS, self, "useLazyEvaluation", "Use lazy evaluation") OWGUI.separator(self.controlArea) OWGUI.button(self.controlArea, self, "&Apply Settings", callback = self.applySettings, disabled=0) self.resize(100,150)
def __init__(self, parent=None, signalManager=None, title="Multiple Correspondence Analysis"): OWCorrespondenceAnalysis.__init__(self, parent, signalManager, title) self.inputs = [("Data", ExampleTable, self.setData)] self.outputs = [("Selected Data", ExampleTable), ("Remaining Data", ExampleTable)] # self.allAttrs = [] self.allAttributes = [] self.selectedAttrs = [] # GUI # Hide the row and column attributes combo boxes self.colAttrCB.box.hide() self.rowAttrCB.box.hide() box = OWGUI.widgetBox(self.graphTab, "Attributes", addToLayout=False) self.graphTab.layout().insertWidget(0, box) self.graphTab.layout().insertSpacing(1, 4) self.attrsListBox = OWGUI.listBox(box, self, "selectedAttrs", "allAttributes", tooltip="Attributes to include in the analysis", callback=self.runCA, selectionMode=QListWidget.ExtendedSelection, ) # Find and hide the "Percent of Column Points" box boxes = self.graphTab.findChildren(QGroupBox) boxes = [box for box in boxes if str(box.title()).strip() == "Percent of Column Points"] if boxes: boxes[0].hide()
def __init__(self,parent=None): self.signalManager = orngSignalManager.SignalManager() OWBaseWidget.__init__(self, title = 'unsupervised1', signalManager = self.signalManager) self.widgets = {} self.loadSettings() self.setLayout(QVBoxLayout()) self.box = OWGUI.widgetBox(self, 'Widgets') self.createWidget('OWFile', 'icons/File.png', 'File', 1, self.signalManager) self.createWidget('OWDataDomain', 'icons/SelectAttributes.png', 'Select Attributes', 1, self.signalManager) self.createWidget('OWDataSampler', 'icons/DataSampler.png', 'Data Sampler', 1, self.signalManager) self.createWidget('OWExampleDistance', 'icons/ExampleDistance.png', 'Example Distance', 1, self.signalManager) self.createWidget('OWAttributeDistance', 'icons/AttributeDistance.png', 'Attribute Distance', 1, self.signalManager) self.createWidget('OWSymMatrixTransform', 'icons/DistanceFile.png', 'Matrix Transformation (2)', 1, self.signalManager) self.createWidget('OWDistanceMap', 'icons/DistanceMap.png', 'Distance Map', 1, self.signalManager) self.createWidget('OWMDS', 'icons/MDS.png', 'MDS (2)', 1, self.signalManager) self.createWidget('OWNetworkFromDistances', 'icons/NetworkFromDistances.png', 'Network from Distances', 1, self.signalManager) self.createWidget('OWNetExplorer', 'icons/Network.png', 'Net Explorer (2)', 1, self.signalManager) self.createWidget('OWSymMatrixTransform', 'icons/DistanceFile.png', 'Matrix Transformation', 1, self.signalManager) self.createWidget('OWDistanceMap', 'icons/DistanceMap.png', 'Distance Map (2)', 1, self.signalManager) self.createWidget('OWMDS', 'icons/MDS.png', 'MDS', 1, self.signalManager) self.createWidget('OWNetworkFromDistances', 'icons/NetworkFromDistances.png', 'Network from Distances (2)', 1, self.signalManager) self.createWidget('OWNetExplorer', 'icons/Network.png', 'Net Explorer', 1, self.signalManager) box2 = OWGUI.widgetBox(self, 1) exitButton = OWGUI.button(box2, self, "Exit", callback = self.accept) self.layout().addStretch(100) statusBar = QStatusBar(self) self.layout().addWidget(statusBar) self.caption = QLabel('', statusBar) self.caption.setMaximumWidth(230) self.progress = QProgressBar(statusBar) self.progress.setMaximumWidth(100) self.status = QLabel("", statusBar) self.status.setSizePolicy(QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)) statusBar.addWidget(self.progress) statusBar.addWidget(self.caption) statusBar.addWidget(self.status) # add widget signals self.signalManager.setFreeze(1) self.signalManager.addLink( self.widgets['File'], self.widgets['Select Attributes'], 'Examples', 'Examples', 1) self.signalManager.addLink( self.widgets['Select Attributes'], self.widgets['Data Sampler'], 'Examples', 'Data', 1) self.signalManager.addLink( self.widgets['Data Sampler'], self.widgets['Example Distance'], 'Sample', 'Examples', 1) self.signalManager.addLink( self.widgets['Data Sampler'], self.widgets['Attribute Distance'], 'Sample', 'Examples', 1) self.signalManager.addLink( self.widgets['Attribute Distance'], self.widgets['Matrix Transformation'], 'Distance Matrix', 'Matrix', 1) self.signalManager.addLink( self.widgets['Example Distance'], self.widgets['Matrix Transformation (2)'], 'Distance Matrix', 'Matrix', 1) self.signalManager.addLink( self.widgets['Matrix Transformation (2)'], self.widgets['Distance Map'], 'Matrix', 'Distance Matrix', 1) self.signalManager.addLink( self.widgets['Matrix Transformation'], self.widgets['Distance Map (2)'], 'Matrix', 'Distance Matrix', 1) self.signalManager.addLink( self.widgets['Matrix Transformation'], self.widgets['MDS'], 'Matrix', 'Distances', 1) self.signalManager.addLink( self.widgets['Matrix Transformation (2)'], self.widgets['MDS (2)'], 'Matrix', 'Distances', 1) self.signalManager.addLink( self.widgets['Matrix Transformation (2)'], self.widgets['Network from Distances'], 'Matrix', 'Distance Matrix', 1) self.signalManager.addLink( self.widgets['Matrix Transformation'], self.widgets['Network from Distances (2)'], 'Matrix', 'Distance Matrix', 1) self.signalManager.addLink( self.widgets['Network from Distances (2)'], self.widgets['Net Explorer'], 'Network', 'Network', 1) self.signalManager.addLink( self.widgets['Network from Distances'], self.widgets['Net Explorer (2)'], 'Network', 'Network', 1) self.signalManager.addLink( self.widgets['Matrix Transformation (2)'], self.widgets['Net Explorer (2)'], 'Matrix', 'Vertex Distance', 1) self.signalManager.addLink( self.widgets['Matrix Transformation'], self.widgets['Net Explorer'], 'Matrix', 'Vertex Distance', 1) self.signalManager.setFreeze(0)
def init_optional_metadata_page(self): self.optionalMetaDataPage = page = QWizardPage() page.setTitle("Optional Add-on Information") page.setLayout(QVBoxLayout()) self.addPage( page ) p = OWGUI.widgetBox(page, "Optionally, enter the following information about your add-on", orientation="vertical") self.preferredDir = "" self.e_preferreddir = ePreferredDir = OWGUI.lineEdit(p, self, "preferredDir", "Preferred directory name (within add-ons directory; optional):", callback=self.preferred_dir_change_callback, callbackOnType=True) self.e_homepage = eHomePage = OWGUI.lineEdit(p, self, None, "Add-on webpage (optional):") self.preferred_dir_touched = False h = OWGUI.widgetBox(p, orientation="horizontal") self.e_tags = self.new_textedit("Tags (one per line, optional):", h) self.e_aorganizations = self.new_textedit("Contributing organizations (one per line, optional):", h) h = OWGUI.widgetBox(p, orientation="horizontal") self.e_aauthors = self.new_textedit("Authors (one per line, optional):", h) self.e_acontributors = self.new_textedit("Contributors (one per line, optional):", h) for noWrapEdit in [self.e_tags, self.e_aauthors, self.e_acontributors, self.e_aorganizations]: noWrapEdit.setLineWrapMode(QTextEdit.NoWrap) def formatList(control, ev): entries = control.parseEntries() control.setPlainText("\n".join(entries)) QTextEdit.focusOutEvent(control, ev) for listEdit in [self.e_tags, self.e_aauthors, self.e_acontributors, self.e_aorganizations]: listEdit.parseEntries = lambda control=listEdit: [entry for entry in map(lambda x: x.strip(), unicode(control.toPlainText()).split("\n")) if entry] listEdit.focusOutEvent = formatList
def __init__(self,parent=None): self.signalManager = orngSignalManager.SignalManager() OWBaseWidget.__init__(self, title = 'logistic_regression', signalManager = self.signalManager) self.widgets = {} self.loadSettings() self.setLayout(QVBoxLayout()) self.box = OWGUI.widgetBox(self, 'Widgets') self.createWidget('OWFile', 'icons/File.png', 'File', 1, self.signalManager) self.createWidget('OWLogisticRegression', 'icons/LogisticRegression.png', 'Logistic Regression', 1, self.signalManager) self.createWidget('OWTestLearners', 'icons/TestLearners.png', 'Test Learners', 1, self.signalManager) box2 = OWGUI.widgetBox(self, 1) exitButton = OWGUI.button(box2, self, "Exit", callback = self.accept) self.layout().addStretch(100) statusBar = QStatusBar(self) self.layout().addWidget(statusBar) self.caption = QLabel('', statusBar) self.caption.setMaximumWidth(230) self.progress = QProgressBar(statusBar) self.progress.setMaximumWidth(100) self.status = QLabel("", statusBar) self.status.setSizePolicy(QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)) statusBar.addWidget(self.progress) statusBar.addWidget(self.caption) statusBar.addWidget(self.status) # add widget signals self.signalManager.setFreeze(1) self.signalManager.addLink( self.widgets['File'], self.widgets['Test Learners'], 'Examples', 'Data', 1) self.signalManager.addLink( self.widgets['Logistic Regression'], self.widgets['Test Learners'], 'Learner', 'Learner', 1) self.signalManager.setFreeze(0)
def __init__(self, parent=None, signalManager = None, name='Loader'): OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0) self.callbackDeposit = [] self.inputs = [] self.outputs = [("Descriptors", Descriptors), ("Codebook", Codebook), ("Images", Images), ("Labels", Labels), ("Histograms", Histograms), ("Clusters", Clusters)] self.useLazyEvaluation = pynopticon.useLazyEvaluation # Settings self.name = name self.loadSettings() self.fname = None self.slot = None #OWGUI.separator(self.controlArea) OWGUI.button(self.controlArea, self, "Loading from...", callback = self.browseFile, disabled=0) self.resize(50,150)
def __init__(self, parent=None, signalManager=None, name="Load Rules"): OWWidget.__init__(self, parent, signalManager, name, wantMainArea=False) self.outputs = [("Rules", associate.AssociationRules, Dynamic)] self.filename_history = [] self.selected_file_index = 0 self.last_file = os.path.expanduser("~/orange_rules.pck") self.loadSettings() self.filename_history= filter(os.path.exists, self.filename_history) ##### # GUI ##### box = OWGUI.widgetBox(self.controlArea, "File", orientation="horizontal", addSpace=True) self.files_combo = OWGUI.comboBox(box, self, "selected_file_index", items = [os.path.basename(p) for p in self.filename_history], tooltip="Select a recent file", callback=self.on_recent_selection) self.browseButton = OWGUI.button(box, self, "...", callback=self.browse, tooltip = "Browse file system") self.browseButton.setIcon(self.style().standardIcon(QStyle.SP_DirOpenIcon)) self.browseButton.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) OWGUI.rubber(self.controlArea) self.resize(200, 50) if self.filename_history: self.load_and_send()
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "FeatureConstructor") # To enable the use of primary table, uncomment the next line and comment the following one # self.inputs = [("Primary Table", dataUtilities.DataTable, self.setData), ("Additional Tables", dataUtilities.DataTable, self.setMoreData, Multiple)] self.inputs = [("Tables", orange.ExampleTable, self.setMoreData, Multiple)] self.outputs = [("Examples", ExampleTable)] self.mergeAttributes = 0 self.primary = None self.additional = {} bg = self.bgMerge = OWGUI.radioButtonsInBox( self.controlArea, self, "mergeAttributes", [], "Domains merging", callback=self.apply ) OWGUI.widgetLabel(bg, "") # "When there is no primary table, the domain should be") OWGUI.appendRadioButton(bg, self, "mergeAttributes", "Union of attributes appearing in all tables") OWGUI.appendRadioButton(bg, self, "mergeAttributes", "Intersection of attributes in all tables") # OWGUI.widgetLabel(bg, "The resulting table will have class only if there is no conflict betwen input classes.") infoBox = OWGUI.widgetBox(self, "Concatenate status") self.infoStatus = OWGUI.widgetLabel(infoBox, "") self.viewBT = OWGUI.button( self.controlArea, self, "&View converted incompatible attributes", callback=self.viewIncompatible, disabled=1, ) self.adjustSize()
def __init__(self,parent=None): self.signalManager = orngSignalManager.SignalManager() OWBaseWidget.__init__(self, title = 'predictions1', signalManager = self.signalManager) self.widgets = {} self.loadSettings() self.setLayout(QVBoxLayout()) self.box = OWGUI.widgetBox(self, 'Widgets') self.createWidget('OWFile', 'icons/File.png', 'File', 1, self.signalManager) self.createWidget('OWDataSampler', 'icons/DataSampler.png', 'Data Sampler', 1, self.signalManager) self.createWidget('OWNaiveBayes', 'icons/NaiveBayes.png', 'Naive Bayes', 1, self.signalManager) self.createWidget('OWLogisticRegression', 'icons/LogisticRegression.png', 'Logistic Regression', 1, self.signalManager) self.createWidget('OWKNN', 'icons/kNearestNeighbours.png', 'k Nearest Neighbours', 1, self.signalManager) self.createWidget('OWClassificationTree', 'icons/ClassificationTree.png', 'Classification Tree', 1, self.signalManager) self.createWidget('OWSVM', 'icons/BasicSVM.png', 'SVM', 1, self.signalManager) self.createWidget('OWCN2', 'icons/CN2.png', 'CN2', 1, self.signalManager) self.createWidget('OWMajority', 'icons/Majority.png', 'Majority', 1, self.signalManager) self.createWidget('OWRandomForest', 'icons/RandomForest.png', 'Random Forest', 1, self.signalManager) self.createWidget('OWPredictions', 'icons/Predictions.png', 'Predictions', 1, self.signalManager) self.createWidget('OWDataTable', 'icons/DataTable.png', 'Data Table', 1, self.signalManager) box2 = OWGUI.widgetBox(self, 1) exitButton = OWGUI.button(box2, self, "Exit", callback = self.accept) self.layout().addStretch(100) statusBar = QStatusBar(self) self.layout().addWidget(statusBar) self.caption = QLabel('', statusBar) self.caption.setMaximumWidth(230) self.progress = QProgressBar(statusBar) self.progress.setMaximumWidth(100) self.status = QLabel("", statusBar) self.status.setSizePolicy(QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)) statusBar.addWidget(self.progress) statusBar.addWidget(self.caption) statusBar.addWidget(self.status) # add widget signals self.signalManager.setFreeze(1) self.signalManager.addLink( self.widgets['File'], self.widgets['Data Sampler'], 'Examples', 'Data', 1) self.signalManager.addLink( self.widgets['Data Sampler'], self.widgets['Naive Bayes'], 'Sample', 'Examples', 1) self.signalManager.addLink( self.widgets['Data Sampler'], self.widgets['Logistic Regression'], 'Sample', 'Examples', 1) self.signalManager.addLink( self.widgets['Data Sampler'], self.widgets['k Nearest Neighbours'], 'Sample', 'Examples', 1) self.signalManager.addLink( self.widgets['Data Sampler'], self.widgets['Classification Tree'], 'Sample', 'Examples', 1) self.signalManager.addLink( self.widgets['Data Sampler'], self.widgets['SVM'], 'Sample', 'Example Table', 1) self.signalManager.addLink( self.widgets['Data Sampler'], self.widgets['CN2'], 'Sample', 'Example Table', 1) self.signalManager.addLink( self.widgets['k Nearest Neighbours'], self.widgets['Predictions'], 'KNN Classifier', 'Predictors', 1) self.signalManager.addLink( self.widgets['Logistic Regression'], self.widgets['Predictions'], 'Classifier', 'Predictors', 1) self.signalManager.addLink( self.widgets['Naive Bayes'], self.widgets['Predictions'], 'Naive Bayesian Classifier', 'Predictors', 1) self.signalManager.addLink( self.widgets['CN2'], self.widgets['Predictions'], 'Classifier', 'Predictors', 1) self.signalManager.addLink( self.widgets['SVM'], self.widgets['Predictions'], 'Classifier', 'Predictors', 1) self.signalManager.addLink( self.widgets['Classification Tree'], self.widgets['Predictions'], 'Classification Tree', 'Predictors', 1) self.signalManager.addLink( self.widgets['File'], self.widgets['Predictions'], 'Examples', 'Examples', 1) self.signalManager.addLink( self.widgets['Predictions'], self.widgets['Data Table'], 'Predictions', 'Examples', 1) self.signalManager.addLink( self.widgets['Data Sampler'], self.widgets['Majority'], 'Sample', 'Examples', 1) self.signalManager.addLink( self.widgets['Majority'], self.widgets['Predictions'], 'Classifier', 'Predictors', 1) self.signalManager.addLink( self.widgets['Data Sampler'], self.widgets['Random Forest'], 'Sample', 'Examples', 1) self.signalManager.addLink( self.widgets['Random Forest'], self.widgets['Predictions'], 'Random Forest Classifier', 'Predictors', 1) self.signalManager.setFreeze(0)
def __init__(self, parent=None): OWWidget.__init__(self, parent, "CheckSpin") self.val = 20 self.chk = 1 OWGUI.checkWithSpin(self.controlArea, self, "Prunning, m=", 0, 100, "chk", "val", posttext="%") self.resize(100, 100)
def __init__(self,parent=None): self.signalManager = orngSignalManager.SignalManager() OWBaseWidget.__init__(self, title = 'visualizations', signalManager = self.signalManager) self.widgets = {} self.loadSettings() self.setLayout(QVBoxLayout()) self.box = OWGUI.widgetBox(self, 'Widgets') self.createWidget('OWFile', 'icons/File.png', 'File', 1, self.signalManager) self.createWidget('OWDataSampler', 'icons/DataSampler.png', 'Data Sampler', 1, self.signalManager) self.createWidget('OWDataDomain', 'icons/SelectAttributes.png', 'Select Attributes', 1, self.signalManager) self.createWidget('OWAttributeStatistics', 'icons/AttributeStatistics.png', 'Attribute Statistics', 1, self.signalManager) self.createWidget('OWScatterPlot', 'icons/ScatterPlot.png', 'Scatterplot', 1, self.signalManager) self.createWidget('OWLinProj', 'icons/LinearProjection.png', 'Linear Projection', 1, self.signalManager) self.createWidget('OWRadviz', 'icons/Radviz.png', 'Radviz', 1, self.signalManager) self.createWidget('OWPolyviz', 'icons/Polyviz.png', 'Polyviz', 1, self.signalManager) self.createWidget('OWParallelCoordinates', 'icons/ParallelCoordinates.png', 'Parallel coordinates', 1, self.signalManager) self.createWidget('OWSurveyPlot', 'icons/SurveyPlot.png', 'Survey Plot', 1, self.signalManager) self.createWidget('OWMosaicDisplay', 'icons/MosaicDisplay.png', 'Mosaic Display', 1, self.signalManager) self.createWidget('OWSieveDiagram', 'icons/SieveDiagram.png', 'Sieve Diagram', 1, self.signalManager) box2 = OWGUI.widgetBox(self, 1) exitButton = OWGUI.button(box2, self, "Exit", callback = self.accept) self.layout().addStretch(100) statusBar = QStatusBar(self) self.layout().addWidget(statusBar) self.caption = QLabel('', statusBar) self.caption.setMaximumWidth(230) self.progress = QProgressBar(statusBar) self.progress.setMaximumWidth(100) self.status = QLabel("", statusBar) self.status.setSizePolicy(QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)) statusBar.addWidget(self.progress) statusBar.addWidget(self.caption) statusBar.addWidget(self.status) # add widget signals self.signalManager.setFreeze(1) self.signalManager.addLink( self.widgets['File'], self.widgets['Data Sampler'], 'Examples', 'Data', 1) self.signalManager.addLink( self.widgets['Select Attributes'], self.widgets['Attribute Statistics'], 'Examples', 'Examples', 1) self.signalManager.addLink( self.widgets['Select Attributes'], self.widgets['Scatterplot'], 'Examples', 'Examples', 1) self.signalManager.addLink( self.widgets['Select Attributes'], self.widgets['Linear Projection'], 'Examples', 'Examples', 1) self.signalManager.addLink( self.widgets['Select Attributes'], self.widgets['Radviz'], 'Examples', 'Examples', 1) self.signalManager.addLink( self.widgets['Select Attributes'], self.widgets['Polyviz'], 'Examples', 'Examples', 1) self.signalManager.addLink( self.widgets['Select Attributes'], self.widgets['Parallel coordinates'], 'Examples', 'Examples', 1) self.signalManager.addLink( self.widgets['Select Attributes'], self.widgets['Survey Plot'], 'Examples', 'Examples', 1) self.signalManager.addLink( self.widgets['Select Attributes'], self.widgets['Mosaic Display'], 'Examples', 'Examples', 1) self.signalManager.addLink( self.widgets['Select Attributes'], self.widgets['Sieve Diagram'], 'Examples', 'Examples', 1) self.signalManager.addLink( self.widgets['Data Sampler'], self.widgets['Linear Projection'], 'Remaining Examples', 'Example Subset', 1) self.signalManager.addLink( self.widgets['Data Sampler'], self.widgets['Scatterplot'], 'Remaining Examples', 'Example Subset', 1) self.signalManager.addLink( self.widgets['Data Sampler'], self.widgets['Radviz'], 'Remaining Examples', 'Example Subset', 1) self.signalManager.addLink( self.widgets['Data Sampler'], self.widgets['Polyviz'], 'Remaining Examples', 'Example Subset', 1) self.signalManager.addLink( self.widgets['Data Sampler'], self.widgets['Parallel coordinates'], 'Remaining Examples', 'Example Subset', 1) self.signalManager.addLink( self.widgets['Data Sampler'], self.widgets['Mosaic Display'], 'Remaining Examples', 'Example Subset', 1) self.signalManager.addLink( self.widgets['File'], self.widgets['Select Attributes'], 'Examples', 'Examples', 1) self.signalManager.setFreeze(0)
def __init__(self, parent = None, signalManager = None, name = "Merge data"): OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0) #initialize base class # set channels self.inputs = [("Data A", ExampleTable, self.onDataAInput), ("Data B", ExampleTable, self.onDataBInput)] self.outputs = [("Merged Data A+B", ExampleTable), ("Merged Data B+A", ExampleTable)] # data self.dataA = None self.dataB = None self.varListA = [] self.varListB = [] self.varA = None self.varB = None self.lbAttrAItems = [] self.lbAttrBItems = [] # load settings self.loadSettings() # GUI w = QWidget(self) self.controlArea.layout().addWidget(w) grid = QGridLayout() grid.setMargin(0) w.setLayout(grid) # attribute A boxAttrA = OWGUI.widgetBox(self, 'Attribute A', orientation = "vertical", addToLayout=0) grid.addWidget(boxAttrA, 0,0) self.lbAttrA = OWGUI.listBox(boxAttrA, self, "lbAttrAItems", callback = self.lbAttrAChange) # attribute B boxAttrB = OWGUI.widgetBox(self, 'Attribute B', orientation = "vertical", addToLayout=0) grid.addWidget(boxAttrB, 0,1) self.lbAttrB = OWGUI.listBox(boxAttrB, self, "lbAttrBItems", callback = self.lbAttrBChange) # info A boxDataA = OWGUI.widgetBox(self, 'Data A', orientation = "vertical", addToLayout=0) grid.addWidget(boxDataA, 1,0) self.lblDataAExamples = OWGUI.widgetLabel(boxDataA, "num examples") self.lblDataAAttributes = OWGUI.widgetLabel(boxDataA, "num attributes") # info B boxDataB = OWGUI.widgetBox(self, 'Data B', orientation = "vertical", addToLayout=0) grid.addWidget(boxDataB, 1,1) self.lblDataBExamples = OWGUI.widgetLabel(boxDataB, "num examples") self.lblDataBAttributes = OWGUI.widgetLabel(boxDataB, "num attributes") # icons self.icons = self.createAttributeIconDict() # resize self.resize(400,500)
def createDiscretePalette(self, paletteName, boxCaption, rgbColors = defaultRGBColors): vbox = OWGUI.widgetBox(self.mainArea, boxCaption, orientation = 'vertical') self.__dict__["disc"+paletteName+"View"] = PaletteView(vbox) self.__dict__["disc"+paletteName+"View"].rgbColors = rgbColors hbox = OWGUI.widgetBox(vbox, orientation = 'horizontal') self.__dict__["disc"+paletteName+"EditButt"] = OWGUI.button(hbox, self, "Edit palette", self.editPalette, tooltip = "Edit the order and colors of the palette", debuggingEnabled = 0, toggleButton = 1) self.__dict__["disc"+paletteName+"LoadButt"] = OWGUI.button(hbox, self, "Load palette", self.loadPalette, tooltip = "Load a predefined color palette", debuggingEnabled = 0, toggleButton = 1) self.discPaletteNames.append(paletteName)
def __init__(self,parent=None): self.signalManager = orngSignalManager.SignalManager() OWBaseWidget.__init__(self, title = 'evaluate', signalManager = self.signalManager) self.widgets = {} self.loadSettings() self.setLayout(QVBoxLayout()) self.box = OWGUI.widgetBox(self, 'Widgets') self.createWidget('OWFile', 'icons/File.png', 'File', 1, self.signalManager) self.createWidget('OWDataDomain', 'icons/SelectAttributes.png', 'Select Attributes', 1, self.signalManager) self.createWidget('OWDataSampler', 'icons/DataSampler.png', 'Data Sampler', 1, self.signalManager) self.createWidget('OWNaiveBayes', 'icons/NaiveBayes.png', 'Naive Bayes', 1, self.signalManager) self.createWidget('OWLogisticRegression', 'icons/LogisticRegression.png', 'Logistic Regression', 1, self.signalManager) self.createWidget('OWMajority', 'icons/Majority.png', 'Majority', 1, self.signalManager) self.createWidget('OWKNN', 'icons/kNearestNeighbours.png', 'k Nearest Neighbours', 1, self.signalManager) self.createWidget('OWClassificationTree', 'icons/ClassificationTree.png', 'Classification Tree', 1, self.signalManager) self.createWidget('OWC45Tree', 'icons/C45.png', 'C4.5', 1, self.signalManager) self.createWidget('OWSVM', 'icons/BasicSVM.png', 'SVM', 1, self.signalManager) self.createWidget('OWCN2', 'icons/CN2.png', 'CN2', 1, self.signalManager) self.createWidget('OWTestLearners', 'icons/TestLearners.png', 'Test Learners', 1, self.signalManager) self.createWidget('OWROC', 'icons/ROCAnalysis.png', 'ROC Analysis', 1, self.signalManager) self.createWidget('OWLiftCurve', 'icons/LiftCurve.png', 'Lift Curve', 1, self.signalManager) box2 = OWGUI.widgetBox(self, 1) exitButton = OWGUI.button(box2, self, "Exit", callback = self.accept) self.layout().addStretch(100) statusBar = QStatusBar(self) self.layout().addWidget(statusBar) self.caption = QLabel('', statusBar) self.caption.setMaximumWidth(230) self.progress = QProgressBar(statusBar) self.progress.setMaximumWidth(100) self.status = QLabel("", statusBar) self.status.setSizePolicy(QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)) statusBar.addWidget(self.progress) statusBar.addWidget(self.caption) statusBar.addWidget(self.status) # add widget signals self.signalManager.setFreeze(1) self.signalManager.addLink( self.widgets['File'], self.widgets['Select Attributes'], 'Examples', 'Examples', 1) self.signalManager.addLink( self.widgets['Select Attributes'], self.widgets['Data Sampler'], 'Examples', 'Data', 1) self.signalManager.addLink( self.widgets['Naive Bayes'], self.widgets['Test Learners'], 'Learner', 'Learner', 1) self.signalManager.addLink( self.widgets['Logistic Regression'], self.widgets['Test Learners'], 'Learner', 'Learner', 1) self.signalManager.addLink( self.widgets['Majority'], self.widgets['Test Learners'], 'Learner', 'Learner', 1) self.signalManager.addLink( self.widgets['SVM'], self.widgets['Test Learners'], 'Learner', 'Learner', 1) self.signalManager.addLink( self.widgets['k Nearest Neighbours'], self.widgets['Test Learners'], 'Learner', 'Learner', 1) self.signalManager.addLink( self.widgets['Classification Tree'], self.widgets['Test Learners'], 'Learner', 'Learner', 1) self.signalManager.addLink( self.widgets['C4.5'], self.widgets['Test Learners'], 'Learner', 'Learner', 1) self.signalManager.addLink( self.widgets['CN2'], self.widgets['Test Learners'], 'Learner', 'Learner', 1) self.signalManager.addLink( self.widgets['Test Learners'], self.widgets['ROC Analysis'], 'Evaluation Results', 'Evaluation Results', 1) self.signalManager.addLink( self.widgets['Test Learners'], self.widgets['Lift Curve'], 'Evaluation Results', 'Evaluation Results', 1) self.signalManager.addLink( self.widgets['Data Sampler'], self.widgets['Test Learners'], 'Sample', 'Data', 1) self.signalManager.setFreeze(0)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'FastaConverter') self.inputs = [("convertFastaTab", ExampleTable, self.convertFastaTab)] self.outputs = [("Tab File", ExampleTable)] # GUI box = OWGUI.widgetBox(self.controlArea, "Info") self.infoa = OWGUI.widgetLabel(box, 'No fasta file yet, waiting to get something.') self.infob = OWGUI.widgetLabel(box, '') self.resize(100,50)
def __init__(self, parent=None, signalManager = None, name='ExtractFeatures'): OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0) self.callbackDeposit = [] self.inputs = [("Images PIL", SeqContainer, self.setData)] self.outputs = [("Descriptors", SeqContainer)] self.useLazyEvaluation = armor.useLazyEvaluation # Settings self.name = name self.feature = None self.featureID = 0 self.featureType = None self.features = armor.features.Nowozin.features self.loadSettings() self.data = None # input data set wbN = OWGUI.widgetBox(self.controlArea, "Feature Extractor Settings") self.filecombo = OWGUI.comboBoxWithCaption(wbN, self, "featureID", "Feature type: ", items=self.features, valueType = int) wbS = OWGUI.widgetBox(self.controlArea, "Widget Settings") OWGUI.checkBox(wbS, self, "useLazyEvaluation", "Use lazy evaluation") OWGUI.separator(self.controlArea) OWGUI.button(self.controlArea, self, "&Apply Settings", callback = self.applySettings, disabled=0) self.resize(100,150)
def __init__(self, parent=None, signalManager = None, name='filter'): OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0) self.callbackDeposit = [] self.inputs = [("Unnormalized Data", Histograms, self.setData)] self.outputs = [("Normalized Data", Histograms)] self.useLazyEvaluation = pynopticon.useLazyEvaluation # Settings self.name = name self.normalize = None self.normtype = 1 self.normtypes = ['none', 'bin', 'L1', 'L2', 'whiten', 'bias', 'crop', 'log'] self.loadSettings() self.data = None # input data set wbN = OWGUI.widgetBox(self.controlArea, "Normalization Settings") self.filecombo = OWGUI.comboBoxWithCaption(wbN, self, "normtype", "Normalize type: ", items=self.normtypes, valueType = int) wbS = OWGUI.widgetBox(self.controlArea, "Widget Settings") OWGUI.checkBox(wbS, self, "useLazyEvaluation", "Use lazy evaluation") OWGUI.separator(self.controlArea) OWGUI.button(self.controlArea, self, "&Apply Settings", callback = self.applySettings, disabled=0) self.resize(100,150)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'AttributeSampler') self.inputs = [("Examples", Orange.data.Table, self.dataset)] self.outputs = [("Examples", Orange.data.Table)] self.icons = self.createAttributeIconDict() self.attributeList = [] self.selectedAttributes = [] self.classAttribute = None self.loadSettings() OWGUI.listBox(self.controlArea, self, "selectedAttributes", "attributeList", box="Selected attributes", selectionMode=QListWidget.ExtendedSelection) OWGUI.separator(self.controlArea) self.classAttrCombo = OWGUI.comboBox( self.controlArea, self, "classAttribute", box="Class attribute") OWGUI.separator(self.controlArea) OWGUI.button(self.controlArea, self, "Commit", callback=self.outputData) self.resize(150,400)
def __init__(self, parent=None, signalManager=None, name="filter"): OWWidget.__init__(self, parent, signalManager, name, wantMainArea=0) self.callbackDeposit = [] self.inputs = [("Images PIL", SeqContainer, self.setData)] self.outputs = [("Filtered Images PIL", SeqContainer)] self.useLazyEvaluation = armor.useLazyEvaluation # Settings self.name = name self.filter = None self.filterID = 5 self.filters = armor.filter.Filter().filters.keys() self.loadSettings() self.data = None # input data set wbN = OWGUI.widgetBox(self.controlArea, "Filter Settings") self.filecombo = OWGUI.comboBoxWithCaption( wbN, self, "filterID", "Filters: ", items=self.filters, valueType=str ) wbS = OWGUI.widgetBox(self.controlArea, "Widget Settings") OWGUI.checkBox(wbS, self, "useLazyEvaluation", "Use lazy evaluation") OWGUI.separator(self.controlArea) OWGUI.button(self.controlArea, self, "&Apply Settings", callback=self.applySettings, disabled=0) self.resize(100, 150)
def __init__(self, parent=None, signalManager=None, name="Ensemble"): OWWidget.__init__(self, parent, signalManager, name, wantMainArea=False) self.inputs = [("Learner", orange.Learner, self.setLearner), ("Data", ExampleTable, self.setData)] self.outputs = [("Learner", orange.Learner), ("Classifier", orange.Classifier)] self.method = 0 self.t = 10 self.loadSettings() box = OWGUI.radioButtonsInBox(self.controlArea, self, "method", [name for name, _ in self.METHODS], box="Ensemble", callback=self.onChange) i_box = OWGUI.indentedBox(box, sep=OWGUI.checkButtonOffsetHint(box.buttons[0])) OWGUI.spin(i_box, self, "t", min=1, max=100, step=1, label="Number of created classifiers:") OWGUI.rubber(self.controlArea) OWGUI.button(self.controlArea, self, "&Apply", callback=self.commit) self.data = None self.learner = None self.resize(100, 100)
def __init__(self, parent=None): self.signalManager = orngSignalManager.SignalManager() OWBaseWidget.__init__(self, title="visualizations1", signalManager=self.signalManager) self.widgets = {} self.loadSettings() self.setLayout(QVBoxLayout()) self.box = OWGUI.widgetBox(self, "Widgets") self.createWidget("OWFile", "icons/File.png", "File", 1, self.signalManager) self.createWidget("OWDataSampler", "icons/DataSampler.png", "Data Sampler", 1, self.signalManager) self.createWidget("OWScatterPlot", "icons/ScatterPlot.png", "Scatterplot", 1, self.signalManager) self.createWidget("OWLinProj", "icons/LinearProjection.png", "Linear Projection", 1, self.signalManager) self.createWidget("OWRadviz", "icons/Radviz.png", "Radviz", 1, self.signalManager) self.createWidget("OWPolyviz", "icons/Polyviz.png", "Polyviz", 1, self.signalManager) box2 = OWGUI.widgetBox(self, 1) exitButton = OWGUI.button(box2, self, "Exit", callback=self.accept) self.layout().addStretch(100) statusBar = QStatusBar(self) self.layout().addWidget(statusBar) self.caption = QLabel("", statusBar) self.caption.setMaximumWidth(230) self.progress = QProgressBar(statusBar) self.progress.setMaximumWidth(100) self.status = QLabel("", statusBar) self.status.setSizePolicy(QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)) statusBar.addWidget(self.progress) statusBar.addWidget(self.caption) statusBar.addWidget(self.status) # add widget signals self.signalManager.setFreeze(1) self.signalManager.addLink(self.widgets["File"], self.widgets["Data Sampler"], "Examples", "Data", 1) self.signalManager.addLink(self.widgets["Data Sampler"], self.widgets["Scatterplot"], "Sample", "Examples", 1) self.signalManager.addLink( self.widgets["Data Sampler"], self.widgets["Scatterplot"], "Remaining Examples", "Example Subset", 1 ) self.signalManager.addLink( self.widgets["Data Sampler"], self.widgets["Linear Projection"], "Sample", "Examples", 1 ) self.signalManager.addLink( self.widgets["Data Sampler"], self.widgets["Linear Projection"], "Remaining Examples", "Example Subset", 1 ) self.signalManager.addLink(self.widgets["Data Sampler"], self.widgets["Radviz"], "Sample", "Examples", 1) self.signalManager.addLink( self.widgets["Data Sampler"], self.widgets["Radviz"], "Remaining Examples", "Example Subset", 1 ) self.signalManager.addLink(self.widgets["Data Sampler"], self.widgets["Polyviz"], "Sample", "Examples", 1) self.signalManager.addLink( self.widgets["Data Sampler"], self.widgets["Polyviz"], "Remaining Examples", "Example Subset", 1 ) self.signalManager.setFreeze(0)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'SampleDataA') self.inputs = [("Data", ExampleTable, self.data)] self.outputs = [("Sampled Data", ExampleTable)] # GUI box = OWGUI.widgetBox(self.controlArea, "Info") self.infoa = OWGUI.widgetLabel(box, 'No data on input yet, waiting to get something.') self.infob = OWGUI.widgetLabel(box, '') self.resize(100,50)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'Bio-File') #self.inputs = [("Data", ExampleTable, self.data)] self.outputs = [("Sampled Data", ExampleTable)] # GUI box = OWGUI.widgetBox(self.controlArea, "Info") self.infoa = OWGUI.widgetLabel(box, 'File tool to help import, organize, and manipulate data of various file types from within orange.') self.infob = OWGUI.widgetLabel(box, '') self.resize(100,50)
def createContinuousPalette(self, paletteName, boxCaption, passThroughBlack = 0, initialColor1 = QColor(Qt.white), initialColor2 = Qt.black): buttBox = OWGUI.widgetBox(self.mainArea, boxCaption) box = OWGUI.widgetBox(buttBox, orientation = "horizontal") self.__dict__["cont"+paletteName+"Left"] = ColorButton(self, box, color = QColor(initialColor1)) self.__dict__["cont"+paletteName+"View"] = PaletteView(box) self.__dict__["cont"+paletteName+"Right"] = ColorButton(self, box, color = QColor(initialColor2)) self.__dict__["cont"+paletteName+"passThroughBlack"] = passThroughBlack self.__dict__["cont"+paletteName+"passThroughBlackCheckbox"] = OWGUI.checkBox(buttBox, self, "cont"+paletteName+"passThroughBlack", "Pass through black", callback = self.colorSchemaChange) self.contPaletteNames.append(paletteName)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'SampleDataA') self.inputs = [("Data", ExampleTable, self.oneR)] self.outputs = [("Sampled Data", ExampleTable)] # GUI box = OWGUI.widgetBox( self.controlArea, "Info" ) self.infoa = OWGUI.widgetLabel( box, 'No input data; waiting for the input signal (A).' ) self.infob = OWGUI.widgetLabel( box, '' ) self.resize( 100, 50 )
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'ConceptNet') self.inputs = [("TEST1", WidgetChannelData, self.data)] self.outputs = [("TEST2", WidgetChannelData)] # GUI box = OWGUI.widgetBox(self.controlArea, u"信息") self.infoa = OWGUI.widgetLabel(box, u'万事俱备,只欠东风。') self.infob = OWGUI.widgetLabel(box, u'再见') self.resize(100,50)
def _slider(self, widget, value, label, min_value, max_value, step, cb_name): OWGUI.hSlider( widget, self._plot, value, label=label, minValue=min_value, maxValue=max_value, step=step, callback=self._get_callback(cb_name), )
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.ind = None # indices that control sampling self.Stratified = 1 # use stratified sampling if possible? self.Repeat = 0 # can elements repeat in a sample? self.UseSpecificSeed = 0 # use a specific random seed? self.RandomSeed = 1 # specific seed used self.GroupSeed = 1 # current seed for multiple group selection self.outFold = 1 # folder/group to output self.Folds = 1 # total number of folds/groups self.SelectType = 0 # sampling type (LOO, CV, ...) self.useCases = 0 # use a specific number of cases? self.nCases = 25 # number of cases to use self.selPercentage = 30 # sample size in % self.LOO = 1 # use LOO? self.CVFolds = 10 # number of CV folds self.CVFoldsInternal = 10 # number of CV folds (for internal use) self.nGroups = 3 # number of groups self.pGroups = [0.1, 0.25, 0.5] # sizes of groups self.GroupText = '0.1,0.25,0.5' # assigned to Groups Control (for internal use) self.loadSettings() # GUI # Info Box box1 = OWGUI.widgetBox(self.controlArea, "Information", addSpace=True) self.infoa = OWGUI.widgetLabel(box1, 'No data on input.') self.infob = OWGUI.widgetLabel(box1, ' ') self.infoc = OWGUI.widgetLabel(box1, ' ') # Options Box box2 = OWGUI.widgetBox(self.controlArea, 'Options', addSpace=True) OWGUI.checkBox(box2, self, 'Stratified', 'Stratified (if possible)', callback=self.settingsChanged) OWGUI.checkWithSpin(box2, self, 'Set random seed:', 0, 32767, 'UseSpecificSeed', 'RandomSeed', checkCallback=self.settingsChanged, spinCallback=self.settingsChanged) # Sampling Type Box self.s = [None, None, None, None] self.sBox = OWGUI.widgetBox(self.controlArea, "Sampling type", addSpace=True) self.sBox.buttons = [] # Random Sampling self.s[0] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", 'Random sampling') # indent indent = sep = OWGUI.checkButtonOffsetHint(self.s[0]) # repeat checkbox self.h1Box = OWGUI.indentedBox(self.sBox, sep=indent, orientation="horizontal") OWGUI.checkBox(self.h1Box, self, 'Repeat', 'With replacement', callback=self.settingsChanged) # specified number of elements checkbox self.h2Box = OWGUI.indentedBox(self.sBox, sep=indent, orientation="horizontal") OWGUI.checkWithSpin(self.h2Box, self, 'Sample size (instances):', 1, 1000000000, 'useCases', 'nCases', checkCallback=[self.uCases, self.settingsChanged], spinCallback=self.settingsChanged) OWGUI.rubber(self.h2Box) # percentage slider self.h3Box = OWGUI.indentedBox(self.sBox, sep=indent, orientation="horizontal") OWGUI.widgetLabel(self.h3Box, "Sample size:") self.slidebox = OWGUI.indentedBox(self.sBox, sep=indent, orientation="horizontal") OWGUI.hSlider(self.slidebox, self, 'selPercentage', minValue=1, maxValue=100, step=1, ticks=10, labelFormat=" %d%%", callback=self.settingsChanged) # Cross Validation self.s[1] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", 'Cross validation') box = OWGUI.indentedBox(self.sBox, sep=indent, orientation="horizontal") OWGUI.spin(box, self, 'CVFolds', 2, 100, step=1, label='Number of folds: ', callback=[self.changeCombo, self.settingsChanged]) OWGUI.rubber(box) # Leave-One-Out self.s[2] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", 'Leave-one-out') # Multiple Groups self.s[3] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", 'Multiple subsets') gbox = OWGUI.indentedBox(self.sBox, sep=indent, orientation="horizontal") OWGUI.lineEdit(gbox, self, 'GroupText', label='Subset sizes (e.g. "0.1, 0.2, 0.5"):', callback=self.multipleChanged) # Output Group Box self.foldcombo = OWGUI.comboBox(self.controlArea, self, "outFold", 'Output Data for Fold / Group', 'Fold / group:', orientation="horizontal", items=range(1, 101), callback=self.foldChanged, sendSelectedValue=1, valueType=int) self.foldcombo.setEnabled(False) # Select Data Button OWGUI.rubber(self.controlArea) self.sampleButton = OWGUI.button(self.controlArea, self, 'Sample &Data', callback=self.process, addToLayout=False, default=True) self.buttonBackground.layout().setDirection(QBoxLayout.TopToBottom) self.buttonBackground.layout().insertWidget(0, self.sampleButton) self.buttonBackground.show() self.s[self.SelectType].setChecked( True) # set initial radio button on (default sample type) # CONNECTIONS # set connections for RadioButton (SelectType) self.dummy1 = [None] * len(self.s) for i in range(len(self.s)): self.dummy1[i] = lambda x, v=i: self.sChanged(x, v) self.connect(self.s[i], SIGNAL("toggled(bool)"), self.dummy1[i]) # final touch self.resize(200, 275)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "Nx File", wantMainArea=False) self.inputs = [] self.outputs = [("Network", Orange.network.Graph), ("Items", Orange.data.Table)] #set default settings self.recentFiles = ["(none)"] self.recentDataFiles = ["(none)"] self.recentEdgesFiles = ["(none)"] self.auto_table = False self.domain = None self.graph = None self.auto_items = None #get settings from the ini file, if they exist self.loadSettings() #GUI self.controlArea.layout().setMargin(4) self.box = OWGUI.widgetBox(self.controlArea, box="Graph File", orientation="vertical") hb = OWGUI.widgetBox(self.box, orientation="horizontal") self.filecombo = OWGUI.comboBox(hb, self, "filename") self.filecombo.setMinimumWidth(250) button = OWGUI.button(hb, self, '...', callback=self.browseNetFile, disabled=0) button.setIcon(self.style().standardIcon(QStyle.SP_DirOpenIcon)) button.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) OWGUI.checkBox( self.box, self, "auto_table", "Build graph data table automatically", callback=lambda: self.selectNetFile(self.filecombo.currentIndex())) self.databox = OWGUI.widgetBox(self.controlArea, box="Vertices Data File", orientation="horizontal") self.datacombo = OWGUI.comboBox(self.databox, self, "dataname") self.datacombo.setMinimumWidth(250) button = OWGUI.button(self.databox, self, '...', callback=self.browseDataFile, disabled=0) button.setIcon(self.style().standardIcon(QStyle.SP_DirOpenIcon)) button.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) self.edgesbox = OWGUI.widgetBox(self.controlArea, box="Edges Data File", orientation="horizontal") self.edgescombo = OWGUI.comboBox(self.edgesbox, self, "edgesname") self.edgescombo.setMinimumWidth(250) button = OWGUI.button(self.edgesbox, self, '...', callback=self.browseEdgesFile, disabled=0) button.setIcon(self.style().standardIcon(QStyle.SP_DirOpenIcon)) button.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) # info box = OWGUI.widgetBox(self.controlArea, "Info") self.infoa = OWGUI.widgetLabel(box, 'No data loaded.') self.infob = OWGUI.widgetLabel(box, ' ') self.infoc = OWGUI.widgetLabel(box, ' ') self.infod = OWGUI.widgetLabel(box, ' ') OWGUI.rubber(self.controlArea) self.resize(150, 100) self.activateLoadedSettings() # connecting GUI to code self.connect(self.filecombo, SIGNAL('activated(int)'), self.selectNetFile) self.connect(self.datacombo, SIGNAL('activated(int)'), self.selectDataFile) self.connect(self.edgescombo, SIGNAL('activated(int)'), self.selectEdgesFile)
def __init__(self, parent=None, signalManager=None, name='kNN'): OWWidget.__init__(self, parent, signalManager, name, wantMainArea=0, resizingEnabled=0) self.callbackDeposit = [] self.inputs = [("Data", ExampleTable, self.setData), ("Preprocess", PreprocessedLearner, self.setPreprocessor)] self.outputs = [("Learner", orange.Learner), ("kNN Classifier", orange.kNNClassifier)] self.metricsList = [ ("Euclidean", orange.ExamplesDistanceConstructor_Euclidean), ("Hamming", orange.ExamplesDistanceConstructor_Hamming), ("Manhattan", orange.ExamplesDistanceConstructor_Manhattan), ("Maximal", orange.ExamplesDistanceConstructor_Maximal), # ("Dynamic time warp", orange.ExamplesDistanceConstructor_DTW) ] # Settings self.name = 'kNN' self.k = 5 self.metrics = 0 self.ranks = 0 self.ignoreUnknowns = 0 self.normalize = self.oldNormalize = 1 self.loadSettings() self.data = None # input data set self.preprocessor = None # no preprocessing as default self.setLearner() # this just sets the learner, no data # has come to the input yet OWGUI.lineEdit(self.controlArea, self, 'name', box='Learner/Classifier Name', \ tooltip='Name to be used by other widgets to identify your learner/classifier.') OWGUI.separator(self.controlArea) wbN = OWGUI.widgetBox(self.controlArea, "Neighbours") OWGUI.spin(wbN, self, "k", 1, 100, 1, None, "Number of neighbours ", orientation="horizontal") OWGUI.checkBox(wbN, self, "ranks", "Weighting by ranks, not distances") OWGUI.separator(self.controlArea) wbM = OWGUI.widgetBox(self.controlArea, "Metrics") OWGUI.comboBox(wbM, self, "metrics", items=[x[0] for x in self.metricsList], valueType=int, callback=self.metricsChanged) self.cbNormalize = OWGUI.checkBox(wbM, self, "normalize", "Normalize continuous attributes") OWGUI.checkBox(wbM, self, "ignoreUnknowns", "Ignore unknown values") self.metricsChanged() OWGUI.separator(self.controlArea) OWGUI.button(self.controlArea, self, "&Apply", callback=self.setLearner, disabled=0, default=True) OWGUI.rubber(self.controlArea) self.resize(100, 250)
def __init__(self, parentWidget = None, signalManager = None, graph = None, parentName = "Visualization widget"): OWWidget.__init__(self, None, signalManager, "FreeViz Dialog", savePosition = True, wantMainArea = 0, wantStatusBar = 1) FreeViz.__init__(self, graph) self.parentWidget = parentWidget self.parentName = parentName self.setCaption("FreeViz Optimization Dialog") self.cancelOptimization = 0 self.forceRelation = 5 self.disableAttractive = 0 self.disableRepulsive = 0 self.touringSpeed = 4 self.graph = graph if self.graph: self.graph.hideRadius = 0 self.graph.showAnchors = 1 # differential evolution self.differentialEvolutionPopSize = 100 self.DERadvizSolver = None self.loadSettings() self.layout().setMargin(0) self.tabs = OWGUI.tabWidget(self.controlArea) self.MainTab = OWGUI.createTabPage(self.tabs, "Main") self.ProjectionsTab = OWGUI.createTabPage(self.tabs, "Projections") # ########################### # MAIN TAB OWGUI.comboBox(self.MainTab, self, "implementation", box = "FreeViz implementation", items = ["Fast (C) implementation", "Slow (Python) implementation", "LDA"]) box = OWGUI.widgetBox(self.MainTab, "Optimization") self.optimizeButton = OWGUI.button(box, self, "Optimize Separation", callback = self.optimizeSeparation) self.stopButton = OWGUI.button(box, self, "Stop Optimization", callback = self.stopOptimization) self.singleStepButton = OWGUI.button(box, self, "Single Step", callback = self.singleStepOptimization) f = self.optimizeButton.font(); f.setBold(1) self.optimizeButton.setFont(f) self.stopButton.setFont(f); self.stopButton.hide() self.attrKNeighboursCombo = OWGUI.comboBoxWithCaption(box, self, "stepsBeforeUpdate", "Number of steps before updating graph: ", tooltip = "Set the number of optimization steps that will be executed before the updated anchor positions will be visualized", items = [1, 3, 5, 10, 15, 20, 30, 50, 75, 100, 150, 200, 300], sendSelectedValue = 1, valueType = int) OWGUI.checkBox(box, self, "mirrorSymmetry", "Keep mirror symmetry", tooltip = "'Rotational' keeps the second anchor upside") vbox = OWGUI.widgetBox(self.MainTab, "Set anchor positions") hbox1 = OWGUI.widgetBox(vbox, orientation = "horizontal") OWGUI.button(hbox1, self, "Sphere" if "3d" in self.parentName.lower() else "Circle", callback = self.radialAnchors) OWGUI.button(hbox1, self, "Random", callback = self.randomAnchors) self.manualPositioningButton = OWGUI.button(hbox1, self, "Manual", callback = self.setManualPosition) self.manualPositioningButton.setCheckable(1) OWGUI.comboBox(vbox, self, "restrain", label="Restrain anchors:", orientation = "horizontal", items = ["Unrestrained", "Fixed Length", "Fixed Angle"], callback = self.setRestraints) box2 = OWGUI.widgetBox(self.MainTab, "Forces", orientation = "vertical") self.cbLaw = OWGUI.comboBox(box2, self, "law", label="Law", labelWidth = 40, orientation="horizontal", items=["Linear", "Square", "Gaussian", "KNN", "Variance"], callback = self.forceLawChanged) hbox2 = OWGUI.widgetBox(box2, orientation = "horizontal") hbox2.layout().addSpacing(10) validSigma = QDoubleValidator(self); validSigma.setBottom(0.01) self.spinSigma = OWGUI.lineEdit(hbox2, self, "forceSigma", label = "Kernel width (sigma) ", labelWidth = 110, orientation = "horizontal", valueType = float) self.spinSigma.setFixedSize(60, self.spinSigma.sizeHint().height()) self.spinSigma.setSizePolicy(QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed)) box2.layout().addSpacing(20) self.cbforcerel = OWGUI.comboBox(box2, self, "forceRelation", label= "Attractive : Repulsive ",orientation = "horizontal", items=self.forceRelValues, callback = self.updateForces) self.cbforcebal = OWGUI.checkBox(box2, self, "forceBalancing", "Dynamic force balancing", tooltip="Normalize the forces so that the total sums of the\nrepulsive and attractive are in the above proportion.") box2.layout().addSpacing(20) self.cbDisableAttractive = OWGUI.checkBox(box2, self, "disableAttractive", "Disable attractive forces", callback = self.setDisableAttractive) self.cbDisableRepulsive = OWGUI.checkBox(box2, self, "disableRepulsive", "Disable repulsive forces", callback = self.setDisableRepulsive) box = OWGUI.widgetBox(self.MainTab, "Show anchors") OWGUI.checkBox(box, self, 'graph.showAnchors', 'Show attribute anchors', callback = self.parentWidget.updateGraph) OWGUI.qwtHSlider(box, self, "graph.hideRadius", label="Hide radius", minValue=0, maxValue=9, step=1, ticks=0, callback = self.parentWidget.updateGraph) self.freeAttributesButton = OWGUI.button(box, self, "Remove hidden attributes", callback = self.removeHidden) if parentName.lower() != "radviz" and parentName.lower() != "sphereviz": pcaBox = OWGUI.widgetBox(self.ProjectionsTab, "Principal Component Analysis") OWGUI.button(pcaBox, self, "Principal component analysis", callback = self.findPCAProjection) OWGUI.button(pcaBox, self, "Supervised principal component analysis", callback = self.findSPCAProjection) OWGUI.checkBox(pcaBox, self, "useGeneralizedEigenvectors", "Merge examples with same class value") plsBox = OWGUI.widgetBox(self.ProjectionsTab, "Partial Least Squares") OWGUI.button(plsBox, self, "Partial least squares", callback = self.findPLSProjection) box = OWGUI.widgetBox(self.ProjectionsTab, "Projection Tours") self.startTourButton = OWGUI.button(box, self, "Start Random Touring", callback = self.startRandomTouring) self.stopTourButton = OWGUI.button(box, self, "Stop Touring", callback = self.stopRandomTouring) self.stopTourButton.hide() OWGUI.hSlider(box, self, 'touringSpeed', label = "Speed: ", minValue=1, maxValue=10, step=1) OWGUI.rubber(self.ProjectionsTab) box = OWGUI.widgetBox(self.ProjectionsTab, "Signal to Noise Heuristic") #OWGUI.comboBoxWithCaption(box, self, "s2nSpread", "Anchor spread: ", tooltip = "Are the anchors for each class value placed together or are they distributed along the circle", items = range(11), callback = self.s2nMixAnchors) box2 = OWGUI.widgetBox(box, 0, orientation = "horizontal") OWGUI.widgetLabel(box2, "Anchor spread: ") OWGUI.hSlider(box2, self, 's2nSpread', minValue=0, maxValue=10, step=1, callback = self.s2nMixAnchors, labelFormat=" %d", ticks=0) OWGUI.comboBoxWithCaption(box, self, "s2nPlaceAttributes", "Attributes to place: ", tooltip = "Set the number of top ranked attributes to place. You can select a higher value than the actual number of attributes", items = self.attrsNum, callback = self.s2nMixAnchors, sendSelectedValue = 1, valueType = int) OWGUI.checkBox(box, self, 'autoSetParameters', 'Automatically find optimal parameters') self.s2nMixButton = OWGUI.button(box, self, "Place anchors", callback = self.s2nMixAnchorsAutoSet) self.forceLawChanged() self.updateForces() self.cbforcebal.setDisabled(self.cbDisableAttractive.isChecked() or self.cbDisableRepulsive.isChecked()) self.resize(320,650)
def __init__(self, visualizationWidget = None, signalManager = None): OWWidget.__init__(self, None, signalManager, "Sieve Evaluation Dialog", savePosition = True, wantMainArea = 0, wantStatusBar = 1) orngMosaic.__init__(self) self.resize(390,620) self.setCaption("Sieve Diagram Evaluation Dialog") # loaded variables self.visualizationWidget = visualizationWidget self.useTimeLimit = 0 self.useProjectionLimit = 0 self.qualityMeasure = CHI_SQUARE # we will always compute only chi square with sieve diagram self.optimizationType = EXACT_NUMBER_OF_ATTRS self.attributeCount = 2 self.attrCondition = None self.attrConditionValue = None self.lastSaveDirName = os.getcwd() self.attrLenDict = {} self.shownResults = [] self.loadSettings() self.layout().setMargin(0) self.tabs = OWGUI.tabWidget(self.controlArea) self.MainTab = OWGUI.createTabPage(self.tabs, "Main") self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings") self.ManageTab = OWGUI.createTabPage(self.tabs, "Manage") # ########################### # MAIN TAB box = OWGUI.widgetBox(self.MainTab, box = "Condition") self.attrConditionCombo = OWGUI.comboBoxWithCaption(box, self, "attrCondition", "Attribute:", callback = self.updateConditionAttr, sendSelectedValue = 1, valueType = str, labelWidth = 70) self.attrConditionValueCombo = OWGUI.comboBoxWithCaption(box, self, "attrConditionValue", "Value:", sendSelectedValue = 1, valueType = str, labelWidth = 70) self.optimizationBox = OWGUI.widgetBox(self.MainTab, "Evaluate") self.buttonBox = OWGUI.widgetBox(self.optimizationBox, orientation = "horizontal") self.resultsBox = OWGUI.widgetBox(self.MainTab, "Projection List Ordered by Chi-Square") # self.label1 = OWGUI.widgetLabel(self.buttonBox, 'Projections with ') # self.optimizationTypeCombo = OWGUI.comboBox(self.buttonBox, self, "optimizationType", items = [" exactly ", " maximum "] ) # self.attributeCountCombo = OWGUI.comboBox(self.buttonBox, self, "attributeCount", items = range(1, 5), tooltip = "Evaluate only projections with exactly (or maximum) this number of attributes", sendSelectedValue = 1, valueType = int) # self.attributeLabel = OWGUI.widgetLabel(self.buttonBox, ' attributes') self.startOptimizationButton = OWGUI.button(self.optimizationBox, self, "Start Evaluating Projections", callback = self.evaluateProjections) f = self.startOptimizationButton.font(); f.setBold(1); self.startOptimizationButton.setFont(f) self.stopOptimizationButton = OWGUI.button(self.optimizationBox, self, "Stop Evaluation", callback = self.stopEvaluationClick) self.stopOptimizationButton.setFont(f) self.stopOptimizationButton.hide() self.resultList = OWGUI.listBox(self.resultsBox, self, callback = self.showSelectedAttributes) self.resultList.setMinimumHeight(200) # ########################## # SETTINGS TAB OWGUI.checkBox(self.SettingsTab, self, "ignoreTooSmallCells", "Ignore cells where expected number of cases is less than 5", box = "Ignore small cells", tooltip = "Statisticians advise that in cases when the number of expected examples is less than 5 we ignore the cell \nsince it can significantly influence the chi-square value.") OWGUI.comboBoxWithCaption(self.SettingsTab, self, "percentDataUsed", "Percent of data used: ", box = "Data settings", items = self.percentDataNums, sendSelectedValue = 1, valueType = int, tooltip = "In case that we have a large dataset the evaluation of each projection can take a lot of time.\nWe can therefore use only a subset of randomly selected examples, evaluate projection on them and thus make evaluation faster.") self.stopOptimizationBox = OWGUI.widgetBox(self.SettingsTab, "When to Stop Evaluation or Optimization?") OWGUI.checkWithSpin(self.stopOptimizationBox, self, "Time limit: ", 1, 1000, "useTimeLimit", "timeLimit", " (minutes)", debuggingEnabled = 0) # disable debugging. we always set this to 1 minute OWGUI.checkWithSpin(self.stopOptimizationBox, self, "Use projection count limit: ", 1, 1000000, "useProjectionLimit", "projectionLimit", " (projections)", debuggingEnabled = 0) OWGUI.rubber(self.SettingsTab) # ########################## # SAVE TAB # self.visualizedAttributesBox = OWGUI.widgetBox(self.ManageTab, "Number of Concurrently Visualized Attributes") self.dialogsBox = OWGUI.widgetBox(self.ManageTab, "Dialogs") self.manageResultsBox = OWGUI.widgetBox(self.ManageTab, "Manage projections") # self.attrLenList = OWGUI.listBox(self.visualizedAttributesBox, self, selectionMode = QListWidget.MultiSelection, callback = self.attrLenListChanged) # self.attrLenList.setMinimumHeight(60) self.buttonBox7 = OWGUI.widgetBox(self.dialogsBox, orientation = "horizontal") OWGUI.button(self.buttonBox7, self, "Attribute Ranking", self.attributeAnalysis, debuggingEnabled = 0) OWGUI.button(self.buttonBox7, self, "Graph Projection Scores", self.graphProjectionQuality, debuggingEnabled = 0) hbox = OWGUI.widgetBox(self.manageResultsBox, orientation = "horizontal") OWGUI.button(hbox, self, "Load", self.load, debuggingEnabled = 0) OWGUI.button(hbox, self, "Save", self.save, debuggingEnabled = 0) hbox = OWGUI.widgetBox(self.manageResultsBox, orientation = "horizontal") OWGUI.button(hbox, self, "Clear results", self.clearResults) OWGUI.rubber(self.ManageTab) # reset some parameters if we are debugging so that it won't take too much time if orngDebugging.orngDebuggingEnabled: self.useTimeLimit = 1 self.timeLimit = 0.3 self.useProjectionLimit = 1 self.projectionLimit = 100 self.icons = self.createAttributeIconDict()
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "Nomogram", 1) #self.setWFlags(Qt.WResizeNoErase | Qt.WRepaintNoErase) #this works like magic.. no flicker during repaint! self.parent = parent # self.setWFlags(self.getWFlags()+Qt.WStyle_Maximize) self.callbackDeposit = [] # deposit for OWGUI callback functions self.alignType = 0 self.contType = 0 self.yAxis = 0 self.probability = 0 self.verticalSpacing = 60 self.verticalSpacingContinuous = 100 self.diff_between_ordinal = 30 self.fontSize = 9 self.lineWidth = 1 self.histogram = 0 self.histogram_size = 10 self.data = None self.cl = None self.confidence_check = 0 self.confidence_percent = 95 self.sort_type = 0 self.loadSettings() self.pointsName = ["Total", "Total"] self.totalPointsName = ["Probability", "Probability"] self.bnomogram = None self.inputs = [("Classifier", orange.Classifier, self.classifier)] self.TargetClassIndex = 0 self.targetCombo = OWGUI.comboBox( self.controlArea, self, "TargetClassIndex", " Target Class ", addSpace=True, tooltip='Select target (prediction) class in the model.', callback=self.setTarget) self.alignRadio = OWGUI.radioButtonsInBox( self.controlArea, self, 'alignType', ['Align left', 'Align by zero influence'], box='Attribute placement', tooltips=[ 'Attributes in nomogram are left aligned', 'Attributes are not aligned, top scale represents true (normalized) regression coefficient value' ], addSpace=True, callback=self.showNomogram) self.verticalSpacingLabel = OWGUI.spin( self.alignRadio, self, 'verticalSpacing', 15, 200, label='Vertical spacing:', orientation=0, tooltip='Define space (pixels) between adjacent attributes.', callback=self.showNomogram) self.ContRadio = OWGUI.radioButtonsInBox( self.controlArea, self, 'contType', ['1D projection', '2D curve'], 'Continuous attributes', tooltips=[ 'Continuous attribute are presented on a single scale', 'Two dimensional space is used to present continuous attributes in nomogram.' ], addSpace=True, callback=[ lambda: self.verticalSpacingContLabel.setDisabled( not self.contType), self.showNomogram ]) self.verticalSpacingContLabel = OWGUI.spin( OWGUI.indentedBox(self.ContRadio, sep=OWGUI.checkButtonOffsetHint( self.ContRadio.buttons[-1])), self, 'verticalSpacingContinuous', 15, 200, label="Height", orientation=0, tooltip= 'Define space (pixels) between adjacent 2d presentation of attributes.', callback=self.showNomogram) self.verticalSpacingContLabel.setDisabled(not self.contType) self.yAxisRadio = OWGUI.radioButtonsInBox( self.controlArea, self, 'yAxis', ['Point scale', 'Log odds ratios'], 'Scale', tooltips=[ 'values are normalized on a 0-100 point scale', 'values on top axis show log-linear contribution of attribute to full model' ], addSpace=True, callback=self.showNomogram) layoutBox = OWGUI.widgetBox(self.controlArea, "Display", orientation=1, addSpace=True) self.probabilityCheck = OWGUI.checkBox(layoutBox, self, 'probability', 'Show prediction', tooltip='', callback=self.setProbability) self.CICheck, self.CILabel = OWGUI.checkWithSpin( layoutBox, self, 'Confidence intervals (%):', min=1, max=99, step=1, checked='confidence_check', value='confidence_percent', checkCallback=self.showNomogram, spinCallback=self.showNomogram) self.histogramCheck, self.histogramLabel = OWGUI.checkWithSpin( layoutBox, self, 'Show histogram, size', min=1, max=30, checked='histogram', value='histogram_size', step=1, tooltip='-(TODO)-', checkCallback=self.showNomogram, spinCallback=self.showNomogram) OWGUI.separator(layoutBox) self.sortOptions = [ "No sorting", "Absolute importance", "Positive influence", "Negative influence" ] self.sortBox = OWGUI.comboBox(layoutBox, self, "sort_type", label="Sort by ", items=self.sortOptions, callback=self.sortNomogram, orientation="horizontal") OWGUI.rubber(self.controlArea) self.connect(self.graphButton, SIGNAL("clicked()"), self.menuItemPrinter) #add a graph widget self.header = OWNomogramHeader(None, self.mainArea) self.header.setFixedHeight(60) self.header.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.header.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.graph = OWNomogramGraph(self.bnomogram, self.mainArea) self.graph.setMinimumWidth(200) self.graph.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.footer = OWNomogramHeader(None, self.mainArea) self.footer.setFixedHeight(60 * 2 + 10) self.footer.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.footer.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.mainArea.layout().addWidget(self.header) self.mainArea.layout().addWidget(self.graph) self.mainArea.layout().addWidget(self.footer) self.resize(700, 500) #self.repaint() #self.update() # mouse pressed flag self.mousepr = False
def __init__(self, parent=None, signalManager=None, name='Classification Tree Viewer'): OWWidget.__init__(self, parent, signalManager, name) self.dataLabels = (('Majority class', 'Class'), ('Probability of majority class', 'P(Class)'), ('Probability of target class', 'P(Target)'), ('Number of instances', '# Inst'), ('Relative distribution', 'Distribution (rel)'), ('Absolute distribution', 'Distribution (abs)')) # self.callbackDeposit = [] self.inputs = [("Classification Tree", orange.TreeClassifier, self.setClassificationTree)] self.outputs = [("Examples", ExampleTable)] # Settings for s in self.settingsList[:6]: setattr(self, s, 1) self.expslider = 5 self.targetClass = 0 self.loadSettings() self.tree = None self.sliderValue = 5 self.precision = 3 self.precFrmt = "%%2.%if" % self.precision # GUI # parameters self.dBox = OWGUI.widgetBox(self.controlArea, 'Displayed information') for i in range(len(self.dataLabels)): checkColumn(self.dBox, self, self.dataLabels[i][0], self.settingsList[i]) OWGUI.separator(self.controlArea) self.slider = OWGUI.hSlider(self.controlArea, self, "sliderValue", box='Expand/shrink to level', minValue=1, maxValue=9, step=1, callback=self.sliderChanged) OWGUI.separator(self.controlArea) self.targetCombo = OWGUI.comboBox(self.controlArea, self, "targetClass", items=[], box="Target class", callback=self.setTarget) self.infBox = OWGUI.widgetBox(self.controlArea, 'Tree size') self.infoa = OWGUI.widgetLabel(self.infBox, 'No tree.') self.infob = OWGUI.widgetLabel(self.infBox, ' ') OWGUI.rubber(self.controlArea) # list view self.splitter = QSplitter(Qt.Vertical, self.mainArea) self.mainArea.layout().addWidget(self.splitter) self.v = QTreeWidget(self.splitter) self.splitter.addWidget(self.v) self.v.setAllColumnsShowFocus(1) self.v.setHeaderLabels(['Classification Tree'] + [label[1] for label in self.dataLabels]) self.v.setColumnWidth(0, 250) self.connect(self.v, SIGNAL("itemSelectionChanged()"), self.viewSelectionChanged) # rule self.rule = QTextEdit(self.splitter) self.splitter.addWidget(self.rule) self.rule.setReadOnly(1) self.splitter.setStretchFactor(0, 2) self.splitter.setStretchFactor(1, 1) self.resize(800, 400) self.resize(830, 400)
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) self.inputs = [("Data", Orange.data.Table, self.set_data)] self.outputs = [("Sampled Data", Orange.data.Table)] # [start-snippet-2] self.proportion = 50 self.commitOnChange = 0 self.loadSettings() # [end-snippet-2] # GUI # [start-snippet-3] box = OWGUI.widgetBox(self.controlArea, "Info") self.infoa = OWGUI.widgetLabel( box, 'No data on input yet, waiting to get something.') self.infob = OWGUI.widgetLabel(box, '') OWGUI.separator(self.controlArea) self.optionsBox = OWGUI.widgetBox(self.controlArea, "Options") OWGUI.spin(self.optionsBox, self, 'proportion', min=10, max=90, step=10, label='Sample Size [%]:', callback=[self.selection, self.checkCommit]) OWGUI.checkBox(self.optionsBox, self, 'commitOnChange', 'Commit data on selection change') OWGUI.button(self.optionsBox, self, "Commit", callback=self.commit) self.optionsBox.setDisabled(1) # [end-snippet-3] self.resize(100, 50)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "Scatter Plot", TRUE) self.inputs = [("Data", ExampleTable, self.setData, Default), ("Data Subset", ExampleTable, self.setSubsetData), ("Features", AttributeList, self.setShownAttributes), ("Evaluation Results", orngTest.ExperimentResults, self.setTestResults), ("VizRank Learner", orange.Learner, self.setVizRankLearner)] self.outputs = [("Selected Data", ExampleTable), ("Other Data", ExampleTable)] self.graph = OWScatterPlotGraph(self, self.mainArea, "ScatterPlot") self.graph.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) self.graph.setMinimumSize(250, 200) self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) self.vizrank = OWVizRank(self, self.signalManager, self.graph, orngVizRank.SCATTERPLOT, "ScatterPlot") self.optimizationDlg = self.vizrank # local variables self.showGridlines = 0 self.autoSendSelection = 1 self.toolbarSelection = 0 self.classificationResults = None self.outlierValues = None self.colorSettings = None self.selectedSchemaIndex = 0 self.graph.sendSelectionOnUpdate = 0 self.attributeSelectionList = None self.data = None self.subsetData = None #load settings self.loadSettings() #GUI self.tabs = OWGUI.tabWidget(self.controlArea) self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main") self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings", canScroll=True) #add a graph widget self.mainArea.layout().addWidget(self.graph) self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile) #x attribute self.attrX = "" self.attrXCombo = OWGUI.comboBox(self.GeneralTab, self, "attrX", "X-axis Attribute", callback=self.majorUpdateGraph, sendSelectedValue=1, valueType=str) # y attribute self.attrY = "" self.attrYCombo = OWGUI.comboBox(self.GeneralTab, self, "attrY", "Y-axis Attribute", callback=self.majorUpdateGraph, sendSelectedValue=1, valueType=str) # coloring self.attrColor = "" box = OWGUI.widgetBox(self.GeneralTab, "Point Color") self.attrColorCombo = OWGUI.comboBox(box, self, "attrColor", callback=self.updateGraph, sendSelectedValue=1, valueType=str, emptyString="(Same color)") box = OWGUI.widgetBox(self.GeneralTab, "Additional Point Properties") # labelling self.attrLabel = "" self.attrLabelCombo = OWGUI.comboBox(box, self, "attrLabel", label="Point label:", callback=self.updateGraph, sendSelectedValue=1, valueType=str, emptyString="(No labels)", indent=10) # shaping self.attrShape = "" self.attrShapeCombo = OWGUI.comboBox(box, self, "attrShape", label="Point shape:", callback=self.updateGraph, sendSelectedValue=1, valueType=str, emptyString="(Same shape)", indent=10) # sizing self.attrSize = "" self.attrSizeCombo = OWGUI.comboBox(box, self, "attrSize", label="Point size:", callback=self.updateGraph, sendSelectedValue=1, valueType=str, emptyString="(Same size)", indent=10) self.optimizationButtons = OWGUI.widgetBox(self.GeneralTab, "Optimization dialogs", orientation="horizontal") OWGUI.button( self.optimizationButtons, self, "VizRank", callback=self.vizrank.reshow, tooltip= "Opens VizRank dialog, where you can search for interesting projections with different subsets of attributes", debuggingEnabled=0) # zooming / selection self.zoomSelectToolbar = OWToolbars.ZoomSelectToolbar( self, self.GeneralTab, self.graph, self.autoSendSelection) self.connect(self.zoomSelectToolbar.buttonSendSelections, SIGNAL("clicked()"), self.sendSelections) # #################################### # SETTINGS TAB # point width pointBox = OWGUI.widgetBox(self.SettingsTab, "Point Properties") OWGUI.hSlider(pointBox, self, 'graph.pointWidth', label="Symbol size: ", minValue=1, maxValue=20, step=1, callback=self.pointSizeChange) OWGUI.hSlider(pointBox, self, 'graph.alphaValue', label="Transparency: ", minValue=0, maxValue=255, step=10, callback=self.alphaChange) # ##### # jittering options box2 = OWGUI.widgetBox(self.SettingsTab, "Jittering Options") self.jitterSizeCombo = OWGUI.comboBox( box2, self, "graph.jitterSize", label='Jittering size (% of size)' + ' ', orientation="horizontal", callback=self.resetGraphData, items=self.jitterSizeNums, sendSelectedValue=1, valueType=float) OWGUI.checkBox( box2, self, 'graph.jitterContinuous', 'Jitter continuous attributes', callback=self.resetGraphData, tooltip="Does jittering apply also on continuous attributes?") # general graph settings box4 = OWGUI.widgetBox(self.SettingsTab, "General Graph Settings") OWGUI.checkBox(box4, self, 'graph.showXaxisTitle', 'X axis title', callback=self.graph.setShowXaxisTitle) OWGUI.checkBox(box4, self, 'graph.showYLaxisTitle', 'Y axis title', callback=self.graph.setShowYLaxisTitle) OWGUI.checkBox(box4, self, 'graph.showAxisScale', 'Show axis scale', callback=self.updateGraph) OWGUI.checkBox(box4, self, 'graph.showLegend', 'Show legend', callback=self.updateGraph) OWGUI.checkBox(box4, self, 'graph.showFilledSymbols', 'Show filled symbols', callback=self.updateGraph) OWGUI.checkBox(box4, self, 'showGridlines', 'Show gridlines', callback=self.setShowGridlines) OWGUI.checkBox(box4, self, 'graph.useAntialiasing', 'Use antialiasing', callback=self.updateGraph) box5 = OWGUI.widgetBox(box4, orientation="horizontal") OWGUI.checkBox( box5, self, 'graph.showProbabilities', 'Show probabilities' + ' ', callback=self.updateGraph, tooltip="Show a background image with class probabilities") smallWidget = OWGUI.SmallWidgetLabel(box5, pixmap=1, box="Advanced settings", tooltip="Show advanced settings") #OWGUI.rubber(box5) box6 = OWGUI.widgetBox(smallWidget.widget, orientation="horizontal") box7 = OWGUI.widgetBox(smallWidget.widget, orientation="horizontal") OWGUI.widgetLabel(box6, "Granularity:" + " ") OWGUI.hSlider(box6, self, 'graph.squareGranularity', minValue=1, maxValue=10, step=1, callback=self.updateGraph) OWGUI.checkBox(box7, self, 'graph.spaceBetweenCells', 'Show space between cells', callback=self.updateGraph) self.colorButtonsBox = OWGUI.widgetBox(self.SettingsTab, "Colors", orientation="horizontal") OWGUI.button( self.colorButtonsBox, self, "Set Colors", self.setColors, tooltip= "Set the canvas background color, grid color and color palette for coloring continuous variables", debuggingEnabled=0) box5 = OWGUI.widgetBox(self.SettingsTab, "Tooltips Settings") OWGUI.comboBox(box5, self, "graph.tooltipKind", items=[ "Don't Show Tooltips", "Show Visible Attributes", "Show All Attributes" ], callback=self.updateGraph) box = OWGUI.widgetBox(self.SettingsTab, "Auto Send Selected Data When...") OWGUI.checkBox( box, self, 'autoSendSelection', 'Adding/Removing selection areas', callback=self.selectionChanged, tooltip= "Send selected data whenever a selection area is added or removed") OWGUI.checkBox( box, self, 'graph.sendSelectionOnUpdate', 'Moving/Resizing selection areas', tooltip= "Send selected data when a user moves or resizes an existing selection area" ) self.graph.autoSendSelectionCallback = self.selectionChanged self.GeneralTab.layout().addStretch(100) self.SettingsTab.layout().addStretch(100) self.icons = self.createAttributeIconDict() self.debugSettings = [ "attrX", "attrY", "attrColor", "attrLabel", "attrShape", "attrSize" ] self.wdChildDialogs = [self.vizrank ] # used when running widget debugging dlg = self.createColorDialog() self.graph.contPalette = dlg.getContinuousPalette("contPalette") self.graph.discPalette = dlg.getDiscretePalette("discPalette") self.graph.setCanvasBackground(dlg.getColor("Canvas")) self.graph.gridCurve.setPen(QPen(dlg.getColor("Grid"))) self.graph.enableGridXB(self.showGridlines) self.graph.enableGridYL(self.showGridlines) apply([ self.zoomSelectToolbar.actionZooming, self.zoomSelectToolbar.actionRectangleSelection, self.zoomSelectToolbar.actionPolygonSelection ][self.toolbarSelection], []) #self.SettingsTab.resize(self.SettingsTab.sizeHint()) self.resize(700, 550)
def __init__(self, parent=None, signalManager=None, name="Logistic regression"): OWWidget.__init__(self, parent, signalManager, name, wantMainArea=0, resizingEnabled=0) self.inputs = [("Examples", ExampleTable, self.setData), ("Preprocess", PreprocessedLearner, self.setPreprocessor)] self.outputs = [("Learner", orange.Learner), ("Classifier", orange.Classifier), ("Attributes", list)] from orngTree import TreeLearner imputeByModel = orange.ImputerConstructor_model() imputeByModel.learnerDiscrete = TreeLearner(measure="infoGain", minSubset=50) imputeByModel.learnerContinuous = TreeLearner(measure="retis", minSubset=50) self.imputationMethods = [ imputeByModel, orange.ImputerConstructor_average(), orange.ImputerConstructor_minimal(), orange.ImputerConstructor_maximal(), None ] self.imputationMethodsStr = [ "Classification/Regression trees", "Average values", "Minimal value", "Maximal value", "None (skip examples)" ] self.name = "Logistic regression" self.univariate = 0 self.stepwiseLR = 0 self.addCrit = 10 self.removeCrit = 10 self.numAttr = 10 self.limitNumAttr = False self.zeroPoint = 0 self.imputation = 1 self.data = None self.preprocessor = None self.loadSettings() OWGUI.lineEdit( self.controlArea, self, 'name', box='Learner/Classifier Name', tooltip= 'Name to be used by other widgets to identify your learner/classifier.' ) OWGUI.separator(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Attribute selection") stepwiseCb = OWGUI.checkBox(box, self, "stepwiseLR", "Stepwise attribute selection") ibox = OWGUI.indentedBox(box, sep=OWGUI.checkButtonOffsetHint(stepwiseCb)) addCritSpin = OWGUI.spin( ibox, self, "addCrit", 1, 50, label="Add threshold [%]", labelWidth=155, tooltip="Requested significance for adding an attribute") remCritSpin = OWGUI.spin( ibox, self, "removeCrit", 1, 50, label="Remove threshold [%]", labelWidth=155, tooltip="Requested significance for removing an attribute") limitAttSpin = OWGUI.checkWithSpin( ibox, self, "Limit number of attributes to ", 1, 100, "limitNumAttr", "numAttr", step=1, labelWidth=155, tooltip= "Maximum number of attributes. Algorithm stops when it selects specified number of attributes." ) stepwiseCb.disables += [addCritSpin, remCritSpin, limitAttSpin] stepwiseCb.makeConsistent() OWGUI.separator(self.controlArea) self.imputationCombo = OWGUI.comboBox( self.controlArea, self, "imputation", box="Imputation of unknown values", items=self.imputationMethodsStr) OWGUI.separator(self.controlArea) applyButton = OWGUI.button(self.controlArea, self, "&Apply", callback=self.applyLearner) OWGUI.rubber(self.controlArea) #self.adjustSize() self.applyLearner()
def sendData(self): """Compute result of widget processing and send to output""" # Skip if title list is empty: if self.titleLabels == list(): return # Check that something has been selected... if len(self.selectedTitles) == 0: self.infoBox.setText(u'Please select one or more titles.', 'warning') self.send(u'Text data', None, self) return # Clear created Inputs. self.clearCreatedInputs() # Initialize progress bar. progressBar = OWGUI.ProgressBar(self, iterations=len(self.selectedTitles)) # Attempt to connect to Theatre-classique and retrieve plays... xml_contents = list() annotations = list() try: for title in self.selectedTitles: response = urllib2.urlopen( self.document_base_url + self.filteredTitleSeg[title].annotations[u'url']) xml_contents.append(unicode(response.read(), u'utf8')) annotations.append( self.filteredTitleSeg[title].annotations.copy()) progressBar.advance() # 1 tick on the progress bar... # If an error occurs (e.g. http error, or memory error)... except: # Set Info box and widget to 'error' state. self.infoBox.setText( u"Couldn't download data from theatre-classique website.", 'error') # Reset output channel. self.send(u'Text data', None, self) return # Store downloaded XML in input objects... for xml_content_idx in xrange(len(xml_contents)): newInput = Input(xml_contents[xml_content_idx], self.captionTitle) self.createdInputs.append(newInput) # If there's only one play, the widget's output is the created Input. if len(self.createdInputs) == 1: self.segmentation = self.createdInputs[0] # Otherwise the widget's output is a concatenation... else: self.segmentation = Segmenter.concatenate( self.createdInputs, self.captionTitle, import_labels_as=None, ) # Annotate segments... for idx, segment in enumerate(self.segmentation): segment.annotations.update(annotations[idx]) self.segmentation[idx] = segment # Store imported URLs as setting. self.importedURLs = [ self.filteredTitleSeg[self.selectedTitles[0]].annotations[u'url'] ] # Set status to OK and report data size... message = u'%i segment@p sent to output ' % len(self.segmentation) message = pluralize(message, len(self.segmentation)) numChars = 0 for segment in self.segmentation: segmentLength = len(Segmentation.get_data(segment.str_index)) numChars += segmentLength message += u'(%i character@p).' % numChars message = pluralize(message, numChars) self.infoBox.setText(message) progressBar.finish() # Clear progress bar. progressBar.finish() # Send token... self.send(u'Text data', self.segmentation, self) self.sendButton.resetSettingsChangedFlag()
def __init__(self, graph, extraButtons=[], defaultName="graph", parent=None, saveMatplotlib=None): OWBaseWidget.__init__(self, parent, None, "Image settings", modal=TRUE, resizingEnabled=0) self.graph = graph self.selectedSize = 0 self.customX = 400 self.customY = 400 self.saveAllSizes = 0 self.penWidthFactor = 1 self.lastSaveDirName = "./" self.defaultName = defaultName self.loadSettings() self.setLayout(QVBoxLayout(self)) self.space = OWGUI.widgetBox(self) self.layout().setMargin(8) #self.layout().addWidget(self.space) box = OWGUI.widgetBox(self.space, "Image Size") global _have_qwt if _have_qwt and isinstance(graph, QwtPlot): size = OWGUI.radioButtonsInBox( box, self, "selectedSize", [ "Current size", "400 x 400", "600 x 600", "800 x 800", "Custom:" ], callback=self.updateGUI) self.customXEdit = OWGUI.lineEdit(OWGUI.indentedBox(box), self, "customX", "Width: ", orientation="horizontal", valueType=int) self.customYEdit = OWGUI.lineEdit(OWGUI.indentedBox(box), self, "customY", "Height:", orientation="horizontal", valueType=int) OWGUI.comboBoxWithCaption( self.space, self, "penWidthFactor", label='Factor: ', box=" Pen width multiplication factor ", tooltip= "Set the pen width factor for all curves in the plot\n(Useful for example when the lines in the plot look to thin)\nDefault: 1", sendSelectedValue=1, valueType=int, items=range(1, 20)) elif isinstance(graph, QGraphicsScene) or isinstance( graph, QGraphicsView) or (_have_gl and isinstance(graph, QGLWidget)): OWGUI.widgetLabel(box, "Image size will be set automatically.") box = OWGUI.widgetBox(self.space, 1) #self.printButton = OWGUI.button(self.space, self, "Print", callback = self.printPic) self.saveImageButton = OWGUI.button(box, self, "Save Image", callback=self.saveImage) # If None we try to determine if save can succeed automatically if saveMatplotlib is None: saveMatplotlib = self.canSaveToMatplotlib(graph) if saveMatplotlib and not (_have_gl and isinstance(graph, QGLWidget)): self.saveMatplotlibButton = OWGUI.button( box, self, "Save Graph as matplotlib Script", callback=self.saveToMatplotlib) for (text, funct) in extraButtons: butt = OWGUI.button(box, self, text, callback=funct) self.connect( butt, SIGNAL("clicked()"), self.accept ) # also connect the button to accept so that we close the dialog OWGUI.button(box, self, "Cancel", callback=self.reject) self.resize(250, 300) self.updateGUI()
def __init__(self, parent=None, signalManager = None, name='ML-kNN'): OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0, resizingEnabled = 0) self.callbackDeposit = [] self.inputs = [("Examples", ExampleTable, self.set_data), ("Preprocess", PreprocessedLearner, self.set_preprocessor) ] self.outputs = [("Learner", orange.Learner),("ML-kNN Classifier", Orange.multilabel.MLkNNClassifier)] # Settings self.name = 'ML-kNN' self.k = 1 self.smooth = 1.0 self.loadSettings() self.data = None # input data set self.preprocessor = None # no preprocessing as default self.set_learner() # this just sets the learner, no data # has come to the input yet OWGUI.lineEdit(self.controlArea, self, 'name', box='Learner/Classifier Name', \ tooltip='Name to be used by other widgets to identify your learner/classifier.') OWGUI.separator(self.controlArea) wbN = OWGUI.widgetBox(self.controlArea, "Neighbours") OWGUI.spin(wbN, self, "k", 1, 100, 1, None, "Number of neighbours", orientation="horizontal") OWGUI.separator(self.controlArea) OWGUI.widgetLabel(self.controlArea, 'Smoothing parameter') kernelSizeValid = QDoubleValidator(self.controlArea) kernelSizeValid.setRange(0,10,3) OWGUI.lineEdit(self.controlArea, self, 'smooth', tooltip='Smoothing parameter controlling the strength of uniform prior (Default value is set to 1 which yields the Laplace smoothing).', valueType = float, validator = kernelSizeValid) OWGUI.separator(self.controlArea) OWGUI.button(self.controlArea, self, "&Apply", callback=self.set_learner, disabled=0, default=True) OWGUI.rubber(self.controlArea) self.resize(100,250)
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="CSV File Import"): OWWidget.__init__(self, parent, signalManager, title, wantMainArea=False) self.inputs = [] self.outputs = [("Data", Orange.data.Table)] # Settings self.delimiter = "," self.other_delimiter = None self.quote = '"' self.missing = "" self.skipinitialspace = True self.has_header = True self.has_orange_header = True # List of recent opened files. self.recent_files = [] # Hints for the recent files self.hints = {} self.loadSettings() self.recent_files = filter(os.path.exists, self.recent_files) self.hints = dict([item for item in self.hints.items() \ if item[0] in self.recent_files]) layout = QHBoxLayout() box = OWGUI.widgetBox(self.controlArea, "File", orientation=layout) icons = standard_icons(self) self.recent_combo = QComboBox(self, objectName="recent_combo", toolTip="Recent files.", activated=self.on_select_recent) self.recent_combo.addItems([os.path.basename(p) \ for p in self.recent_files]) self.browse_button = QPushButton("...", icon=icons.dir_open_icon, toolTip="Browse filesystem", clicked=self.on_open_dialog) self.reload_button = QPushButton("Reload", icon=icons.reload_icon, toolTip="Reload the selected file", clicked=self.on_reload_file) layout.addWidget(self.recent_combo, 2) layout.addWidget(self.browse_button) layout.addWidget(self.reload_button) ################# # Cell separators ################# grid_layout = QGridLayout() grid_layout.setVerticalSpacing(4) grid_layout.setHorizontalSpacing(4) box = OWGUI.widgetBox(self.controlArea, "Cell Separator", orientation=grid_layout) button_group = QButtonGroup(box) QObject.connect(button_group, SIGNAL("buttonPressed(int)"), self.delimiter_changed ) for i, (name, char) in enumerate(self.DELIMITERS[:-1]): button = QRadioButton(name, box, toolTip="Use %r as cell separator" % char) button_group.addButton(button, i) grid_layout.addWidget(button, i / 3, i % 3) button = QRadioButton("Other", box, toolTip="Use other character") button_group.addButton(button, i + 1) grid_layout.addWidget(button, i / 3 + 1, 0) self.delimiter_button_group = button_group self.delimiter_edit = \ QLineEdit(objectName="delimiter_edit", text=self.other_delimiter or self.delimiter, editingFinished=self.delimiter_changed, toolTip="Cell delimiter character.") grid_layout.addWidget(self.delimiter_edit, i / 3 + 1, 1, -1, -1) preset = [d[1] for d in self.DELIMITERS[:-1]] if self.delimiter in preset: index = preset.index(self.delimiter) b = button_group.button(index) b.setChecked(True) self.delimiter_edit.setEnabled(False) else: button.setChecked(True) self.delimiter_edit.setEnabled(True) ############### # Other options ############### form = QFormLayout() box = OWGUI.widgetBox(self.controlArea, "Other Options", orientation=form) self.quote_edit = QLineEdit(objectName="quote_edit", text=self.quote, editingFinished=self.quote_changed, toolTip="Text quote character.") form.addRow("Quote", self.quote_edit) self.missing_edit = \ QLineEdit(objectName="missing_edit", text=self.missing, editingFinished=self.missing_changed, toolTip="Missing value flags (separated by a comma)." ) form.addRow("Missing values", self.missing_edit) self.skipinitialspace_check = \ QCheckBox(objectName="skipinitialspace_check", checked=self.skipinitialspace, text="Skip initial whitespace", toolTip="Skip any whitespace at the beginning of each cell.", clicked=self.skipinitialspace_changed ) form.addRow(self.skipinitialspace_check) self.has_header_check = \ QCheckBox(objectName="has_header_check", checked=self.has_header, text="Header line", toolTip="Use the first line as a header", clicked=self.has_header_changed ) form.addRow(self.has_header_check) self.has_orange_header_check = \ QCheckBox(objectName="has_orange_header_check", checked=self.has_orange_header, text="Has orange variable type definitions", toolTip="Use second and third line as a orange style" "'.tab' format feature definitions.", clicked=self.has_orange_header_changed ) form.addRow(self.has_orange_header_check) box = OWGUI.widgetBox(self.controlArea, "Preview") self.preview_view = QTableView() box.layout().addWidget(self.preview_view) OWGUI.button(self.controlArea, self, "Send", callback=self.send_data) self.selected_file = None self.data = None self.resize(450, 500) if self.recent_files: QTimer.singleShot(1, lambda: self.set_selected_file(self.recent_files[0]) )
def __init__(self, parent=None, signalManager=None, name='sift'): OWWidget.__init__(self, parent, signalManager, name, wantMainArea=0) self.callbackDeposit = [] self.inputs = [("Images PIL", Images, self.setData)] self.outputs = [("Descriptors", Descriptors)] # Settings self.name = name self.sift = None self.useLazyEvaluation = pynopticon.useLazyEvaluation self.Octave = 6 self.Levels = 3 self.FirstOctave = 0 self.PeakThresh = 0 self.EdgeThresh = 10 self.NormThresh = 0 self.Orientations = 0 self.loadSettings() self.data = None # input data set wbN = OWGUI.widgetBox(self.controlArea, "Sift Settings") OWGUI.spin(wbN, self, "Octave", -1, 8, 1, None, "Octaves ", orientation="horizontal") OWGUI.spin(wbN, self, "Levels", 1, 8, 1, None, "Levels ", orientation="horizontal") OWGUI.spin(wbN, self, "FirstOctave", 0, 8, 1, None, "First Octave ", orientation="horizontal") OWGUI.spin(wbN, self, "PeakThresh", -1, 8, 1, None, "PeakThresh", orientation="horizontal") OWGUI.spin(wbN, self, "EdgeThresh", -1, 8, 1, None, "EdgeThresh", orientation="horizontal") OWGUI.spin(wbN, self, "NormThresh", -1, 8, 1, None, "NormThresh", orientation="horizontal") OWGUI.spin(wbN, self, "Orientations", 0, 1, 1, None, "Force computation of orientations", orientation="horizontal") wbS = OWGUI.widgetBox(self.controlArea, "Widget Settings") OWGUI.checkBox(wbS, self, "useLazyEvaluation", "Use lazy evaluation") OWGUI.separator(self.controlArea) OWGUI.button(self.controlArea, self, "&Apply Settings", callback=self.applySettings, disabled=0) self.resize(100, 250)
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='Outlier'): OWWidget.__init__(self, parent, signalManager, name) self.inputs = [("Examples", ExampleTable, self.cdata), ("Distance matrix", orange.SymMatrix, self.cdistance)] self.outputs = [("Outliers", ExampleTable), ("Examples with Z-scores", ExampleTable)] # Settings self.name = 'Outlier detection' # name of the classifier/learner self.zscore = '4.0' self.haveInput = 0 self.data = None # input data set self.dataInput = None self.distanceMatrix = None self.loadSettings() kernelSizeValid = QDoubleValidator(self.controlArea) self.metric = 0 self.metrics = [ ("Euclidean", orange.ExamplesDistanceConstructor_Euclidean), ("Manhattan", orange.ExamplesDistanceConstructor_Manhattan), ("Hamming", orange.ExamplesDistanceConstructor_Hamming), ("Relief", orange.ExamplesDistanceConstructor_Relief) ] self.k = 0 self.ks = [("All", 0), ("1", 1), ("2", 2), ("3", 3), ("5", 5), ("10", 10), ("15", 15)] items = [x[0] for x in self.metrics] itemsk = [x[0] for x in self.ks] OWGUI.comboBox( self.controlArea, self, "metric", box="Distance Metrics", items=items, tooltip= "Choose metrics to measure pairwise distance between examples.", callback=self.dataChange) OWGUI.comboBox( self.controlArea, self, "k", box="Nearest Neighbours", items=itemsk, tooltip= "Choose how many neighbours are considered when analysing data.", callback=self.applySettings) box = QVGroupBox(self.controlArea) box.setTitle('Settings') OWGUI.lineEdit(box, self, 'zscore', label='Outlier Z:', orientation='horizontal', box=None, tooltip='Minimum Z score of an outlier', callback=None, valueType=str, validator=kernelSizeValid) OWGUI.separator(self.controlArea) self.applyBtn = OWGUI.button(box, self, "&Apply", callback=self.applySettings) self.resize(100, 100) self.applySettings()
def __init__(self,parent=None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "Sieve diagram", TRUE) #self.controlArea.setMinimumWidth(250) self.inputs = [("Examples", ExampleTable, self.setData, Default), ("Attribute Selection List", AttributeList, self.setShownAttributes)] self.outputs = [] #set default settings self.data = None self.attrX = "" self.attrY = "" self.attrCondition = None self.attrConditionValue = None self.showLines = 1 self.showCases = 0 self.showInColor = 1 self.attributeSelectionList = None self.stopCalculating = 0 #load settings self.loadSettings() self.canvas = QGraphicsScene() self.canvasView = QGraphicsView(self.canvas, self.mainArea) self.mainArea.layout().addWidget(self.canvasView) self.canvasView.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.canvasView.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) #GUI self.attrSelGroup = OWGUI.widgetBox(self.controlArea, box = "Shown attributes") self.attrXCombo = OWGUI.comboBoxWithCaption(self.attrSelGroup, self, "attrX", "X attribute:", tooltip = "Select an attribute to be shown on the X axis", callback = self.updateGraph, sendSelectedValue = 1, valueType = str, labelWidth = 70) self.attrYCombo = OWGUI.comboBoxWithCaption(self.attrSelGroup, self, "attrY", "Y attribute:", tooltip = "Select an attribute to be shown on the Y axis", callback = self.updateGraph, sendSelectedValue = 1, valueType = str, labelWidth = 70) OWGUI.separator(self.controlArea) self.conditionGroup = OWGUI.widgetBox(self.controlArea, box = "Condition") self.attrConditionCombo = OWGUI.comboBoxWithCaption(self.conditionGroup, self, "attrCondition", "Attribute:", callback = self.updateConditionAttr, sendSelectedValue = 1, valueType = str, labelWidth = 70) self.attrConditionValueCombo = OWGUI.comboBoxWithCaption(self.conditionGroup, self, "attrConditionValue", "Value:", callback = self.updateGraph, sendSelectedValue = 1, valueType = str, labelWidth = 70) OWGUI.separator(self.controlArea) box2 = OWGUI.widgetBox(self.controlArea, box = "Visual settings") OWGUI.checkBox(box2, self, "showLines", "Show lines", callback = self.updateGraph) hbox = OWGUI.widgetBox(box2, orientation = "horizontal") OWGUI.checkBox(hbox, self, "showCases", "Show data examples...", callback = self.updateGraph) OWGUI.checkBox(hbox, self, "showInColor", "...in color", callback = self.updateGraph) self.optimizationDlg = OWSieveOptimization(self, self.signalManager) optimizationButtons = OWGUI.widgetBox(self.controlArea, "Dialogs", orientation = "horizontal") OWGUI.button(optimizationButtons, self, "VizRank", callback = self.optimizationDlg.reshow, debuggingEnabled = 0, tooltip = "Find attribute groups with highest value dependency") OWGUI.rubber(self.controlArea) self.wdChildDialogs = [self.optimizationDlg] # used when running widget debugging self.connect(self.graphButton, SIGNAL("clicked()"), self.saveToFileCanvas) self.icons = self.createAttributeIconDict() self.resize(800, 550) random.seed()
def __init__(self, parent=None, signalManager=None): "Constructor" OWWidget.__init__(self, parent, signalManager, "Distributions (Qt)", TRUE) # settings self.numberOfBars = 5 self.barSize = 50 self.showContinuousClassGraph = 1 self.showProbabilities = 1 self.showConfidenceIntervals = 0 self.smoothLines = 0 self.lineWidth = 1 self.showMainTitle = 0 self.showXaxisTitle = 1 self.showYaxisTitle = 1 self.showYPaxisTitle = 1 self.attribute = "" self.targetValue = 0 self.visibleOutcomes = [] self.outcomes = [] # tmp values self.mainTitle = "" self.xaxisTitle = "" self.yaxisTitle = "frequency" self.yPaxisTitle = "" # GUI # self.tabs = OWGUI.tabWidget(self.controlArea) # self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main") # self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings") self.GeneralTab = self.SettingsTab = self.controlArea self.graph = OWDistributionGraphQt(self, self.mainArea) self.mainArea.layout().addWidget(self.graph) self.graph.setAxisScale(yRight, -0.05, 1.05, 0.1) self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile) self.loadSettings() self.setShowXaxisTitle() self.setShowYaxisTitle() self.setShowYPaxisTitle() self.barSize = 50 # inputs # data and graph temp variables self.inputs = [("Data", ExampleTable, self.setData, Default)] self.data = None self.outcomenames = [] self.probGraphValues = [] b = OWGUI.widgetBox(self.controlArea, "Variable", addSpace=True) self.variablesQCB = OWGUI.comboBox(b, self, "attribute", valueType=str, sendSelectedValue=True, callback=self.setVariable) OWGUI.widgetLabel(b, "Displayed outcomes") self.outcomesQLB = OWGUI.listBox( b, self, "visibleOutcomes", "outcomes", selectionMode=QListWidget.MultiSelection, callback=self.outcomeSelectionChange) # GUI connections # options dialog connections # b = OWGUI.widgetBox(self.SettingsTab, "Bars") # OWGUI.spin(b, self, "numberOfBars", label="Number of bars", min=5, max=60, step=5, callback=self.setNumberOfBars, callbackOnReturn=True) # self.numberOfBarsSlider = OWGUI.hSlider(self.SettingsTab, self, 'numberOfBars', box='Number of bars', minValue=5, maxValue=60, step=5, callback=self.setNumberOfBars, ticks=5) # self.numberOfBarsSlider.setTracking(0) # no change until the user stop dragging the slider # self.barSizeSlider = OWGUI.hSlider(self.SettingsTab, self, 'barSize', box="Bar size", minValue=30, maxValue=100, step=5, callback=self.setBarSize, ticks=10) # OWGUI.spin(b, self, "barSize", label="Bar size", min=30, max=100, step=5, callback=self.setBarSize, callbackOnReturn=True) box = OWGUI.widgetBox(self.SettingsTab, "General graph settings", addSpace=True) box.setMinimumWidth(180) box2 = OWGUI.widgetBox(box, orientation="horizontal") OWGUI.checkBox(box2, self, 'showMainTitle', 'Main title', callback=self.setShowMainTitle) OWGUI.lineEdit(box2, self, 'mainTitle', callback=self.setMainTitle, enterPlaceholder=True) box3 = OWGUI.widgetBox(box, orientation="horizontal") OWGUI.checkBox(box3, self, 'showXaxisTitle', 'X axis title', callback=self.setShowXaxisTitle) OWGUI.lineEdit(box3, self, 'xaxisTitle', callback=self.setXaxisTitle, enterPlaceholder=True) box4 = OWGUI.widgetBox(box, orientation="horizontal") OWGUI.checkBox(box4, self, 'showYaxisTitle', 'Y axis title', callback=self.setShowYaxisTitle) OWGUI.lineEdit(box4, self, 'yaxisTitle', callback=self.setYaxisTitle, enterPlaceholder=True) OWGUI.checkBox(box, self, 'graph.showContinuousClassGraph', 'Show continuous class graph', callback=self.setShowContinuousClassGraph) OWGUI.spin(box, self, "numberOfBars", label="Number of bars", min=5, max=60, step=5, callback=self.setNumberOfBars, callbackOnReturn=True) box5 = OWGUI.widgetBox(self.SettingsTab, "Probability plot") self.showProb = OWGUI.checkBox(box5, self, 'showProbabilities', 'Show probabilities', callback=self.setShowProbabilities) self.targetQCB = OWGUI.comboBox(OWGUI.indentedBox( box5, sep=OWGUI.checkButtonOffsetHint(self.showProb)), self, "targetValue", label="Target value", valueType=int, callback=self.setTarget) box6 = OWGUI.widgetBox(box5, orientation="horizontal") self.showYPaxisCheck = OWGUI.checkBox(box6, self, 'showYPaxisTitle', 'Axis title', callback=self.setShowYPaxisTitle) self.yPaxisEdit = OWGUI.lineEdit(box6, self, 'yPaxisTitle', callback=self.setYPaxisTitle, enterPlaceholder=True) self.confIntCheck = OWGUI.checkBox( box5, self, 'showConfidenceIntervals', 'Show confidence intervals', callback=self.setShowConfidenceIntervals) self.cbSmooth = OWGUI.checkBox(box5, self, 'smoothLines', 'Smooth probability lines', callback=self.setSmoothLines) self.showProb.disables = [ self.showYPaxisCheck, self.yPaxisEdit, self.confIntCheck, self.targetQCB, self.cbSmooth ] self.showProb.makeConsistent() # self.barSizeSlider = OWGUI.hSlider(box5, self, 'lineWidth', box='Line width', minValue=1, maxValue=9, step=1, callback=self.setLineWidth, ticks=1) OWGUI.rubber(self.SettingsTab) #add controls to self.controlArea widget self.icons = self.createAttributeIconDict() self.graph.numberOfBars = self.numberOfBars self.graph.barSize = self.barSize self.graph.setShowMainTitle(self.showMainTitle) self.graph.setShowXaxisTitle(self.showXaxisTitle) self.graph.setShowYLaxisTitle(self.showYaxisTitle) self.graph.setShowYRaxisTitle(self.showYPaxisTitle) self.graph.setMainTitle(self.mainTitle) self.graph.setXaxisTitle(self.xaxisTitle) self.graph.setYLaxisTitle(self.yaxisTitle) self.graph.setYRaxisTitle(self.yPaxisTitle) self.graph.showProbabilities = self.showProbabilities self.graph.showConfidenceIntervals = self.showConfidenceIntervals self.graph.smoothLines = self.smoothLines self.graph.lineWidth = self.lineWidth #self.graph.variableContinuous = self.VariableContinuous self.graph.targetValue = self.targetValue
def __init__(self, parent=None, signalManager = None, name='AttributeDistance'): self.callbackDeposit = [] # deposit for OWGUI callback functions OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0, resizingEnabled = 0) self.inputs = [("Data", ExampleTable, self.dataset)] self.outputs = [("Distances", orange.SymMatrix)] self.data = None self.classInteractions = 0 self.loadSettings() rb = OWGUI.radioButtonsInBox(self.controlArea, self, "classInteractions", [], "Distance", callback=self.toggleClass) OWGUI.widgetLabel(rb, "Measures on discrete attributes\n (continuous attributes are discretized into five intervals)") for b in self.discMeasures: OWGUI.appendRadioButton(rb, self, "classInteractions", b) OWGUI.widgetLabel(rb, "\n"+"Measures on continuous attributes\n (discrete attributes are treated as ordinal)") for b in self.contMeasures: OWGUI.appendRadioButton(rb, self, "classInteractions", b) OWGUI.rubber(self.controlArea) self.resize(215,50)
def synchronizeTable(self): # for row in range(len(self.Conditions), self.criteriaTable.rowCount()): # self.criteriaTable.clearCellWidget(row,0) # self.criteriaTable.clearCell(row,1) currentRow = self.criteriaTable.currentRow() self.criteriaTable.clearContents() self.criteriaTable.setRowCount(len(self.Conditions)) for row, cond in enumerate(self.Conditions): if cond.type == "OR": cw = QLabel("", self) else: cw = QCheckBox( str( len( cond.operator.getFilter( self.data.domain, cond.varName, cond.val1, cond.val2, cond.negated, cond.caseSensitive)(self.data))), self) # cw.setChecked(cond.enabled) self.connect(cw, SIGNAL("toggled(bool)"), lambda val, cond=cond: self.criteriaActiveChange( cond, val)) self.criteriaTable.setCellWidget(row, 0, cw) # This is a fix for Qt bug (4.3). When Qt is fixed, the setChecked above should suffice # but now it unchecks the checkbox as it is inserted if cond.type != "OR": cw.setChecked(cond.enabled) # column 1 if cond.type == "OR": txt = "OR" else: soper = str(cond.operator) if cond.negated and soper in Operator.negations: txt = "'%s' %s " % (cond.varName, Operator.negations[soper]) else: txt = (cond.negated and "NOT " or "") + "'%s' %s " % (cond.varName, soper) if cond.operator != Operator.operatorDef: if cond.operator.varType == orange.VarTypes.Discrete: if cond.operator.isInterval: if len(cond.val1) > 0: txt += "[" for name in cond.val1: txt += "%s, " % name txt = txt[0:-2] + "]" else: txt += "[]" else: txt += cond.val1[0] elif cond.operator.varType == orange.VarTypes.String: if cond.caseSensitive: cs = " (C)" else: cs = "" if cond.operator.isInterval: txt += "'%s'%s and '%s'%s" % (cond.val1, cs, cond.val2, cs) else: txt += "'%s'%s" % (cond.val1, cs) elif cond.operator.varType == orange.VarTypes.Continuous: if cond.operator.isInterval: txt += str(cond.val1) + " and " + str(cond.val2) else: txt += str(cond.val1) OWGUI.tableItem(self.criteriaTable, row, 1, txt) self.criteriaTable.setCurrentCell( max(currentRow, len(self.Conditions) - 1), 0) self.criteriaTable.resizeRowsToContents() self.updateFilteredDataLens() en = len(self.Conditions) self.btnUpdate.setEnabled(en) self.btnRemove.setEnabled(en) self.updateMoveButtons()
def __init__(self, parent=None, signalManager=None, name="Merge data"): OWWidget.__init__(self, parent, signalManager, name, wantMainArea=0) #initialize base class # set channels self.inputs = [("Data A", ExampleTable, self.onDataAInput), ("Data B", ExampleTable, self.onDataBInput)] self.outputs = [("Merged Data A+B", ExampleTable), ("Merged Data B+A", ExampleTable)] # data self.dataA = None self.dataB = None self.varListA = [] self.varListB = [] self.varA = None self.varB = None self.lbAttrAItems = [] self.lbAttrBItems = [] # load settings self.loadSettings() # GUI w = QWidget(self) self.controlArea.layout().addWidget(w) grid = QGridLayout() grid.setMargin(0) w.setLayout(grid) # attribute A boxAttrA = OWGUI.widgetBox(self, 'Attribute A', orientation="vertical", addToLayout=0) grid.addWidget(boxAttrA, 0, 0) self.lbAttrA = OWGUI.listBox(boxAttrA, self, "lbAttrAItems", callback=self.lbAttrAChange) # attribute B boxAttrB = OWGUI.widgetBox(self, 'Attribute B', orientation="vertical", addToLayout=0) grid.addWidget(boxAttrB, 0, 1) self.lbAttrB = OWGUI.listBox(boxAttrB, self, "lbAttrBItems", callback=self.lbAttrBChange) # info A boxDataA = OWGUI.widgetBox(self, 'Data A', orientation="vertical", addToLayout=0) grid.addWidget(boxDataA, 1, 0) self.lblDataAExamples = OWGUI.widgetLabel(boxDataA, "num examples") self.lblDataAAttributes = OWGUI.widgetLabel(boxDataA, "num attributes") # info B boxDataB = OWGUI.widgetBox(self, 'Data B', orientation="vertical", addToLayout=0) grid.addWidget(boxDataB, 1, 1) self.lblDataBExamples = OWGUI.widgetLabel(boxDataB, "num examples") self.lblDataBAttributes = OWGUI.widgetLabel(boxDataB, "num attributes") # icons self.icons = self.createAttributeIconDict() # resize self.resize(400, 500)
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 createShowHiddenLists(self, placementTab, callback=None): maxWidth = 180 self.updateCallbackFunction = callback self.shownAttributes = [] self.selectedShown = [] self.hiddenAttributes = [] self.selectedHidden = [] self.shownAttribsGroup = OWGUI.widgetBox(placementTab, " Shown attributes ") self.addRemoveGroup = OWGUI.widgetBox(placementTab, 1, orientation="horizontal") self.hiddenAttribsGroup = OWGUI.widgetBox(placementTab, " Hidden attributes ") hbox = OWGUI.widgetBox(self.shownAttribsGroup, orientation='horizontal') self.shownAttribsLB = OWGUI.listBox( hbox, self, "selectedShown", "shownAttributes", callback=self.resetAttrManipulation, dragDropCallback=callback, enableDragDrop=1, selectionMode=QListWidget.ExtendedSelection) #self.shownAttribsLB.setMaximumWidth(maxWidth) vbox = OWGUI.widgetBox(hbox, orientation='vertical') self.buttonUPAttr = OWGUI.button(vbox, self, "", callback=self.moveAttrUP, tooltip="Move selected attributes up") self.buttonDOWNAttr = OWGUI.button( vbox, self, "", callback=self.moveAttrDOWN, tooltip="Move selected attributes down") self.buttonUPAttr.setIcon( QIcon(os.path.join(self.widgetDir, "icons/Dlg_up3.png"))) self.buttonUPAttr.setSizePolicy( QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)) self.buttonUPAttr.setMaximumWidth(30) self.buttonDOWNAttr.setIcon( QIcon(os.path.join(self.widgetDir, "icons/Dlg_down3.png"))) self.buttonDOWNAttr.setSizePolicy( QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)) self.buttonDOWNAttr.setMaximumWidth(30) self.attrAddButton = OWGUI.button( self.addRemoveGroup, self, "", callback=self.addAttribute, tooltip="Add (show) selected attributes") self.attrAddButton.setIcon( QIcon(os.path.join(self.widgetDir, "icons/Dlg_up3.png"))) self.attrRemoveButton = OWGUI.button( self.addRemoveGroup, self, "", callback=self.removeAttribute, tooltip="Remove (hide) selected attributes") self.attrRemoveButton.setIcon( QIcon(os.path.join(self.widgetDir, "icons/Dlg_down3.png"))) self.showAllCB = OWGUI.checkBox(self.addRemoveGroup, self, "showAllAttributes", "Show all", callback=self.cbShowAllAttributes) self.hiddenAttribsLB = OWGUI.listBox( self.hiddenAttribsGroup, self, "selectedHidden", "hiddenAttributes", callback=self.resetAttrManipulation, dragDropCallback=callback, enableDragDrop=1, selectionMode=QListWidget.ExtendedSelection)
def __init__(self,parent=None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "FeatureConstructor") self.inputs = [("Examples", orange.ExampleTable, self.setData)] self.outputs = [("Examples", ExampleTable)] self.expression = self.attrname = "" self.selectedDef = [] self.defLabels = [] self.data = None self.definitions = [] self.selectedAttr = 0 self.selectedFunc = 0 self.autosend = True self.loadSettings() db = OWGUI.widgetBox(self.controlArea, "Attribute definitions", addSpace = True) hb = OWGUI.widgetBox(db, None, "horizontal") hbv = OWGUI.widgetBox(hb) self.leAttrName = OWGUI.lineEdit(hbv, self, "attrname", "New attribute") OWGUI.rubber(hbv) vb = OWGUI.widgetBox(hb, None, "vertical", addSpace=True) self.leExpression = OWGUI.lineEdit(vb, self, "expression", "Expression") hhb = OWGUI.widgetBox(vb, None, "horizontal") self.cbAttrs = OWGUI.comboBox(hhb, self, "selectedAttr", items = ["(all attributes)"], callback = self.attrListSelected) sortedFuncs = sorted(m for m in list(AttrComputer.FUNCTIONS.keys())) self.cbFuncs = OWGUI.comboBox(hhb, self, "selectedFunc", items = ["(all functions)"] + sortedFuncs, callback = self.funcListSelected) model = self.cbFuncs.model() for i, func in enumerate(sortedFuncs): model.item(i + 1).setToolTip(AttrComputer.FUNCTIONS[func].__doc__) hb = OWGUI.widgetBox(db, None, "horizontal", addSpace=True) OWGUI.button(hb, self, "Add", callback = self.addAttr) OWGUI.button(hb, self, "Update", callback = self.updateAttr) OWGUI.button(hb, self, "Remove", callback = self.removeAttr) OWGUI.button(hb, self, "Remove All", callback = self.removeAllAttr) self.lbDefinitions = OWGUI.listBox(db, self, "selectedDef", "defLabels", callback=self.selectAttr) self.lbDefinitions.setFixedHeight(160) hb = OWGUI.widgetBox(self.controlArea, "Apply", "horizontal") OWGUI.button(hb, self, "Apply", callback = self.apply) cb = OWGUI.checkBox(hb, self, "autosend", "Apply automatically", callback=self.enableAuto) cb.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)) self.adjustSize()
def __init__(self, parent=None, signalManager=None, name="Select data"): OWWidget.__init__(self, parent, signalManager, name, wantMainArea=0) #initialize base class self.inputs = [("Data", ExampleTable, self.setData)] self.outputs = [("Matching Data", ExampleTable, Default), ("Unmatched Data", ExampleTable)] self.name2var = {} # key: variable name, item: orange.Variable self.Conditions = [] self.currentVar = None self.NegateCondition = False self.currentOperatorDict = { orange.VarTypes.Continuous: Operator(Operator.operatorsC[0], orange.VarTypes.Continuous), orange.VarTypes.Discrete: Operator(Operator.operatorsD[0], orange.VarTypes.Discrete), orange.VarTypes.String: Operator(Operator.operatorsS[0], orange.VarTypes.String) } self.Num1 = 0.0 self.Num2 = 0.0 self.Str1 = "" self.Str2 = "" self.attrSearchText = "" self.currentVals = [] self.CaseSensitive = False self.updateOnChange = True self.purgeAttributes = True self.purgeClasses = True self.oldPurgeClasses = True self.loadedVarNames = [] self.loadedConditions = [] self.loadSettings() w = QWidget(self) self.controlArea.layout().addWidget(w) grid = QGridLayout() grid.setMargin(0) w.setLayout(grid) boxAttrCond = OWGUI.widgetBox(self, '', orientation=QGridLayout(), addToLayout=0) grid.addWidget(boxAttrCond, 0, 0, 1, 3) glac = boxAttrCond.layout() glac.setColumnStretch(0, 2) glac.setColumnStretch(1, 1) glac.setColumnStretch(2, 2) boxAttr = OWGUI.widgetBox(self, 'Attribute', addToLayout=0) glac.addWidget(boxAttr, 0, 0) self.lbAttr = OWGUI.listBox(boxAttr, self, callback=self.lbAttrChange) self.leSelect = OWGUI.lineEdit(boxAttr, self, "attrSearchText", label="Search: ", orientation="horizontal", callback=self.setLbAttr, callbackOnType=1) boxOper = OWGUI.widgetBox(self, 'Operator') # operators 0: empty self.lbOperatosNone = OWGUI.listBox(boxOper, self) # operators 1: discrete self.lbOperatorsD = OWGUI.listBox(boxOper, self, callback=self.lbOperatorsChange) self.lbOperatorsD.hide() self.lbOperatorsD.addItems(Operator.operatorsD + [Operator.operatorDef]) # operators 2: continuous self.lbOperatorsC = OWGUI.listBox(boxOper, self, callback=self.lbOperatorsChange) self.lbOperatorsC.hide() self.lbOperatorsC.addItems(Operator.operatorsC + [Operator.operatorDef]) # operators 6: string self.lbOperatorsS = OWGUI.listBox(boxOper, self, callback=self.lbOperatorsChange) self.lbOperatorsS.hide() self.lbOperatorsS.addItems(Operator.operatorsS + [Operator.operatorDef]) self.lbOperatorsDict = { 0: self.lbOperatosNone, orange.VarTypes.Continuous: self.lbOperatorsC, orange.VarTypes.Discrete: self.lbOperatorsD, orange.VarTypes.String: self.lbOperatorsS } glac.addWidget(boxOper, 0, 1) self.cbNot = OWGUI.checkBox(boxOper, self, "NegateCondition", "Negate") self.boxIndices = {} self.valuesStack = QStackedWidget(self) glac.addWidget(self.valuesStack, 0, 2) # values 0: empty boxVal = OWGUI.widgetBox(self, "Values", addToLayout=0) self.boxIndices[0] = boxVal self.valuesStack.addWidget(boxVal) # values 1: discrete boxVal = OWGUI.widgetBox(self, "Values", addToLayout=0) self.boxIndices[orange.VarTypes.Discrete] = boxVal self.valuesStack.addWidget(boxVal) self.lbVals = OWGUI.listBox(boxVal, self, callback=self.lbValsChange) # values 2: continuous between num and num boxVal = OWGUI.widgetBox(self, "Values", addToLayout=0) self.boxIndices[orange.VarTypes.Continuous] = boxVal self.valuesStack.addWidget(boxVal) self.leNum1 = OWGUI.lineEdit(boxVal, self, "Num1", validator=QDoubleValidator(self)) self.lblAndCon = OWGUI.widgetLabel(boxVal, "and") self.leNum2 = OWGUI.lineEdit(boxVal, self, "Num2", validator=QDoubleValidator(self)) boxAttrStat = OWGUI.widgetBox(boxVal, "Statistics") self.lblMin = OWGUI.widgetLabel(boxAttrStat, "Min: ") self.lblAvg = OWGUI.widgetLabel(boxAttrStat, "Avg: ") self.lblMax = OWGUI.widgetLabel(boxAttrStat, "Max: ") self.lblDefined = OWGUI.widgetLabel(boxAttrStat, "Defined for ---- examples") OWGUI.rubber(boxAttrStat) # values 6: string between str and str boxVal = OWGUI.widgetBox(self, "Values", addToLayout=0) self.boxIndices[orange.VarTypes.String] = boxVal self.valuesStack.addWidget(boxVal) self.leStr1 = OWGUI.lineEdit(boxVal, self, "Str1") self.lblAndStr = OWGUI.widgetLabel(boxVal, "and") self.leStr2 = OWGUI.lineEdit(boxVal, self, "Str2") self.cbCaseSensitive = OWGUI.checkBox(boxVal, self, "CaseSensitive", "Case sensitive") self.boxButtons = OWGUI.widgetBox(self, orientation="horizontal") grid.addWidget(self.boxButtons, 1, 0, 1, 3) self.btnNew = OWGUI.button(self.boxButtons, self, "Add", self.OnNewCondition) self.btnUpdate = OWGUI.button(self.boxButtons, self, "Modify", self.OnUpdateCondition) self.btnRemove = OWGUI.button(self.boxButtons, self, "Remove", self.OnRemoveCondition) self.btnOR = OWGUI.button(self.boxButtons, self, "OR", self.OnDisjunction) self.btnMoveUp = OWGUI.button(self.boxButtons, self, "Move Up", self.btnMoveUpClicked) self.btnMoveDown = OWGUI.button(self.boxButtons, self, "Move Down", self.btnMoveDownClicked) self.btnRemove.setEnabled(False) self.btnUpdate.setEnabled(False) self.btnMoveUp.setEnabled(False) self.btnMoveDown.setEnabled(False) boxCriteria = OWGUI.widgetBox(self, 'Data Selection Criteria', addToLayout=0) grid.addWidget(boxCriteria, 2, 0, 1, 3) self.criteriaTable = QTableWidget(boxCriteria) boxCriteria.layout().addWidget(self.criteriaTable) self.criteriaTable.setShowGrid(False) self.criteriaTable.setSelectionMode(QTableWidget.SingleSelection) self.criteriaTable.setColumnCount(2) self.criteriaTable.verticalHeader().setClickable(False) #self.criteriaTable.verticalHeader().setResizeEnabled(False,-1) self.criteriaTable.horizontalHeader().setClickable(False) self.criteriaTable.setHorizontalHeaderLabels(["Active", "Condition"]) self.criteriaTable.resizeColumnToContents(0) self.criteriaTable.setSelectionBehavior(QAbstractItemView.SelectRows) self.criteriaTable.horizontalHeader().setResizeMode( 1, QHeaderView.Stretch) self.connect(self.criteriaTable, SIGNAL('cellClicked(int, int)'), self.currentCriteriaChange) boxDataIn = OWGUI.widgetBox(self, 'Data In', addToLayout=0) grid.addWidget(boxDataIn, 3, 0) self.dataInExamplesLabel = OWGUI.widgetLabel(boxDataIn, "num examples") self.dataInAttributesLabel = OWGUI.widgetLabel(boxDataIn, "num attributes") OWGUI.rubber(boxDataIn) boxDataOut = OWGUI.widgetBox(self, 'Data Out', addToLayout=0) grid.addWidget(boxDataOut, 3, 1) self.dataOutExamplesLabel = OWGUI.widgetLabel(boxDataOut, "num examples") self.dataOutAttributesLabel = OWGUI.widgetLabel( boxDataOut, "num attributes") OWGUI.rubber(boxDataOut) boxSettings = OWGUI.widgetBox(self, 'Commit', addToLayout=0) grid.addWidget(boxSettings, 3, 2) cb = OWGUI.checkBox(boxSettings, self, "purgeAttributes", "Remove unused values/attributes", box=None, callback=self.OnPurgeChange) self.purgeClassesCB = OWGUI.checkBox(OWGUI.indentedBox( boxSettings, sep=OWGUI.checkButtonOffsetHint(cb)), self, "purgeClasses", "Remove unused classes", callback=self.OnPurgeChange) OWGUI.checkBox(boxSettings, self, "updateOnChange", "Commit on change", box=None) btnUpdate = OWGUI.button(boxSettings, self, "Commit", self.setOutput, default=True) self.icons = self.createAttributeIconDict() self.setData(None) self.lbOperatorsD.setCurrentRow(0) self.lbOperatorsC.setCurrentRow(0) self.lbOperatorsS.setCurrentRow(0) self.resize(500, 661) grid.setRowStretch(0, 10) grid.setRowStretch(2, 10)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'Python Script') self.inputs = [("inExampleTable", ExampleTable, self.setExampleTable), ("inDistanceMatrix", orange.SymMatrix, self.setDistanceMatrix), ("inNetwork", orngNetwork.Network, self.setNetwork)] self.outputs = [("outExampleTable", ExampleTable), ("outDistanceMatrix", orange.SymMatrix), ("outNetwork", orngNetwork.Network)] self.inNetwork = None self.inExampleTable = None self.inDistanceMatrix = None self.codeFile = '' self.loadSettings() self.infoBox = OWGUI.widgetBox(self.controlArea, 'Info') OWGUI.label( self.infoBox, self, "Execute python script.\n\nInput variables:\n - inExampleTable\n - inDistanceMatrix\n - inNetwork\n\nOutput variables:\n - outExampleTable\n - outDistanceMatrix\n - outNetwork" ) self.controlBox = OWGUI.widgetBox(self.controlArea, 'File') OWGUI.button(self.controlBox, self, "Open...", callback=self.openScript) OWGUI.button(self.controlBox, self, "Save...", callback=self.saveScript) self.runBox = OWGUI.widgetBox(self.controlArea, 'Run') OWGUI.button(self.runBox, self, "Execute", callback=self.execute) self.splitCanvas = QSplitter(Qt.Vertical, self.mainArea) self.mainArea.layout().addWidget(self.splitCanvas) self.textBox = OWGUI.widgetBox(self, 'Python script') self.splitCanvas.addWidget(self.textBox) self.text = QPlainTextEdit(self) self.textBox.layout().addWidget(self.text) self.text.setFont(QFont("Monospace")) self.textBox.setAlignment(Qt.AlignVCenter) self.text.setTabStopWidth(4) self.consoleBox = OWGUI.widgetBox(self, 'Console') self.splitCanvas.addWidget(self.consoleBox) self.console = QPlainTextEdit(self) self.consoleBox.layout().addWidget(self.console) self.console.setFont(QFont("Monospace")) self.consoleBox.setAlignment(Qt.AlignBottom) self.console.setTabStopWidth(4) self.openScript(self.codeFile) self.controlArea.layout().addStretch(1) self.resize(800, 600)
def __init__(self, parent=None, signalManager=None): """Widget creator.""" # Standard call to creator of base class (OWWidget). OWWidget.__init__( self, parent, signalManager, wantMainArea=0, wantStateInfoWidget=0, ) # Channel definitions... self.inputs = [] self.outputs = [('Text data', Segmentation)] # Settings initializations... self.autoSend = True self.label = u'xml_tei_data' self.filterCriterion = u'author' self.filterValue = u'(all)' self.titleLabels = list() self.selectedTitles = list() self.importedURLs = list() self.displayAdvancedSettings = False # Always end Textable widget settings with the following 3 lines... self.uuid = None self.loadSettings() self.uuid = getWidgetUuid(self) # Other attributes... self.segmentation = None self.createdInputs = list() self.titleSeg = None self.filteredTitleSeg = None self.filterValues = dict() self.base_url = \ u'http://www.theatre-classique.fr/pages/programmes/PageEdition.php' self.document_base_url = \ u'http://www.theatre-classique.fr/pages/' # Next two instructions are helpers from TextableUtils. Corresponding # interface elements are declared here and actually drawn below (at # their position in the UI)... self.infoBox = InfoBox(widget=self.controlArea) self.sendButton = SendButton( widget=self.controlArea, master=self, callback=self.sendData, infoBoxAttribute=u'infoBox', sendIfPreCallback=self.updateGUI, ) # The AdvancedSettings class, also from TextableUtils, facilitates # the management of basic vs. advanced interface. An object from this # class (here assigned to self.advancedSettings) contains two lists # (basicWidgets and advanceWidgets), to which the corresponding # widgetBoxes must be added. self.advancedSettings = AdvancedSettings( widget=self.controlArea, master=self, callback=self.updateFilterValueList, ) # User interface... # Advanced settings checkbox (basic/advanced interface will appear # immediately after it... self.advancedSettings.draw() # Filter box (advanced settings only) filterBox = OWGUI.widgetBox( widget=self.controlArea, box=u'Filter', orientation=u'vertical', ) filterCriterionCombo = OWGUI.comboBox( widget=filterBox, master=self, value=u'filterCriterion', items=[u'author', u'year', u'genre'], sendSelectedValue=True, orientation=u'horizontal', label=u'Criterion:', labelWidth=120, callback=self.updateFilterValueList, tooltip=( u"Please select a criterion for searching the title list\n"), ) filterCriterionCombo.setMinimumWidth(120) OWGUI.separator(widget=filterBox, height=3) self.filterValueCombo = OWGUI.comboBox( widget=filterBox, master=self, value=u'filterValue', sendSelectedValue=True, orientation=u'horizontal', label=u'Value:', labelWidth=120, callback=self.updateTitleList, tooltip=(u"Please select a value for the chosen criterion."), ) OWGUI.separator(widget=filterBox, height=3) # The following lines add filterBox (and a vertical separator) to the # advanced interface... self.advancedSettings.advancedWidgets.append(filterBox) self.advancedSettings.advancedWidgetsAppendSeparator() # Title box titleBox = OWGUI.widgetBox( widget=self.controlArea, box=u'Titles', orientation=u'vertical', ) self.titleListbox = OWGUI.listBox( widget=titleBox, master=self, value=u'selectedTitles', # setting (list) labels=u'titleLabels', # setting (list) callback=self.sendButton.settingsChanged, tooltip=u"The list of titles whose content will be imported", ) self.titleListbox.setMinimumHeight(150) self.titleListbox.setSelectionMode(3) OWGUI.separator(widget=titleBox, height=3) OWGUI.button( widget=titleBox, master=self, label=u'Refresh', callback=self.refreshTitleSeg, tooltip=u"Connect to Theatre-classique website and refresh list.", ) OWGUI.separator(widget=titleBox, height=3) OWGUI.separator(widget=self.controlArea, height=3) OWGUI.rubber(self.controlArea) # Now Info box and Send button must be drawn... self.sendButton.draw() self.infoBox.draw() # This initialization step needs to be done after infoBox has been # drawn (because getTitleSeg may need to display an error message). self.getTitleSeg() # Send data if autoSend. self.sendButton.sendIf() self.setMinimumWidth(350) self.adjustSizeWithTimer()