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, 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 __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='kmeans'): OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0) self.callbackDeposit = [] self.inputs = [("Data", Descriptors, self.setData)] self.outputs = [("Codebook", Codebook)] # , ("Histograms", ExampleTable)] self.useLazyEvaluation = pynopticon.useLazyEvaluation # Settings self.name = name self.kmeans = None self.loadSettings() self.numClusters = 20 self.maxiter = 0 self.numruns = 1 self.sampleFromData = 1.0 self.loadSettings() wbN = OWGUI.widgetBox(self.controlArea, "kMeans Settings") OWGUI.spin(wbN, self, "numClusters", 1, 100000, 100, None, "Number of clusters ", orientation="horizontal") OWGUI.spin(wbN, self, "maxiter", 0, 100000, 1, None, "Maximum number of iterations", orientation="horizontal") OWGUI.spin(wbN, self, "numruns", 0, 100000, 1, None, "Number of runs ", orientation="horizontal") OWGUI.widgetLabel(wbN, 'Use x% of the data') OWGUI.lineEdit(wbN, self, 'sampleFromData', valueType=float) 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 = [("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, "Itemsets", wantMainArea = 0) from OWItemsets import Itemsets self.inputs = [("Data", ExampleTable, self.setData)] self.outputs = [("Itemsets", Itemsets)] self.minSupport = 60 self.maxRules = 10000 self.useSparseAlgorithm = False self.loadSettings() self.dataset = None box = OWGUI.widgetBox(self.space, "Settings", addSpace = True) OWGUI.checkBox(box, self, 'useSparseAlgorithm', 'Use algorithm for sparse data', tooltip="Use original Agrawal's algorithm") OWGUI.widgetLabel(box, "Minimal support [%]") OWGUI.hSlider(box, self, 'minSupport', minValue=1, maxValue=100, ticks=10, step = 1) OWGUI.separator(box, 0, 0) OWGUI.widgetLabel(box, 'Maximal number of rules') OWGUI.hSlider(box, self, 'maxRules', minValue=10000, maxValue=100000, step=10000, ticks=10000, debuggingEnabled = 0) OWGUI.button(self.space, self, "&Find Itemsets", self.findItemsets, default=True) OWGUI.rubber(self.controlArea) self.adjustSize()
def __init__(self, parent=None, signalManager=None, name='Classification Tree'): OWWidget.__init__(self, parent, signalManager, name, wantMainArea=0, resizingEnabled=0) self.inputs = [("Data", ExampleTable, self.setData), ("Preprocess", PreprocessedLearner, self.setPreprocessor)] self.outputs = [("Learner", Orange.classification.tree.TreeLearner), ("Classification Tree", Orange.classification.tree.TreeClassifier), ] self.name = 'Classification Tree' self.estim = 0; self.relK = 5; self.relM = 100; self.limitRef = True self.bin = 0; self.subset = 0 self.preLeafInstP = 2; self.preNodeInstP = 5; self.preNodeMajP = 95 self.preLeafInst = 1; self.preNodeInst = 0; self.preNodeMaj = 0 self.postMaj = 1; self.postMPruning = 1; self.postM = 2.0 self.limitDepth = False; self.maxDepth = 100 self.loadSettings() self.data = None self.preprocessor = None self.setLearner() 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) qBox = OWGUI.widgetBox(self.controlArea, 'Attribute selection criterion') self.qMea = OWGUI.comboBox(qBox, self, "estim", items=[m[0] for m in self.measures], callback=self.measureChanged) b1 = OWGUI.widgetBox(qBox, orientation="horizontal") OWGUI.separator(b1, 16, 0) b2 = OWGUI.widgetBox(b1) self.cbLimitRef, self.hbxRel1 = OWGUI.checkWithSpin(b2, self, "Limit the number of reference examples to ", 1, 1000, "limitRef", "relM") OWGUI.separator(b2) self.hbxRel2 = OWGUI.spin(b2, self, "relK", 1, 50, orientation="horizontal", label="Number of neighbours in ReliefF ") OWGUI.separator(self.controlArea) OWGUI.radioButtonsInBox(self.controlArea, self, 'bin', self.binarizationOpts, "Binarization") OWGUI.separator(self.controlArea) self.measureChanged() self.pBox = OWGUI.widgetBox(self.controlArea, 'Pre-Pruning') self.preLeafInstBox, self.preLeafInstPBox = OWGUI.checkWithSpin(self.pBox, self, "Min. instances in leaves ", 1, 1000, "preLeafInst", "preLeafInstP") self.preNodeInstBox, self.preNodeInstPBox = OWGUI.checkWithSpin(self.pBox, self, "Stop splitting nodes with less instances than ", 1, 1000, "preNodeInst", "preNodeInstP") self.preNodeMajBox, self.preNodeMajPBox = OWGUI.checkWithSpin(self.pBox, self, "Stop splitting nodes with a majority class of (%)", 1, 100, "preNodeMaj", "preNodeMajP") self.cbLimitDepth, self.maxDepthBox = OWGUI.checkWithSpin(self.pBox, self, "Stop splitting nodes at depth", 0, 1000, "limitDepth", "maxDepth") OWGUI.separator(self.controlArea) self.mBox = OWGUI.widgetBox(self.controlArea, 'Post-Pruning') OWGUI.checkBox(self.mBox, self, 'postMaj', 'Recursively merge leaves with same majority class') self.postMPruningBox, self.postMPruningPBox = OWGUI.checkWithSpin(self.mBox, self, "Pruning with m-estimate, m=", 0, 1000, 'postMPruning', 'postM') OWGUI.separator(self.controlArea) self.btnApply = OWGUI.button(self.controlArea, self, "&Apply", callback=self.setLearner, disabled=0, default=True) OWGUI.rubber(self.controlArea) self.resize(200, 200)
def __init__(self, parent=None): OWWidget.__init__(self, parent, title='X Learner') self.method= 0 self.maxi = 1 self.cheat = 0 self.autoApply = True self.settingsChanged = False OWGUI.radioButtonsInBox(self.controlArea, self, "method", ["Vanishing", "Disappearing", "Invisibilisation"], box="Minimization technique", callback = self.applyIf) OWGUI.separator(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Settings") OWGUI.checkBox(box, self, "maxi", "Post-maximize", callback = self.applyIf) OWGUI.checkBox(box, self, "cheat", "Quasi-cheating", callback = self.applyIf) OWGUI.separator(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Apply") applyButton = OWGUI.button(box, self, "Apply", callback = self.apply) autoApplyCB = OWGUI.checkBox(box, self, "autoApply", "Apply automatically") OWGUI.setStopper(self, applyButton, autoApplyCB, "settingsChanged", self.apply) self.adjustSize()
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'SampleDataC') self.inputs = [("Data", Orange.data.Table, self.set_data)] # [start-snippet-1] self.outputs = [("Sampled Data", Orange.data.Table), ("Other Data", Orange.data.Table)] # [end-snippet-1] self.proportion = 50 self.commitOnChange = 0 self.loadSettings() # 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, '') 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) self.resize(100,50)
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): OWWidget.__init__(self, parent, signalManager, 'LearningCurveA') # [start-snippet-1] self.inputs = [("Data", Orange.data.Table, self.set_dataset), ("Learner", Orange.classification.Learner, self.set_learner, Multiple + Default)] # [end-snippet-1] self.folds = 5 # cross validation folds self.steps = 10 # points in the learning curve self.scoringF = 0 # scoring function self.commitOnChange = 1 # compute curve on any change of parameters self.loadSettings() self.updateCurvePoints() # sets self.curvePoints, self.steps equidistant points from 1/self.steps to 1 # [start-snippet-2] self.scoring = [("Classification Accuracy", Orange.evaluation.scoring.CA), ("AUC", Orange.evaluation.scoring.AUC), ("BrierScore", Orange.evaluation.scoring.Brier_score), ("Information Score", Orange.evaluation.scoring.IS), ("Sensitivity", Orange.evaluation.scoring.Sensitivity), ("Specificity", Orange.evaluation.scoring.Specificity)] # [end-snippet-2] self.learners = [] # list of current learners from input channel, tuples (id, learner) self.data = None # data on which to construct the learning curve self.curves = [] # list of evaluation results (one per learning curve point) self.scores = [] # list of current scores, learnerID:[learner scores] # GUI box = OWGUI.widgetBox(self.controlArea, "Info") self.infoa = OWGUI.widgetLabel(box, 'No data on input.') self.infob = OWGUI.widgetLabel(box, 'No learners.') OWGUI.separator(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Evaluation Scores") scoringNames = [x[0] for x in self.scoring] OWGUI.comboBox(box, self, "scoringF", items=scoringNames, callback=self.computeScores) OWGUI.separator(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Options") OWGUI.spin(box, self, 'folds', 2, 100, step=1, label='Cross validation folds: ', callback=lambda: self.computeCurve() if self.commitOnChange else None) OWGUI.spin(box, self, 'steps', 2, 100, step=1, label='Learning curve points: ', callback=[self.updateCurvePoints, lambda: self.computeCurve() if self.commitOnChange else None]) OWGUI.checkBox(box, self, 'commitOnChange', 'Apply setting on any change') self.commitBtn = OWGUI.button(box, self, "Apply Setting", callback=self.computeCurve, disabled=1) OWGUI.rubber(self.controlArea) # table widget self.table = OWGUI.table(self.mainArea, selectionMode=QTableWidget.NoSelection) self.resize(500,200)
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): OWWidget.__init__(self, parent, signalManager, "Confusion Matrix", 1) # inputs self.inputs=[("Evaluation Results", orngTest.ExperimentResults, self.setTestResults, Default)] self.outputs=[("Selected Data", ExampleTable, 8)] self.selectedLearner = [] self.learnerNames = [] self.selectionDirty = 0 self.autoApply = True self.appendPredictions = True self.appendProbabilities = False self.shownQuantity = 0 self.learnerList = OWGUI.listBox(self.controlArea, self, "selectedLearner", "learnerNames", box = "Learners", callback = self.learnerChanged) self.learnerList.setMinimumHeight(100) OWGUI.separator(self.controlArea) OWGUI.comboBox(self.controlArea, self, "shownQuantity", items = self.quantities, box = "Show", callback=self.reprint) OWGUI.separator(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Selection") #, addSpace=True) OWGUI.button(box, self, "Correct", callback=self.selectCorrect) OWGUI.button(box, self, "Misclassified", callback=self.selectWrong) OWGUI.button(box, self, "None", callback=self.selectNone) OWGUI.separator(self.controlArea) self.outputBox = box = OWGUI.widgetBox(self.controlArea, "Output") OWGUI.checkBox(box, self, "appendPredictions", "Append class predictions", callback = self.sendIf) OWGUI.checkBox(box, self, "appendProbabilities", "Append predicted class probabilities", callback = self.sendIf) applyButton = OWGUI.button(box, self, "Commit", callback = self.sendData, default=True) autoApplyCB = OWGUI.checkBox(box, self, "autoApply", "Commit automatically") OWGUI.setStopper(self, applyButton, autoApplyCB, "selectionDirty", self.sendData) import sip sip.delete(self.mainArea.layout()) self.layout = QGridLayout(self.mainArea) self.layout.addWidget(OWGUI.widgetLabel(self.mainArea, "Prediction"), 0, 1, Qt.AlignCenter) label = TransformedLabel("Correct Class") self.layout.addWidget(label, 2, 0, Qt.AlignCenter) # self.layout.addWidget(OWGUI.widgetLabel(self.mainArea, "Correct Class "), 2, 0, Qt.AlignCenter) self.table = OWGUI.table(self.mainArea, rows = 0, columns = 0, selectionMode = QTableWidget.MultiSelection, addToLayout = 0) self.layout.addWidget(self.table, 2, 1) self.layout.setColumnStretch(1, 100) self.layout.setRowStretch(2, 100) self.connect(self.table, SIGNAL("itemSelectionChanged()"), self.sendIf) self.res = None self.matrix = None self.selectedLearner = None self.resize(700,450)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "Regression Tree", wantMainArea = 0, resizingEnabled = 0) self.Name="Regression Tree" self.MinInstCheck=1 self.MinInstVal=5 self.MinNodeCheck=1 self.MinNodeVal=10 self.MaxMajCheck=1 self.MaxMajVal=70 self.PostMaj=1 self.PostMPCheck=1 self.PostMPVal=5 self.Bin=1 self.loadSettings() self.data=None self.preprocessor = None self.inputs=[("Data",ExampleTable,self.dataset), ("Preprocess", PreprocessedLearner, self.setPreprocessor)] self.outputs=[("Learner", orange.Learner), ("Regressor", orange.Classifier), ("Regression Tree", Orange.regression.tree.TreeClassifier)] ## #GUI ## OWGUI.lineEdit(self.controlArea, self, "Name", box="Learner/Classifier name") OWGUI.separator(self.controlArea) OWGUI.checkBox(self.controlArea, self, "Bin", label="Binarization", box ="Tree structure") OWGUI.separator(self.controlArea) self.prePBox=OWGUI.widgetBox(self.controlArea, "Pre-Pruning") #OWGUI.checkWithSpin(self.prePBox, self, "Min. instances in leaves: ", 1, 1000, # "MinInstCheck", "MinInstVal") OWGUI.checkWithSpin(self.prePBox, self, "Do not split nodes with less instances than", 1, 1000, "MinNodeCheck", "MinNodeVal") #OWGUI.checkWithSpin(self.prePBox, self, "Stop splitting nodes with ", 1, 100, # "MaxMajCheck", "MaxMajVal", "% of majority class") #OWGUI.checkBox(self.postPBox, self, 'PostMaj', 'Recursively merge leaves with same majority class') OWGUI.separator(self.controlArea) self.postPBox=OWGUI.widgetBox(self.controlArea, "Post-Pruning") OWGUI.checkWithSpin(self.postPBox, self, "Pruning with m-estimate, m:", 0, 1000, 'PostMPCheck', 'PostMPVal') OWGUI.button(self.controlArea, self, "&Apply settings", callback=self.setLearner, default=True) OWGUI.rubber(self.controlArea) self.setLearner() self.resize(100,100)
def __init__(self,parent=None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "Calibration Plot", 1) # inputs self.inputs=[("Evaluation Results", orngTest.ExperimentResults, self.results, Default)] #set default settings self.CalibrationCurveWidth = 3 self.ShowDiagonal = TRUE self.ShowRugs = TRUE #load settings self.loadSettings() # temp variables self.dres = None self.targetClass = None self.numberOfClasses = 0 self.graphs = [] self.classifierColor = None self.numberOfClassifiers = 0 self.classifiers = [] self.selectedClassifiers = [] # GUI import sip sip.delete(self.mainArea.layout()) self.graphsGridLayoutQGL = QGridLayout(self.mainArea) self.mainArea.setLayout(self.graphsGridLayoutQGL) ## save each ROC graph in separate file self.graph = None self.connect(self.graphButton, SIGNAL("clicked()"), self.saveToFile) ## general tab self.tabs = OWGUI.tabWidget(self.controlArea) self.generalTab = OWGUI.createTabPage(self.tabs, "General") self.settingsTab = OWGUI.createTabPage(self.tabs, "Settings") self.splitQS = QSplitter() self.splitQS.setOrientation(Qt.Vertical) ## target class self.classCombo = OWGUI.comboBox(self.generalTab, self, 'targetClass', box='Target class', items=[], callback=self.target) OWGUI.separator(self.generalTab) ## classifiers selection (classifiersQLB) self.classifiersQVGB = OWGUI.widgetBox(self.generalTab, "Classifiers") self.classifiersQLB = OWGUI.listBox(self.classifiersQVGB, self, "selectedClassifiers", selectionMode = QListWidget.MultiSelection, callback = self.classifiersSelectionChange) self.unselectAllClassifiersQLB = OWGUI.button(self.classifiersQVGB, self, "(Un)select all", callback = self.SUAclassifiersQLB) ## settings tab OWGUI.hSlider(self.settingsTab, self, 'CalibrationCurveWidth', box='Calibration Curve Width', minValue=1, maxValue=9, step=1, callback=self.setCalibrationCurveWidth, ticks=1) OWGUI.checkBox(self.settingsTab, self, 'ShowDiagonal', 'Show Diagonal Line', tooltip='', callback=self.setShowDiagonal) OWGUI.checkBox(self.settingsTab, self, 'ShowRugs', 'Show Rugs', tooltip='', callback=self.setShowRugs) self.settingsTab.layout().addStretch(100)
def __init__(self, parent=None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "Predictions") self.callbackDeposit = [] self.inputs = [("Examples", ExampleTable, self.setData), ("Predictors", orange.Classifier, self.setPredictor, Multiple)] self.outputs = [("Predictions", ExampleTable)] self.predictors = {} # saveble settings self.ShowAttributeMethod = 0 self.classes = [] self.selectedClasses = [] self.loadSettings() self.datalabel = "N/A" self.predictorlabel = "N/A" self.tasklabel = "N/A" self.outvar = None # current output variable (set by the first predictor/data set send in) self.classifications = [] self.rindx = None self.data = None self.verbose = 0 self.nVarImportance = 0 # GUI - Options # Options - classification ibox = OWGUI.widgetBox(self.controlArea, "Info") OWGUI.label(ibox, self, "Data: %(datalabel)s") OWGUI.label(ibox, self, "Predictors: %(predictorlabel)s") OWGUI.label(ibox, self, "Task: %(tasklabel)s") OWGUI.separator(ibox) OWGUI.label(ibox, self, "Predictions can be viewed with the 'Data Table'\nand saved with the 'Save' widget!") OWGUI.separator(self.controlArea) self.copt = OWGUI.widgetBox(self.controlArea,"Probabilities (classification)") self.copt.setDisabled(1) self.lbcls = OWGUI.listBox(self.copt, self, "selectedClasses", "classes", selectionMode=QListWidget.MultiSelection) self.lbcls.setFixedHeight(50) OWGUI.separator(self.controlArea) self.VarImportanceBox = OWGUI.doubleSpin(self.controlArea, self, "nVarImportance", 0,9999999,1, label="Variable importance", orientation="horizontal", tooltip="The number of variables to report for each prediction.") OWGUI.checkBox(self.controlArea, self, 'verbose', 'Verbose', tooltip='Show detailed info while predicting. This will slow down the predictions process!') OWGUI.separator(self.controlArea) self.outbox = OWGUI.widgetBox(self.controlArea,"Output") self.apply = OWGUI.button(self.outbox, self, "Apply", callback=self.sendpredictions) OWGUI.rubber(self.controlArea) self.adjustSize()
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 defineGUI(self): # Set the number of hidden neurons throught the GUI OWGUI.lineEdit(self.controlArea, self, 'name', box='Learner/Classifier Name', \ tooltip='Name to be used by other widgets to identify your learner/classifier.<br>This should be a unique name!') OWGUI.lineEdit(self.controlArea, self, 'nHiddenGUI', box='The number of hidden neurons', \ tooltip='The number of neurons in each hidden layer should be given as a comma separated string. \n\ For example, 2,3,4 will create 3 hidden layers (5 layers in total, including in and out),\n\ with 2, 3 and 4 neurons respectively. If no value is given, the default, which is one layer of 5 neurons, \n\ will be used. ') # Set the training function throught the GUI # CVANNOPTALGDICT = {"FANN_TRAIN_BACKPROP":0, "FANN_TRAIN_RPROP":1} self.trainingBox=b=OWGUI.widgetBox(self.controlArea,"Training function") self.trainingRadio = OWGUI.radioButtonsInBox(b, self, "optAlgGUI", btnLabels= \ ["TRAIN_BACKPROP - Backpropagation", \ "TRAIN_RPROP - iRPROP algorithm (Recommended)"],callback = self.changedOptAlg) #CVANNSTOPCRITDICT = {"ITER":1, "EPS":2} sc = OWGUI.widgetBox(self.controlArea,"Stop criteria") self.trainingRadio = OWGUI.radioButtonsInBox(sc, self, "stopCritGUI", btnLabels= \ ["Max number of Iterations", \ "Epsilon"], callback = self.OnChangedStopCrit) OWGUI.lineEdit(OWGUI.indentedBox(sc), self, 'stopValueGUI', 'Value:', orientation="horizontal", tooltip="Value to use as stop Criteria") self.priorBox = OWGUI.lineEdit(b, self, 'priorsGUI', box='Class weights', \ tooltip='Ex: POS:2 , NEG:1') b=OWGUI.widgetBox(self.controlArea, "Scaling", addSpace = True) self.scaleDataBox=OWGUI.checkBox(b, self, "scaleDataGUI", "Scale Data", tooltip="Scales the training data, and the input examples",callback = self.setLearnerVars) self.scaleClassBox=OWGUI.checkBox(b, self, "scaleClassGUI", "Scale Class variable", tooltip="Scales the class variable of training data, and the output predictions",callback = self.setLearnerVars) # Apply the settings and send the learner to the output channel OWGUI.button(self.controlArea, self,"&Apply settings", callback=self.applySettings) # Get desired location of model file boxFile = OWGUI.widgetBox(self.controlArea, "Path for saving Model", addSpace = True, orientation=0) L1 = OWGUI.lineEdit(boxFile, self, "modelFile", labelWidth=80, orientation = "horizontal", \ tooltip = "Once a model is created (connect this widget with a data widget), \nit can be saved by giving a \ file name here and clicking the save button.\nPlease observe that model names should not contain an extention.") L1.setMinimumWidth(200) button = OWGUI.button(boxFile, self, '...', callback = self.browseFile, disabled=0,tooltip = "Choose the dir where to save. After chosen, add a name for the model file!") button.setMaximumWidth(25) # Save the model OWGUI.button(self.controlArea, self,"&Save model to file", callback=self.saveModel) self.setLearnerVars() self.applySettings() self.adjustSize()
def __init__ (self, parent=None, signalManager = None, name = "Logistic regression"): OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0, resizingEnabled = 0) self.inputs = [("Data", ExampleTable, self.setData), ("Preprocess", PreprocessedLearner, self.setPreprocessor)] self.outputs = [("Learner", orange.Learner), ("Classifier", orange.Classifier), ("Features", list)] self.regularizations = [ Orange.classification.logreg.LibLinearLogRegLearner.L2R_LR, Orange.classification.logreg.LibLinearLogRegLearner.L1R_LR ] self.regularizationsStr = [ "L2 (squared weights)", "L1 (absolute weights)" ] self.name = "Logistic regression" self.normalization = True self.C = 1. self.regularization = 0 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, "Regularization") self.regularizationCombo = OWGUI.comboBox(box, self, "regularization", items=self.regularizationsStr) cset = OWGUI.doubleSpin(box, self, "C", 0.01, 512.0, 0.1, decimals=2, addToLayout=True, label="Training error cost (C)", alignment=Qt.AlignRight, tooltip= "Weight of log-loss term (higher C means better fit on the training data)."), OWGUI.separator(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Preprocessing") OWGUI.checkBox(box, self, "normalization", label="Normalize data", tooltip="Normalize data before learning.") OWGUI.separator(self.controlArea) applyButton = OWGUI.button(self.controlArea, self, "&Apply", callback=self.applyLearner, default=True) OWGUI.rubber(self.controlArea) #self.adjustSize() self.applyLearner()
def __init__(self,parent=None, signalManager = None, name = "Continuizer"): OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0) self.inputs = [("Data", ExampleTable, self.setData)] self.outputs = [("Data", ExampleTable), ("Preprocessor", PreprocessedLearner)] self.multinomialTreatment = 0 self.targetValue = 0 self.continuousTreatment = 0 self.classTreatment = 0 self.zeroBased = 1 self.autosend = 0 self.dataChanged = False self.loadSettings() bgMultiTreatment = OWGUI.widgetBox(self.controlArea, "Multinomial attributes") OWGUI.radioButtonsInBox(bgMultiTreatment, self, "multinomialTreatment", btnLabels=[x[0] for x in self.multinomialTreats], callback=self.sendDataIf) self.controlArea.layout().addSpacing(4) bgMultiTreatment = OWGUI.widgetBox(self.controlArea, "Continuous attributes") OWGUI.radioButtonsInBox(bgMultiTreatment, self, "continuousTreatment", btnLabels=[x[0] for x in self.continuousTreats], callback=self.sendDataIf) self.controlArea.layout().addSpacing(4) bgClassTreatment = OWGUI.widgetBox(self.controlArea, "Discrete class attribute") self.ctreat = OWGUI.radioButtonsInBox(bgClassTreatment, self, "classTreatment", btnLabels=[x[0] for x in self.classTreats], callback=self.sendDataIf) # hbox = OWGUI.widgetBox(bgClassTreatment, orientation = "horizontal") # OWGUI.separator(hbox, 19, 4) hbox = OWGUI.indentedBox(bgClassTreatment, sep=OWGUI.checkButtonOffsetHint(self.ctreat.buttons[-1]), orientation="horizontal") self.cbTargetValue = OWGUI.comboBox(hbox, self, "targetValue", label="Target Value ", items=[], orientation="horizontal", callback=self.cbTargetSelected) def setEnabled(*args): self.cbTargetValue.setEnabled(self.classTreatment == 3) self.connect(self.ctreat.group, SIGNAL("buttonClicked(int)"), setEnabled) setEnabled() self.controlArea.layout().addSpacing(4) zbbox = OWGUI.widgetBox(self.controlArea, "Value range") OWGUI.radioButtonsInBox(zbbox, self, "zeroBased", btnLabels=self.valueRanges, callback=self.sendDataIf) self.controlArea.layout().addSpacing(4) snbox = OWGUI.widgetBox(self.controlArea, "Send data") OWGUI.button(snbox, self, "Send data", callback=self.sendData, default=True) OWGUI.checkBox(snbox, self, "autosend", "Send automatically", callback=self.enableAuto) self.data = None self.sendPreprocessor() self.resize(150,300)
def __init__(self, parent=None, signalManager=None, title="Add row ids"): OWWidget.__init__(self, parent, signalManager, title, wantMainArea=False) self.inputs = [("Data", Orange.data.Table, self.set_table)] self.outputs = [("Data", Orange.data.Table)] self.use_guid = False OWGUI.checkBox(self.controlArea, self, "use_guid", label="Use unique global identifiers", tooltip="Use unique global identifiers. Identifiers will\ be unique across all widget istances and orange sessions.", callback=self.commit ) self.table = None
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, '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 defineGUI(self): OWGUI.lineEdit(self.controlArea, self, 'name', box='Learner/Classifier Name', \ tooltip='Name to be used by other widgets to identify your learner/classifier.<br>This should be a unique name!') OWGUI.separator(self.controlArea, 0, 30) self.bBox = self.controlArea# QGroupBox('Model parameters for the Random Forest algorithm',self.controlArea) #self.bBox.setTitle('Model parameters for the Random Forest algorithm') OWGUI.lineEdit(self.bBox, self, 'nActVars', box='The number of active attributes', \ tooltip='The number of randomly sampled attributes at each node.\nThe default value 0, sets the number of samples \nto the square root of the total number of samples.') OWGUI.lineEdit(self.bBox, self, 'maxDepth', box='Maximum branching depth.', \ tooltip='The maximal number of nodes along one branch') OWGUI.lineEdit(self.bBox, self, 'minSample', box='Minimum number of samples', \ tooltip='The number of samples at which to stop branching.') self.trainingBox=b=QButtonGroup(self.bBox)#"Termination criteria", self.bBox) self.trainingBox=b=OWGUI.widgetBox(self.bBox, "Termination criteria") self.trainingRadio = OWGUI.radioButtonsInBox(b, self, "termCrit", btnLabels= \ ["Number of trees in the forest", "Out of bag error to achive before termination "]) OWGUI.lineEdit(self.bBox, self, 'nTrees', box='The number of trees', \ tooltip='This is the termination criteria used if "Number of trees in the forest" is checked') OWGUI.lineEdit(self.bBox, self, 'forestAcc', box='OOB error', \ tooltip='This is the termination criteria used if "Out of bag error" is checked') self.priorBox = OWGUI.lineEdit(self.bBox, self, 'priorsGUI', box='Class weights ', \ tooltip='Ex: POS:0.8 , NEG:0.2') #OWGUI.separator(self.bBox, 0, 5) #OWGUI.checkBox(self.bBox, self, 'stratify','Stratify', tooltip='Stratify?') OWGUI.checkBox(self.bBox, self, 'useBuiltInMissValHandling','Use surrogate nodes for missing value handling', tooltip='Use the RF built in missing value handling (as originally implemented by Breiman and Cutler) instead of the AZorange imputer. The training will be more time consuming and the model larger.') # Apply the settings and send the learner to the output channel OWGUI.button(self.controlArea, self,"&Apply settings", callback=self.applySettings) # Get desired location of model file boxFile = OWGUI.widgetBox(self.controlArea, "Path for saving Model", addSpace = True, orientation=0) L1 = OWGUI.lineEdit(boxFile, self, "modelFile", labelWidth=80, orientation = "horizontal", \ tooltip = "Once a model is created (connect this widget with a data widget), \nit can be saved by giving a \ file name here and clicking the save button.\nPlease observe that model names should not contain an extention.") L1.setMinimumWidth(200) button = OWGUI.button(boxFile, self, '...', callback = self.browseFile, disabled=0,tooltip = "Choose the dir where to save. After chosen, add a name for the model file!") button.setMaximumWidth(25) # Save the model OWGUI.button(self.controlArea, self,"&Save model to file", callback=self.saveModel) self.resize(200,400)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self,parent,signalManager,"FeatureSelection") self.inputs = [("Example Table", ExampleTable, self.dataset)] self.outputs = [("Example Table", ExampleTable)] warnings.filterwarnings("ignore", "", orange.AttributeWarning) self.data = None self.chosenMeasure = [0] self.measures = ['Term frequency', 'Random', 'Term document frequency', 'Word frequency', 'Number of features'] self.chosenOp = [0] self.measureDict = {0: 'TF', 1: 'RAND', 2: 'TDF', 3: 'WF', 4: 'NF'} self.operators = ['MIN', 'MAX'] self.tmpData = None self.perc = 1 self.threshold = 90 self.selections = [] #GUI #ca=QFrame(self.controlArea) #gl=QGridLayout(ca) selectionbox = OWGUI.widgetBox(self.controlArea, "Feature selection", "horizontal") #OWGUI.QHGroupBox('Feature selection', self.controlArea) OWGUI.listBox(selectionbox, self, 'chosenMeasure', 'measures', box = 'Select measure', callback = self.selectionChanged) OWGUI.listBox(selectionbox, self, 'chosenOp', 'operators', box = 'Select operator', callback = self.selectionChanged) boxAttrStat = OWGUI.widgetBox(self.controlArea, "Statistics for features") #QVGroupBox("Statistics for features", self.controlArea) self.lblFeatNo = OWGUI.widgetLabel(boxAttrStat, "No. of features: ") #QLabel("No. of features: ", boxAttrStat) self.lblMin = OWGUI.widgetLabel(boxAttrStat, "Min: ") #QLabel("Min: ", boxAttrStat) self.lblAvg = OWGUI.widgetLabel(boxAttrStat, "Avg: ") #QLabel("Avg: ", boxAttrStat) self.lblMax = OWGUI.widgetLabel(boxAttrStat, "Max: ") #QLabel("Max: ", boxAttrStat) boxDocStat = OWGUI.widgetBox(self.controlArea, "Statistics for documents") #QVGroupBox("Statistics for documents", self.controlArea) self.lblDocNo = OWGUI.widgetLabel(boxDocStat, "No. of documents: ") #QLabel("No. of documents: ", boxDocStat) self.lblDocAvg = OWGUI.widgetLabel(boxDocStat, "Avg: ") #QLabel("Avg: ", boxDocStat) self.lblDocMax = OWGUI.widgetLabel(boxDocStat, "Max: ") #QLabel("Max: ", boxDocStat) self.lblDocMin = OWGUI.widgetLabel(boxDocStat, "Min: ") #QLabel("Min: ", boxDocStat) optionBox = OWGUI.widgetBox(selectionbox, "") #OWGUI.QVGroupBox('', selectionbox) self.applyButton = OWGUI.button(optionBox, self, "Apply", self.apply) self.applyButton.setDisabled(1) OWGUI.checkBox(optionBox, self, "perc", "percentage", callback = self.selectionChanged) #OWGUI.spin(optionBox, self, "threshold", 0, 10000, label="Threshold:", callback = None) OWGUI.lineEdit(optionBox, self, "threshold", orientation="horizontal", valueType=float, box="Threshold", callback = self.selectionChanged) OWGUI.rubber(self.controlArea) self.controlArea.adjustSize()
def __init__(self, parent=None): OWWidget.__init__(self, parent, 'Check') # GUI self.spinval = 10 self.chkA = 1 self.chkB = 0 self.dx = 15 box = OWGUI.widgetBox(self.controlArea, "Settings") gridbox = OWGUI.widgetBox(self.controlArea, "Grid Opions") gridbox.setEnabled(self.chkB) OWGUI.checkBox(box, self, "chkA", "Verbose") OWGUI.checkBox(box, self, "chkB", "Display Grid", disables=[gridbox]) OWGUI.spin(gridbox, self, "dx", 10, 20) self.resize(100,50)
def __init__(self, parent=None, signalManager = None, name='C4.5'): 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), ("Classification Tree", Orange.classification.tree.TreeClassifier)]#, ("C45 Tree", orange.C45Classifier)] # Settings self.name = 'C4.5' self.infoGain = 0; self.subset = 0; self.probThresh = 0; self.useMinObjs = 1; self.minObjs = 2; self.prune = 1; self.cf = 25 self.iterative = 0; self.manualWindow = 0; self.window = 50; self.manualIncrement = 0; self.increment = 10; self.trials = 10 self.convertToOrange = 1 self.loadSettings() self.data = None # input data set self.preprocessor = None # no preprocessing as default 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) self.wbSplit = OWGUI.widgetBox(self.controlArea, "Splitting") OWGUI.checkBox(self.wbSplit, self, 'infoGain', 'Use information gain instead of ratio (-g)') OWGUI.checkBox(self.wbSplit, self, 'subset', 'Subsetting (-s)') OWGUI.checkBox(self.wbSplit, self, 'probThresh', 'Probabilistic threshold for continuous attributes (-p)') OWGUI.separator(self.controlArea) self.wbPruning = OWGUI.widgetBox(self.controlArea, "Pruning") OWGUI.checkWithSpin(self.wbPruning, self, 'Minimal examples in leaves (-m)', 1, 1000, 'useMinObjs', 'minObjs', '', 1, labelWidth = 225) OWGUI.checkWithSpin(self.wbPruning, self, 'Post pruning with confidence level (-cf) of ', 0, 100, 'prune', 'cf', '', 5, labelWidth = 225) OWGUI.separator(self.controlArea) self.wbIterative = OWGUI.widgetBox(self.controlArea, "Iterative generation") self.cbIterative = OWGUI.checkBox(self.wbIterative, self, 'iterative', 'Generate the tree iteratively (-i, -t, -w)') self.spTrial = OWGUI.spin(self.wbIterative, self, 'trials', 1, 30, 1, '', " Number of trials (-t)", orientation = "horizontal", labelWidth = 225) self.csWindow = OWGUI.checkWithSpin(self.wbIterative, self, "Manually set initial window size (-w) to ", 10, 1000, 'manualWindow', 'window', '', 10, labelWidth = 225) self.csIncrement = OWGUI.checkWithSpin(self.wbIterative, self, "Manually set window increment (-i) to ", 10, 1000, 'manualIncrement', 'increment', '', 10, labelWidth = 225) self.cbIterative.disables = [self.spTrial, self.csWindow, self.csIncrement] self.cbIterative.makeConsistent() # OWGUI.separator(self.controlArea) # OWGUI.checkBox(self.controlArea, self, 'convertToOrange', 'Convert to orange tree structure', box = 1) OWGUI.separator(self.controlArea) OWGUI.button(self.controlArea, self, "&Apply", callback = self.setLearner, disabled=0, default=True) OWGUI.rubber(self.controlArea) self.setLearner()
def __init__(self, parent=None, signalManager = None, name='sift'): OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0) self.callbackDeposit = [] self.inputs = [("Images PIL", SeqContainer, self.setData)] self.outputs = [("Descriptors", SeqContainer)] # Settings self.name = name self.sift = None self.useLazyEvaluation = armor.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, 'Network Clustering') self.inputs = [("Network", orngNetwork.Network, self.setNetwork, Default)] self.outputs = [("Network", orngNetwork.Network)] self.net = None self.method = 0 self.iterationHistory = 0 self.autoApply = 0 self.loadSettings() ribg = OWGUI.radioButtonsInBox(self.controlArea, self, "method", [], "Method", callback = self.cluster) OWGUI.appendRadioButton(ribg, self, "method", "Label propagation clustering (Raghavan et al., 2007)", callback = self.cluster) OWGUI.checkBox(OWGUI.indentedBox(ribg), self, "iterationHistory", "Append clustering data on each iteration", callback = self.cluster) self.info = OWGUI.widgetLabel(self.controlArea, ' ') autoApplyCB = OWGUI.checkBox(self.controlArea, self, "autoApply", "Commit automatically") OWGUI.button(self.controlArea, self, "Commit", callback=self.cluster)
def __init__(self, parent=None, signalManager=None): #OWWidget.__init__(self, parent, 'Hierarchical Clustering') OWWidget.__init__(self, parent, signalManager, 'Hierarchical Clustering', wantGraph=True) self.inputs = [("Distance matrix", orange.SymMatrix, self.dataset)] self.outputs = [("Selected Examples", ExampleTable), ("Unselected Examples", ExampleTable), ("Centroids", ExampleTable), ("Structured Data Files", DataFiles)] self.linkage = [ ("Single linkage", orange.HierarchicalClustering.Single), ("Average linkage", orange.HierarchicalClustering.Average), ("Ward's linkage", orange.HierarchicalClustering.Ward), ("Complete linkage", orange.HierarchicalClustering.Complete), ] self.Linkage = 3 self.OverwriteMatrix = 0 self.Annotation = 0 self.Brightness = 5 self.PrintDepthCheck = 0 self.PrintDepth = 100 self.HDSize = 500 #initial horizontal and vertical dendrogram size self.VDSize = 800 self.ManualHorSize = 0 self.AutoResize = 0 self.TextSize = 8 self.LineSpacing = 4 self.SelectionMode = 0 self.ZeroOffset = 1 self.DisableHighlights = 0 self.DisableBubble = 0 self.ClassifySelected = 0 self.CommitOnChange = 0 self.ClassifyName = "HC_class" self.loadSettings() self.AutoResize = False self.inputMatrix = None self.matrixSource = "Unknown" self.rootCluster = None self.selectedExamples = None self.ctrlPressed = FALSE self.addIdAs = 0 self.settingsChanged = False self.linkageMethods = [a[0] for a in self.linkage] ################################# ##GUI ################################# #Tabs ## self.tabs = OWGUI.tabWidget(self.controlArea) ## self.settingsTab = OWGUI.createTabPage(self.tabs, "Settings") ## self.selectionTab= OWGUI.createTabPage(self.tabs, "Selection") #HC Settings OWGUI.comboBox(self.controlArea, self, "Linkage", box="Linkage", items=self.linkageMethods, tooltip="Choose linkage method", callback=self.constructTree, addSpace=True) #Label box = OWGUI.widgetBox(self.controlArea, "Annotation", addSpace=True) self.labelCombo = OWGUI.comboBox(box, self, "Annotation", items=["None"], tooltip="Choose label attribute", callback=self.updateLabel) OWGUI.spin(box, self, "TextSize", label="Text size", min=5, max=15, step=1, callback=self.applySettings, controlWidth=40) OWGUI.spin(box, self, "LineSpacing", label="Line spacing", min=2, max=8, step=1, callback=self.applySettings, controlWidth=40) # OWGUI.checkBox(box, self, "DisableBubble", "Disable bubble info") #Dendrogram graphics settings dendrogramBox = OWGUI.widgetBox(self.controlArea, "Limits", addSpace=True) #OWGUI.spin(dendrogramBox, self, "Brightness", label="Brigthtness",min=1,max=9,step=1) form = QFormLayout() form.setLabelAlignment(Qt.AlignLeft) sw = OWGUI.widgetBox(dendrogramBox, orientation="horizontal", addToLayout=False) #QWidget(dendrogramBox) cw = OWGUI.widgetBox(dendrogramBox, orientation="horizontal", addToLayout=False) #QWidget(dendrogramBox) sllp = OWGUI.hSlider(sw, self, "PrintDepth", minValue=1, maxValue=50, callback=self.applySettings) cblp = OWGUI.checkBox(cw, self, "PrintDepthCheck", "Show to depth", callback=self.applySettings, disables=[sw]) form.addRow(cw, sw) # dendrogramBox.layout().addLayout(form) # box = OWGUI.widgetBox(dendrogramBox, orientation=form) option = QStyleOptionButton() cblp.initStyleOption(option) checkWidth = cblp.style().subElementRect(QStyle.SE_CheckBoxContents, option, cblp).x() # ib = OWGUI.indentedBox(dendrogramBox, orientation = 0) # ib = OWGUI.widgetBox(dendrogramBox, margin=0) # ib.layout().setContentsMargins(checkWidth, 5, 5, 5) # OWGUI.widgetLabel(ib, "Depth"+ " ") # slpd = OWGUI.hSlider(ib, self, "PrintDepth", minValue=1, maxValue=50, label="Depth ", callback=self.applySettings) # cblp.disables.append(ib) # cblp.makeConsistent() # OWGUI.separator(dendrogramBox) #OWGUI.spin(dendrogramBox, self, "VDSize", label="Vertical size", min=100, # max=10000, step=10) # form = QFormLayout() sw = OWGUI.widgetBox(dendrogramBox, orientation="horizontal", addToLayout=False) #QWidget(dendrogramBox) cw = OWGUI.widgetBox(dendrogramBox, orientation="horizontal", addToLayout=False) #QWidget(dendrogramBox) hsb = OWGUI.spin(sw, self, "HDSize", min=200, max=10000, step=10, callback=self.applySettings, callbackOnReturn=False) cbhs = OWGUI.checkBox(cw, self, "ManualHorSize", "Horizontal size", callback=self.applySettings, disables=[sw]) # ib = OWGUI.widgetBox(dendrogramBox, margin=0) # self.hSizeBox=OWGUI.spin(ib, self, "HDSize", label="Size"+" ", min=200, # max=10000, step=10, callback=self.applySettings, callbackOnReturn = True, controlWidth=45) # self.hSizeBox.layout().setContentsMargins(checkWidth, 5, 5, 5) self.hSizeBox = hsb form.addRow(cw, sw) dendrogramBox.layout().addLayout(form) # cbhs.disables.append(self.hSizeBox) # cbhs.makeConsistent() #OWGUI.checkBox(dendrogramBox, self, "ManualHorSize", "Fit horizontal size") #OWGUI.checkBox(dendrogramBox, self, "AutoResize", "Auto resize") box = OWGUI.widgetBox(self.controlArea, "Selection") OWGUI.checkBox(box, self, "SelectionMode", "Show cutoff line", callback=self.updateCutOffLine) cb = OWGUI.checkBox(box, self, "ClassifySelected", "Append cluster IDs", callback=self.commitDataIf) # self.classificationBox = ib = OWGUI.indentedBox(box, sep=0) self.classificationBox = ib = OWGUI.widgetBox(box, margin=0) form = QWidget() le = OWGUI.lineEdit(form, self, "ClassifyName", None, callback=None, orientation="horizontal") self.connect(le, SIGNAL("editingFinished()"), self.commitDataIf) # le_layout.addWidget(le.placeHolder) # OWGUI.separator(ib, height = 4) aa = OWGUI.comboBox( form, self, "addIdAs", label=None, orientation="horizontal", items=["Class attribute", "Attribute", "Meta attribute"], callback=self.commitDataIf) layout = QFormLayout() layout.setSpacing(8) layout.setContentsMargins(0, 5, 0, 5) layout.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow) layout.setLabelAlignment(Qt.AlignLeft) # | Qt.AlignJustify) layout.addRow("Name ", le) layout.addRow("Place ", aa) form.setLayout(layout) ib.layout().addWidget(form) ib.layout().setContentsMargins(checkWidth, 5, 5, 5) cb.disables.append(ib) cb.makeConsistent() OWGUI.separator(box) cbAuto = OWGUI.checkBox(box, self, "CommitOnChange", "Commit on change") btCommit = OWGUI.button(box, self, "&Commit", self.commitData) OWGUI.setStopper(self, btCommit, cbAuto, "settingsChanged", self.commitData) OWGUI.rubber(self.controlArea) # OWGUI.button(self.controlArea, self, "&Save Graph", self.saveGraph, debuggingEnabled = 0) self.connect(self.graphButton, SIGNAL("clicked()"), self.saveGraph) scale = QGraphicsScene(self) self.headerView = ScaleView(self, scale, self.mainArea) self.footerView = ScaleView(self, scale, self.mainArea) self.dendrogram = Dendrogram(self) self.dendrogramView = DendrogramView(self.dendrogram, self.mainArea) self.connect(self.dendrogram, SIGNAL("sceneRectChanged(QRectF)"), self.footerView.sceneRectUpdated) self.mainArea.layout().addWidget(self.headerView) self.mainArea.layout().addWidget(self.dendrogramView) self.mainArea.layout().addWidget(self.footerView) self.dendrogram.header = self.headerView self.dendrogram.footer = self.footerView self.connect(self.dendrogramView.horizontalScrollBar(), SIGNAL("valueChanged(int)"), self.footerView.horizontalScrollBar().setValue) self.connect(self.dendrogramView.horizontalScrollBar(), SIGNAL("valueChanged(int)"), self.headerView.horizontalScrollBar().setValue) self.dendrogram.setSceneRect(0, 0, self.HDSize, self.VDSize) self.dendrogram.update() self.resize(800, 500) self.matrix = None self.selectionList = []
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "Survey Plot", TRUE) self.inputs = [("Data", ExampleTable, self.setData, Default), ("Features", AttributeList, self.setShownAttributes)] self.outputs = [("Features", AttributeList)] #add a graph widget self.graph = OWSurveyPlotGraph(self.mainArea) self.mainArea.layout().addWidget(self.graph) self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile) #set default settings self.data = None self.showAllAttributes = 0 self.graph.exampleTracking = 0 self.graph.enabledLegend = 1 self.graph.tooltipKind = 1 self.attributeSelectionList = None self.graphCanvasColor = str(QColor(Qt.white).name()) self.primaryAttribute = "(None)" self.secondaryAttribute = "(None)" self.colorSettings = None self.selectedSchemaIndex = 0 #load settings self.loadSettings() #GUI self.tabs = OWGUI.tabWidget(self.controlArea) self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main") self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings") #add controls to self.controlArea widget self.sortingAttrGB = OWGUI.widgetBox(self.GeneralTab, "Sorting") self.primaryAttrCombo = OWGUI.comboBoxWithCaption( self.sortingAttrGB, self, "primaryAttribute", label='1st:', items=["(None)"], sendSelectedValue=1, valueType=str, callback=self.sortingClick, labelWidth=25) self.secondaryAttrCombo = OWGUI.comboBoxWithCaption( self.sortingAttrGB, self, "secondaryAttribute", label='2nd:', items=["(None)"], sendSelectedValue=1, valueType=str, callback=self.sortingClick, labelWidth=25) self.createShowHiddenLists(self.GeneralTab, callback=self.updateGraph) # ################################## # survey plot settings box = OWGUI.widgetBox(self.SettingsTab, "Visual settings") OWGUI.checkBox(box, self, "graph.exampleTracking", "Example tracking", callback=self.updateGraph) OWGUI.checkBox(box, self, "graph.enabledLegend", "Show legend", callback=self.updateGraph) box = OWGUI.widgetBox(self.SettingsTab, "Tooltips settings") OWGUI.comboBox(box, self, "graph.tooltipKind", items=[ "Don't Show Tooltips", "Show Visible Attributes", "Show All Attributes" ], callback=self.updateGraph) self.colorButtonsBox = OWGUI.widgetBox(self.SettingsTab, "Colors", orientation="horizontal") OWGUI.button( self.colorButtonsBox, self, "Set Colors", self.setColors, tooltip= "Set the canvas background color, grid color and color palette for coloring continuous variables", debuggingEnabled=0) self.SettingsTab.layout().addStretch(100) self.icons = self.createAttributeIconDict() dlg = self.createColorDialog() self.graph.contPalette = dlg.getContinuousPalette("contPalette") self.graph.discPalette = dlg.getDiscretePalette("discPalette") self.graph.setCanvasBackground(dlg.getColor("Canvas")) self.graph.gridCurve.setPen(QPen(dlg.getColor("Grid"))) #self.graph.setCanvasBackground(QColor(self.graphCanvasColor)) self.cbShowAllAttributes() self.resize(750, 700)
def __init__(self, parent=None, signalManager=None, name="Interactive Discretization"): OWWidget.__init__(self, parent, signalManager, name) self.showBaseLine=1 self.showLookaheadLine=1 self.showTargetClassProb=1 self.showRug=0 self.snap=1 self.measure=0 self.targetClass=0 self.discretization = self.classDiscretization = self.indiDiscretization = 1 self.intervals = self.classIntervals = self.indiIntervals = 3 self.outputOriginalClass = True self.indiData = [] self.indiLabels = [] self.resetIndividuals = 0 self.customClassSplits = "" self.selectedAttr = 0 self.customSplits = ["", "", ""] self.autoApply = True self.dataChanged = False self.autoSynchronize = True self.pointsChanged = False self.customLineEdits = [] self.needsDiscrete = [] self.data = self.originalData = None self.loadSettings() self.inputs=[("Data", ExampleTable, self.setData)] self.outputs=[("Data", ExampleTable)] self.measures=[("Information gain", orange.MeasureAttribute_info()), #("Gain ratio", orange.MeasureAttribute_gainRatio), ("Gini", orange.MeasureAttribute_gini()), ("chi-square", orange.MeasureAttribute_chiSquare()), ("chi-square prob.", orange.MeasureAttribute_chiSquare(computeProbabilities=1)), ("Relevance", orange.MeasureAttribute_relevance()), ("ReliefF", orange.MeasureAttribute_relief())] self.discretizationMethods=["Leave continuous", "Entropy-MDL discretization", "Equal-frequency discretization", "Equal-width discretization", "Remove continuous attributes"] self.classDiscretizationMethods=["Equal-frequency discretization", "Equal-width discretization"] self.indiDiscretizationMethods=["Default", "Leave continuous", "Entropy-MDL discretization", "Equal-frequency discretization", "Equal-width discretization", "Remove attribute"] self.mainHBox = OWGUI.widgetBox(self.mainArea, orientation=0) vbox = self.controlArea box = OWGUI.radioButtonsInBox(vbox, self, "discretization", self.discretizationMethods[:-1], "Default discretization", callback=[self.clearLineEditFocus, self.defaultMethodChanged]) self.needsDiscrete.append(box.buttons[1]) box.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)) indent = OWGUI.checkButtonOffsetHint(self.needsDiscrete[-1]) self.interBox = OWGUI.widgetBox(OWGUI.indentedBox(box, sep=indent)) OWGUI.widgetLabel(self.interBox, "Number of intervals (for equal width/frequency)") OWGUI.separator(self.interBox, height=4) self.intervalSlider=OWGUI.hSlider(OWGUI.indentedBox(self.interBox), self, "intervals", None, 2, 10, callback=[self.clearLineEditFocus, self.defaultMethodChanged]) OWGUI.appendRadioButton(box, self, "discretization", self.discretizationMethods[-1]) OWGUI.separator(vbox) ribg = OWGUI.radioButtonsInBox(vbox, self, "resetIndividuals", ["Use default discretization for all attributes", "Explore and set individual discretizations"], "Individual attribute treatment", callback = self.setAllIndividuals) ll = QWidget(ribg) ll.setFixedHeight(1) OWGUI.widgetLabel(ribg, "Set discretization of all attributes to") hcustbox = OWGUI.widgetBox(OWGUI.indentedBox(ribg), 0, 0) for c in range(1, 4): OWGUI.appendRadioButton(ribg, self, "resetIndividuals", "Custom %i" % c, insertInto = hcustbox) OWGUI.separator(vbox) box = self.classDiscBox = OWGUI.radioButtonsInBox(vbox, self, "classDiscretization", self.classDiscretizationMethods, "Class discretization", callback=[self.clearLineEditFocus, self.classMethodChanged]) cinterBox = OWGUI.widgetBox(box) self.intervalSlider=OWGUI.hSlider(OWGUI.indentedBox(cinterBox, sep=indent), self, "classIntervals", None, 2, 10, callback=[self.clearLineEditFocus, self.classMethodChanged], label="Number of intervals") hbox = OWGUI.widgetBox(box, orientation = 0) OWGUI.appendRadioButton(box, self, "discretization", "Custom" + " ", insertInto = hbox) self.classCustomLineEdit = OWGUI.lineEdit(hbox, self, "customClassSplits", callback = self.classCustomChanged, focusInCallback = self.classCustomSelected) # Can't validate - need to allow spaces box.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)) OWGUI.separator(box) self.classIntervalsLabel = OWGUI.widgetLabel(box, "Current splits: ") OWGUI.separator(box) OWGUI.checkBox(box, self, "outputOriginalClass", "Output original class", callback = self.commitIf) OWGUI.widgetLabel(box, "("+"Widget always uses discretized class internally."+")") OWGUI.separator(vbox) #OWGUI.rubber(vbox) box = OWGUI.widgetBox(vbox, "Commit") applyButton = OWGUI.button(box, self, "Commit", callback = self.commit, default=True) autoApplyCB = OWGUI.checkBox(box, self, "autoApply", "Commit automatically", callback=[self.clearLineEditFocus]) OWGUI.setStopper(self, applyButton, autoApplyCB, "dataChanged", self.commit) OWGUI.rubber(vbox) #self.mainSeparator = OWGUI.separator(self.mainHBox, width=25) # space between control and main area self.mainIABox = OWGUI.widgetBox(self.mainHBox, "Individual attribute settings") self.mainBox = OWGUI.widgetBox(self.mainIABox, orientation=0) OWGUI.separator(self.mainIABox)#, height=30) graphBox = OWGUI.widgetBox(self.mainIABox, "", orientation=0) # self.needsDiscrete.append(graphBox) graphOptBox = OWGUI.widgetBox(graphBox) OWGUI.separator(graphBox, width=10) graphGraphBox = OWGUI.widgetBox(graphBox) self.graph = DiscGraph(self, graphGraphBox) graphGraphBox.layout().addWidget(self.graph) reportButton2 = OWGUI.button(graphGraphBox, self, "Report Graph", callback = self.reportGraph, debuggingEnabled=0) #graphOptBox.layout().setSpacing(4) box = OWGUI.widgetBox(graphOptBox, "Split gain measure", addSpace=True) self.measureCombo=OWGUI.comboBox(box, self, "measure", orientation=0, items=[e[0] for e in self.measures], callback=[self.clearLineEditFocus, self.graph.invalidateBaseScore, self.graph.plotBaseCurve]) OWGUI.checkBox(box, self, "showBaseLine", "Show discretization gain", callback=[self.clearLineEditFocus, self.graph.plotBaseCurve]) OWGUI.checkBox(box, self, "showLookaheadLine", "Show lookahead gain", callback=self.clearLineEditFocus) self.needsDiscrete.append(box) box = OWGUI.widgetBox(graphOptBox, "Target class", addSpace=True) self.targetCombo=OWGUI.comboBox(box, self, "targetClass", orientation=0, callback=[self.clearLineEditFocus, self.graph.targetClassChanged]) stc = OWGUI.checkBox(box, self, "showTargetClassProb", "Show target class probability", callback=[self.clearLineEditFocus, self.graph.plotProbCurve]) OWGUI.checkBox(box, self, "showRug", "Show rug (may be slow)", callback=[self.clearLineEditFocus, self.graph.plotRug]) self.needsDiscrete.extend([self.targetCombo, stc]) box = OWGUI.widgetBox(graphOptBox, "Editing", addSpace=True) OWGUI.checkBox(box, self, "snap", "Snap to grid", callback=[self.clearLineEditFocus]) syncCB = OWGUI.checkBox(box, self, "autoSynchronize", "Apply on the fly", callback=self.clearLineEditFocus) syncButton = OWGUI.button(box, self, "Apply", callback = self.synchronizePressed) OWGUI.setStopper(self, syncButton, syncCB, "pointsChanged", self.synchronize) OWGUI.rubber(graphOptBox) self.attrList = OWGUI.listBox(self.mainBox, self, callback = self.individualSelected) self.attrList.setItemDelegate(CustomListItemDelegate(self.attrList)) self.attrList.setFixedWidth(300) self.defaultMethodChanged() OWGUI.separator(self.mainBox, width=10) box = OWGUI.radioButtonsInBox(OWGUI.widgetBox(self.mainBox), self, "indiDiscretization", [], callback=[self.clearLineEditFocus, self.indiMethodChanged]) #hbbox = OWGUI.widgetBox(box) #hbbox.layout().setSpacing(4) for meth in self.indiDiscretizationMethods[:-1]: OWGUI.appendRadioButton(box, self, "indiDiscretization", meth) self.needsDiscrete.append(box.buttons[2]) self.indiInterBox = OWGUI.indentedBox(box, sep=indent, orientation = "horizontal") OWGUI.widgetLabel(self.indiInterBox, "Num. of intervals: ") self.indiIntervalSlider = OWGUI.hSlider(self.indiInterBox, self, "indiIntervals", None, 2, 10, callback=[self.clearLineEditFocus, self.indiMethodChanged], width = 100) OWGUI.rubber(self.indiInterBox) OWGUI.appendRadioButton(box, self, "indiDiscretization", self.indiDiscretizationMethods[-1]) #OWGUI.rubber(hbbox) #OWGUI.separator(box) #hbbox = OWGUI.widgetBox(box) for i in range(3): hbox = OWGUI.widgetBox(box, orientation = "horizontal") OWGUI.appendRadioButton(box, self, "indiDiscretization", "Custom %i" % (i+1) + " ", insertInto = hbox) le = OWGUI.lineEdit(hbox, self, "", callback = lambda w=i: self.customChanged(w), focusInCallback = lambda w=i: self.customSelected(w)) le.setFixedWidth(110) self.customLineEdits.append(le) OWGUI.toolButton(hbox, self, "CC", width=30, callback = lambda w=i: self.copyToCustom(w)) OWGUI.rubber(hbox) OWGUI.rubber(box) #self.controlArea.setFixedWidth(0) self.contAttrIcon = self.createAttributeIconDict()[orange.VarTypes.Continuous] self.setAllIndividuals()
def __init__(self, parent=None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "AssociationRulesViewer", wantMainArea=0, noReport=True) self.inputs = [("Association Rules", orange.AssociationRules, self.arules)] self.outputs = [("Association Rules", orange.AssociationRules)] self.supp_min, self.supp_max = self.conf_min, self.conf_max = 0., 1. self.numcols = self.numrows = 20 self.showBars = True self.cellwidth = self.cellheight = 18 for m in self.measures: setattr(self, m[2], False) self.support = self.confidence = True self.sortedBy = 0 self.autoSend = True self.loadSettings() self.rules = None self.selectedRules = [] self.noZoomButton() self.mainArea = OWGUI.widgetBox(self.topWidgetPart, orientation = "horizontal", sizePolicy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding), margin = 0) mainLeft = OWGUI.widgetBox(self.mainArea, "Filter") OWGUI.separator(self.mainArea, 16, 0) mainRight = OWGUI.widgetBox(self.mainArea, "Rules") mainRight.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) mainLeft.setSizePolicy(QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)) infoGrid = QGridLayout() info = OWGUI.widgetBox(mainLeft, orientation = infoGrid) infoGrid.addWidget(OWGUI.widgetLabel(info, "Shown", addToLayout = 0), 1, 0) infoGrid.addWidget(OWGUI.widgetLabel(info, "Selected", addToLayout = 0), 2, 0) infoGrid.addWidget(OWGUI.widgetLabel(info, "Support (H)", addToLayout = 0), 0, 1) infoGrid.addWidget(OWGUI.widgetLabel(info, "Confidence (V)", addToLayout = 0), 0, 2) infoGrid.addWidget(OWGUI.widgetLabel(info, "# Rules", addToLayout = 0), 0, 3) self.shownSupport = OWGUI.widgetLabel(info, " ", addToLayout = 0) infoGrid.addWidget(self.shownSupport, 1, 1) self.shownConfidence = OWGUI.widgetLabel(info, " ", addToLayout = 0) infoGrid.addWidget(self.shownConfidence, 1, 2) self.shownRules = OWGUI.widgetLabel(info, " ", addToLayout = 0) infoGrid.addWidget(self.shownRules, 1, 3) self.selSupport = OWGUI.widgetLabel(info, " ", addToLayout = 0) infoGrid.addWidget(self.selSupport, 2, 1) self.selConfidence = OWGUI.widgetLabel(info, " ", addToLayout = 0) infoGrid.addWidget(self.selConfidence, 2, 2) self.selRules = OWGUI.widgetLabel(info, " ", addToLayout = 0) infoGrid.addWidget(self.selRules, 2, 3) OWGUI.separator(mainLeft, 0, 4) self.ruleScene = AssociationRulesViewerScene(self, mainLeft) self.sceneView = AssociationRulesViewerView(self, self.ruleScene, mainLeft) mainLeft.layout().addWidget(self.sceneView) boxb = OWGUI.widgetBox(mainLeft, box=None, orientation="horizontal") OWGUI.button(boxb, self, 'Zoom', callback = self.zoomButton) OWGUI.button(boxb, self, 'Show All', callback = self.showAllButton) OWGUI.button(boxb, self, 'No Zoom', callback = self.noZoomButton) OWGUI.separator(boxb, 16, 8) OWGUI.button(boxb, self, 'Unselect', callback = self.unselect) self.grid = QGridLayout() rightUpRight = OWGUI.widgetBox(mainRight, orientation = self.grid) for i, m in enumerate(self.measures): cb = OWGUI.checkBox(rightUpRight, self, m[2], m[0], callback = self.showHideColumns, addToLayout = 0) self.grid.addWidget(cb, i % 2, i / 2) OWGUI.separator(mainRight, 0, 4) trules = self.trules = QTableWidget(0, 0, mainRight) mainRight.layout().addWidget(trules) trules.verticalHeader().hide() trules.setSelectionMode(QTableWidget.NoSelection) trules.setColumnCount(len(self.measures)+3) header = trules.horizontalHeader() trules.setHorizontalHeaderLabels([m[1] for m in self.measures]+["Antecedent", "->", "Consequent"]) trules.horizontalHeaderItem(len(self.measures)).setTextAlignment(Qt.AlignRight) trules.horizontalHeaderItem(len(self.measures)+2).setTextAlignment(Qt.AlignLeft) #trules.setItemDelegate(OWGUI.TableBarItem(self, trules)) trules.normalizers = [] bottomGrid = QGridLayout() bottom = OWGUI.widgetBox(mainRight, orientation = bottomGrid) self.reportButton = OWGUI.button(bottom, self, "&Report", self.reportAndFinish, addToLayout=0) # self.saveButton = OWGUI.button(bottom, self, "Save Rules", callback = self.saveRules, addToLayout=0) commitButton = OWGUI.button(bottom, self, "Send Rules", callback = self.sendRules, addToLayout=0) autoSend = OWGUI.checkBox(bottom, self, "autoSend", "Send rules automatically", disables=[(-1, commitButton)], addToLayout=0) autoSend.makeConsistent() bottomGrid.addWidget(self.reportButton, 1, 0) # bottomGrid.addWidget(self.saveButton, 1, 1) bottomGrid.addWidget(autoSend, 0, 1) bottomGrid.addWidget(commitButton, 1, 1) self.controlArea.setFixedSize(0, 0) self.resize(1000, 380)
def __init__(self, parent=None, signalManager=None, title="Edit Domain"): OWWidget.__init__(self, parent, signalManager, title) self.inputs = [("Data", Orange.data.Table, self.set_data)] self.outputs = [("Data", Orange.data.Table)] # Settings # Domain change hints maps from input variables description to # the modified variables description as returned by # `variable_description` function self.domain_change_hints = {} self.selected_index = 0 self.auto_commit = False self.changed_flag = False self.loadSettings() ##### # GUI ##### # The list of domain's variables. box = OWGUI.widgetBox(self.controlArea, "Domain Features") self.domain_view = QListView() self.domain_view.setSelectionMode(QListView.SingleSelection) self.domain_model = VariableListModel() self.domain_view.setModel(self.domain_model) self.connect( self.domain_view.selectionModel(), SIGNAL("selectionChanged(QItemSelection, QItemSelection)"), self.on_selection_changed) box.layout().addWidget(self.domain_view) # A stack for variable editor widgets. box = OWGUI.widgetBox(self.mainArea, "Edit Feature") self.editor_stack = QStackedWidget() box.layout().addWidget(self.editor_stack) box = OWGUI.widgetBox(self.controlArea, "Reset") OWGUI.button(box, self, "Reset selected", callback=self.reset_selected, tooltip="Reset changes made to the selected feature") OWGUI.button(box, self, "Reset all", callback=self.reset_all, tooltip="Reset all changes made to the domain") box = OWGUI.widgetBox(self.controlArea, "Commit") b = OWGUI.button( box, self, "&Commit", callback=self.commit, tooltip="Commit the data with the changed domain", ) cb = OWGUI.checkBox(box, self, "auto_commit", label="Commit automatically", tooltip="Commit the changed domain on any change", callback=self.commit_if) OWGUI.setStopper(self, b, cb, "changed_flag", callback=self.commit) self._editor_cache = {} self.resize(600, 500)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'k-Means Clustering') self.inputs = [("Data", ExampleTable, self.setData)] self.outputs = [("Data", ExampleTable), ("Centroids", ExampleTable)] #set default settings self.K = 2 self.optimized = True self.optimizationFrom = 2 self.optimizationTo = 5 self.scoring = 0 self.distanceMeasure = 0 self.initializationType = 0 self.restarts = 1 self.classifySelected = 1 self.addIdAs = 0 self.runAnyChange = 1 self.classifyName = "Cluster" self.settingsChanged = False self.loadSettings() self.data = None # holds input data self.km = None # holds clustering object # GUI definition # settings box = OWGUI.widgetBox(self.controlArea, "Clusters (k)", addSpace=True, spacing=0) # left, top, right, bottom = box.getContentsMargins() # box.setContentsMargins(left, 0, right, 0) bg = OWGUI.radioButtonsInBox(box, self, "optimized", [], callback=self.setOptimization) fixedBox = OWGUI.widgetBox(box, orientation="horizontal", margin=0, spacing=bg.layout().spacing()) button = OWGUI.appendRadioButton(bg, self, "optimized", "Fixed", insertInto=fixedBox, tooltip="Fixed number of clusters") button.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) fixedBox.layout().setAlignment(button, Qt.AlignLeft) self.fixedSpinBox = OWGUI.spin(OWGUI.widgetBox(fixedBox), self, "K", min=2, max=30, tooltip="Fixed number of clusters", callback=self.update, callbackOnReturn=True) optimizedBox = OWGUI.widgetBox(box, margin=0, spacing=bg.layout().spacing()) button = OWGUI.appendRadioButton(bg, self, "optimized", "Optimized", insertInto=optimizedBox) box = OWGUI.indentedBox(optimizedBox, sep=OWGUI.checkButtonOffsetHint(button)) box.layout().setSpacing(0) self.optimizationBox = box OWGUI.spin(box, self, "optimizationFrom", label="From", min=2, max=99, tooltip="Minimum number of clusters to try", callback=self.updateOptimizationFrom, callbackOnReturn=True) OWGUI.spin(box, self, "optimizationTo", label="To", min=3, max=100, tooltip="Maximum number of clusters to try", callback=self.updateOptimizationTo, callbackOnReturn=True) OWGUI.comboBox(box, self, "scoring", label="Scoring", orientation="horizontal", items=[m[0] for m in self.scoringMethods], callback=self.update) box = OWGUI.widgetBox(self.controlArea, "Settings", addSpace=True) OWGUI.comboBox(box, self, "distanceMeasure", label="Distance measures", items=[name for name, _ in self.distanceMeasures], tooltip=None, indent=20, callback=self.update) cb = OWGUI.comboBox(box, self, "initializationType", label="Initialization", items=[name for name, _ in self.initializations], tooltip=None, indent=20, callback=self.update) OWGUI.spin(cb.box, self, "restarts", label="Restarts", orientation="horizontal", min=1, max=100 if not orngDebugging.orngDebuggingEnabled else 5, callback=self.update, callbackOnReturn=True) box = OWGUI.widgetBox(self.controlArea, "Cluster IDs", addSpace=True) cb = OWGUI.checkBox(box, self, "classifySelected", "Append cluster indices") box = OWGUI.indentedBox(box, sep=OWGUI.checkButtonOffsetHint(cb)) form = QWidget() le = OWGUI.lineEdit(form, self, "classifyName", None, orientation="horizontal", valueType=str) cc = OWGUI.comboBox( form, self, "addIdAs", label=" ", orientation="horizontal", items=["Class attribute", "Attribute", "Meta attribute"]) layout = QFormLayout() layout.setSpacing(8) layout.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow) layout.setLabelAlignment(Qt.AlignLeft | Qt.AlignJustify) layout.addRow("Name ", le) layout.addRow("Place ", cc) form.setLayout(layout) box.layout().addWidget(form) left, top, right, bottom = layout.getContentsMargins() layout.setContentsMargins(0, top, right, bottom) cb.disables.append(box) cb.makeConsistent() box = OWGUI.widgetBox(self.controlArea, "Run") cb = OWGUI.checkBox(box, self, "runAnyChange", "Run after any change") self.runButton = b = OWGUI.button(box, self, "Run Clustering", callback=self.run) OWGUI.setStopper(self, b, cb, "settingsChanged", callback=self.run) OWGUI.rubber(self.controlArea) # display of clustering results self.optimizationReportBox = OWGUI.widgetBox(self.mainArea) self.tableBox = OWGUI.widgetBox(self.optimizationReportBox, "Optimization Report") self.table = OWGUI.table(self.tableBox, selectionMode=QTableWidget.SingleSelection) self.table.setHorizontalScrollMode(QTableWidget.ScrollPerPixel) self.table.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.table.setSelectionBehavior(QAbstractItemView.SelectRows) self.table.setColumnCount(3) self.table.setHorizontalHeaderLabels(["k", "Best", "Score"]) self.table.verticalHeader().hide() self.table.horizontalHeader().setStretchLastSection(True) self.table.setItemDelegateForColumn( 2, OWGUI.TableBarItem(self, self.table)) self.table.setItemDelegateForColumn(1, OWGUI.IndicatorItemDelegate(self)) self.table.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) self.connect(self.table, SIGNAL("itemSelectionChanged()"), self.tableItemSelected) self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) self.mainArea.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) OWGUI.rubber(self.topWidgetPart) self.updateOptimizationGui()
def __init__(self, parent=None, signalManager=None, name="CN2 Rules Viewer"): OWWidget.__init__(self, parent, signalManager, name) self.inputs = [("Rule Classifier", orange.RuleClassifier, self.setRuleClassifier)] self.outputs = [("Data", ExampleTable), ("Features", AttributeList)] self.show_Rule_length = True self.show_Rule_quality = True self.show_Coverage = True self.show_Predicted_class = True self.show_Distribution = True self.show_Rule = True self.autoCommit = False self.selectedAttrsOnly = True self.loadSettings() ##### # GUI ##### box = OWGUI.widgetBox(self.controlArea, "Show Info", addSpace=True) box.layout().setSpacing(3) self.headers = [ "Rule length", "Rule quality", "Coverage", "Predicted class", "Distribution", "Rule" ] for i, header in enumerate(self.headers): OWGUI.checkBox(box, self, "show_%s" % header.replace(" ", "_"), header, tooltip="Show %s column" % header.lower(), callback=self.updateVisibleColumns) box = OWGUI.widgetBox(self.controlArea, "Output") box.layout().setSpacing(3) cb = OWGUI.checkBox(box, self, "autoCommit", "Commit on any change", callback=self.commitIf) OWGUI.checkBox(box, self, "selectedAttrsOnly", "Selected attributes only", tooltip="Send selected attributes only", callback=self.commitIf) b = OWGUI.button(box, self, "Commit", callback=self.commit, default=True) OWGUI.setStopper(self, b, cb, "changedFlag", callback=self.commit) OWGUI.rubber(self.controlArea) self.tableView = QTableView() self.tableView.setItemDelegate(PyObjectItemDelegate(self)) self.tableView.setItemDelegateForColumn(1, PyFloatItemDelegate(self)) self.tableView.setItemDelegateForColumn(2, PyFloatItemDelegate(self)) self.tableView.setItemDelegateForColumn(4, DistributionItemDelegate(self)) self.tableView.setItemDelegateForColumn( 5, MultiLineStringItemDelegate(self)) self.tableView.setSortingEnabled(True) self.tableView.setSelectionBehavior(QTableView.SelectRows) self.tableView.setAlternatingRowColors(True) self.rulesTableModel = PyTableModel([], self.headers) self.proxyModel = QSortFilterProxyModel(self) self.proxyModel.setSourceModel(self.rulesTableModel) self.tableView.setModel(self.proxyModel) self.connect( self.tableView.selectionModel(), SIGNAL("selectionChanged(QItemSelection, QItemSelection)"), lambda is1, is2: self.commitIf()) self.connect(self.tableView.horizontalHeader(), SIGNAL("sectionClicked(int)"), lambda section: self.tableView.resizeRowsToContents()) self.mainArea.layout().addWidget(self.tableView) self.updateVisibleColumns() self.changedFlag = False self.classifier = None self.rules = [] self.resize(800, 600)
def defineGUI(self): # Set the number of hidden neurons throught the GUI OWGUI.lineEdit(self.controlArea, self, 'name', box='Learner/Classifier Name', \ tooltip='Name to be used by other widgets to identify your learner/classifier.<br>This should be a unique name!') OWGUI.lineEdit(self.controlArea, self, 'nHiddenGUI', box='The number of hidden neurons', \ tooltip='The number of neurons in each hidden layer should be given as a comma separated string. \n\ For example, 2,3,4 will create 3 hidden layers (5 layers in total, including in and out),\n\ with 2, 3 and 4 neurons respectively. If no value is given, the default, which is one layer of 5 neurons, \n\ will be used. ' ) # Set the training function throught the GUI # CVANNOPTALGDICT = {"FANN_TRAIN_BACKPROP":0, "FANN_TRAIN_RPROP":1} self.trainingBox = b = OWGUI.widgetBox(self.controlArea, "Training function") self.trainingRadio = OWGUI.radioButtonsInBox(b, self, "optAlgGUI", btnLabels= \ ["TRAIN_BACKPROP - Backpropagation", \ "TRAIN_RPROP - iRPROP algorithm (Recommended)"],callback = self.changedOptAlg) #CVANNSTOPCRITDICT = {"ITER":1, "EPS":2} sc = OWGUI.widgetBox(self.controlArea, "Stop criteria") self.trainingRadio = OWGUI.radioButtonsInBox(sc, self, "stopCritGUI", btnLabels= \ ["Max number of Iterations", \ "Epsilon"], callback = self.OnChangedStopCrit) OWGUI.lineEdit(OWGUI.indentedBox(sc), self, 'stopValueGUI', 'Value:', orientation="horizontal", tooltip="Value to use as stop Criteria") self.priorBox = OWGUI.lineEdit(b, self, 'priorsGUI', box='Class weights', \ tooltip='Ex: POS:2 , NEG:1') b = OWGUI.widgetBox(self.controlArea, "Scaling", addSpace=True) self.scaleDataBox = OWGUI.checkBox( b, self, "scaleDataGUI", "Scale Data", tooltip="Scales the training data, and the input examples", callback=self.setLearnerVars) self.scaleClassBox = OWGUI.checkBox( b, self, "scaleClassGUI", "Scale Class variable", tooltip= "Scales the class variable of training data, and the output predictions", callback=self.setLearnerVars) # Apply the settings and send the learner to the output channel OWGUI.button(self.controlArea, self, "&Apply settings", callback=self.applySettings) # Get desired location of model file boxFile = OWGUI.widgetBox(self.controlArea, "Path for saving Model", addSpace=True, orientation=0) L1 = OWGUI.lineEdit(boxFile, self, "modelFile", labelWidth=80, orientation = "horizontal", \ tooltip = "Once a model is created (connect this widget with a data widget), \nit can be saved by giving a \ file name here and clicking the save button.\nPlease observe that model names should not contain an extention." ) L1.setMinimumWidth(200) button = OWGUI.button( boxFile, self, '...', callback=self.browseFile, disabled=0, tooltip= "Choose the dir where to save. After chosen, add a name for the model file!" ) button.setMaximumWidth(25) # Save the model OWGUI.button(self.controlArea, self, "&Save model to file", callback=self.saveModel) self.setLearnerVars() self.applySettings() self.adjustSize()
def __init__(self, parent=None, signalManager=None, title="Reliability"): OWWidget.__init__(self, parent, signalManager, title, wantMainArea=False) self.inputs = [("Learner", Orange.core.Learner, self.set_learner), ("Training Data", Orange.data.Table, self.set_train_data), ("Test Data", Orange.data.Table, self.set_test_data)] self.outputs = [("Reliability Scores", Orange.data.Table)] self.variance_checked = False self.bias_checked = False self.bagged_variance = False self.local_cv = False self.local_model_pred_error = False self.bagging_variance_cn = False self.mahalanobis_distance = True self.var_e = "0.01, 0.1, 0.5, 1.0, 2.0" self.bias_e = "0.01, 0.1, 0.5, 1.0, 2.0" self.bagged_m = 10 self.local_cv_k = 2 self.local_pe_k = 5 self.bagged_cn_m = 5 self.bagged_cn_k = 1 self.mahalanobis_k = 3 self.include_error = True self.include_class = True self.include_input_features = False self.auto_commit = False # (selected attr name, getter function, count of returned estimators, indices of estimator results to use) self.estimators = \ [("variance_checked", self.get_SAVar, 3, [0]), ("bias_checked", self.get_SABias, 3, [1, 2]), ("bagged_variance", self.get_BAGV, 1, [0]), ("local_cv", self.get_LCV, 1, [0]), ("local_model_pred_error", self.get_CNK, 2, [0, 1]), ("bagging_variance_cn", self.get_BVCK, 4, [0]), ("mahalanobis_distance", self.get_Mahalanobis, 1, [0])] ##### # GUI ##### self.loadSettings() box = OWGUI.widgetBox(self.controlArea, "Info", addSpace=True) self.info_box = OWGUI.widgetLabel(box, "\n\n") rbox = OWGUI.widgetBox(self.controlArea, "Methods", addSpace=True) def method_box(parent, name, value): box = OWGUI.widgetBox(rbox, name, flat=False) box.setCheckable(True) box.setChecked(bool(getattr(self, value))) self.connect( box, SIGNAL("toggled(bool)"), lambda on: (setattr( self, value, on), self.method_selection_changed(value))) return box e_validator = QRegExpValidator( QRegExp(r"\s*(-?[0-9]+(\.[0-9]*)\s*,\s*)+"), self) variance_box = method_box(rbox, "Sensitivity analysis (variance)", "variance_checked") OWGUI.lineEdit( variance_box, self, "var_e", "Sensitivities:", tooltip= "List of possible e values (comma separated) for SAvar reliability estimates.", callback=partial(self.method_param_changed, 0), validator=e_validator) bias_box = method_box(rbox, "Sensitivity analysis (bias)", "bias_checked") OWGUI.lineEdit( bias_box, self, "bias_e", "Sensitivities:", tooltip= "List of possible e values (comma separated) for SAbias reliability estimates.", callback=partial(self.method_param_changed, 1), validator=e_validator) bagged_box = method_box(rbox, "Variance of bagged models", "bagged_variance") OWGUI.spin( bagged_box, self, "bagged_m", 2, 100, step=1, label="Models:", tooltip="Number of bagged models to be used with BAGV estimate.", callback=partial(self.method_param_changed, 2), keyboardTracking=False) local_cv_box = method_box(rbox, "Local cross validation", "local_cv") OWGUI.spin(local_cv_box, self, "local_cv_k", 2, 20, step=1, label="Nearest neighbors:", tooltip="Number of nearest neighbors used in LCV estimate.", callback=partial(self.method_param_changed, 3), keyboardTracking=False) local_pe = method_box(rbox, "Local modeling of prediction error", "local_model_pred_error") OWGUI.spin(local_pe, self, "local_pe_k", 1, 20, step=1, label="Nearest neighbors:", tooltip="Number of nearest neighbors used in CNK estimate.", callback=partial(self.method_param_changed, 4), keyboardTracking=False) bagging_cnn = method_box(rbox, "Bagging variance c-neighbors", "bagging_variance_cn") OWGUI.spin( bagging_cnn, self, "bagged_cn_m", 2, 100, step=1, label="Models:", tooltip="Number of bagged models to be used with BVCK estimate.", callback=partial(self.method_param_changed, 5), keyboardTracking=False) OWGUI.spin( bagging_cnn, self, "bagged_cn_k", 1, 20, step=1, label="Nearest neighbors:", tooltip="Number of nearest neighbors used in BVCK estimate.", callback=partial(self.method_param_changed, 5), keyboardTracking=False) mahalanobis_box = method_box(rbox, "Mahalanobis distance", "mahalanobis_distance") OWGUI.spin( mahalanobis_box, self, "mahalanobis_k", 1, 20, step=1, label="Nearest neighbors:", tooltip="Number of nearest neighbors used in BVCK estimate.", callback=partial(self.method_param_changed, 6), keyboardTracking=False) box = OWGUI.widgetBox(self.controlArea, "Output") OWGUI.checkBox(box, self, "include_error", "Include prediction error", tooltip="Include prediction error in the output", callback=self.commit_if) OWGUI.checkBox( box, self, "include_class", "Include original class and prediction", tooltip="Include original class and prediction in the output.", callback=self.commit_if) OWGUI.checkBox(box, self, "include_input_features", "Include input features", tooltip="Include features from the input data set.", callback=self.commit_if) cb = OWGUI.checkBox(box, self, "auto_commit", "Commit on any change", callback=self.commit_if) self.commit_button = b = OWGUI.button(box, self, "Commit", callback=self.commit, autoDefault=True) OWGUI.setStopper(self, b, cb, "output_changed", callback=self.commit) self.commit_button.setEnabled(any([getattr(self, selected) \ for selected, _, _, _ in self.estimators])) self.learner = None self.train_data = None self.test_data = None self.output_changed = False self.train_data_has_no_class = False self.train_data_has_discrete_class = False self.invalidate_results()
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "Calibration Plot", 1) # inputs self.inputs = [("Evaluation Results", orngTest.ExperimentResults, self.results, Default)] #set default settings self.CalibrationCurveWidth = 3 self.ShowDiagonal = TRUE self.ShowRugs = TRUE #load settings self.loadSettings() # temp variables self.dres = None self.targetClass = None self.numberOfClasses = 0 self.graphs = [] self.classifierColor = None self.numberOfClassifiers = 0 self.classifiers = [] self.selectedClassifiers = [] # GUI import sip sip.delete(self.mainArea.layout()) self.graphsGridLayoutQGL = QGridLayout(self.mainArea) self.mainArea.setLayout(self.graphsGridLayoutQGL) ## save each ROC graph in separate file self.graph = None self.connect(self.graphButton, SIGNAL("clicked()"), self.saveToFile) ## general tab self.tabs = OWGUI.tabWidget(self.controlArea) self.generalTab = OWGUI.createTabPage(self.tabs, "General") self.settingsTab = OWGUI.createTabPage(self.tabs, "Settings") self.splitQS = QSplitter() self.splitQS.setOrientation(Qt.Vertical) ## target class self.classCombo = OWGUI.comboBox(self.generalTab, self, 'targetClass', box='Target class', items=[], callback=self.target) OWGUI.separator(self.generalTab) ## classifiers selection (classifiersQLB) self.classifiersQVGB = OWGUI.widgetBox(self.generalTab, "Classifiers") self.classifiersQLB = OWGUI.listBox( self.classifiersQVGB, self, "selectedClassifiers", selectionMode=QListWidget.MultiSelection, callback=self.classifiersSelectionChange) self.unselectAllClassifiersQLB = OWGUI.button( self.classifiersQVGB, self, "(Un)select all", callback=self.SUAclassifiersQLB) ## settings tab OWGUI.hSlider(self.settingsTab, self, 'CalibrationCurveWidth', box='Calibration Curve Width', minValue=1, maxValue=9, step=1, callback=self.setCalibrationCurveWidth, ticks=1) OWGUI.checkBox(self.settingsTab, self, 'ShowDiagonal', 'Show Diagonal Line', tooltip='', callback=self.setShowDiagonal) OWGUI.checkBox(self.settingsTab, self, 'ShowRugs', 'Show Rugs', tooltip='', callback=self.setShowRugs) self.settingsTab.layout().addStretch(100)
def __init__(self, parent=None, signalManager=None, title="PCA"): OWWidget.__init__(self, parent, signalManager, title, wantGraph=True) self.inputs = [("Input Data", Orange.data.Table, self.set_data)] self.outputs = [("Transformed Data", Orange.data.Table, Default), ("Eigen Vectors", Orange.data.Table)] self.standardize = True self.max_components = 0 self.variance_covered = 100.0 self.use_generalized_eigenvectors = False self.auto_commit = False self.loadSettings() self.data = None self.changed_flag = False ##### # GUI ##### grid = QGridLayout() box = OWGUI.widgetBox(self.controlArea, "Components Selection", orientation=grid) label1 = QLabel("Max components", box) grid.addWidget(label1, 1, 0) sb1 = OWGUI.spin(box, self, "max_components", 0, 1000, tooltip="Maximum number of components", callback=self.on_update, addToLayout=False, keyboardTracking=False) self.max_components_spin = sb1.control self.max_components_spin.setSpecialValueText("All") grid.addWidget(sb1.control, 1, 1) label2 = QLabel("Variance covered", box) grid.addWidget(label2, 2, 0) sb2 = OWGUI.doubleSpin(box, self, "variance_covered", 1.0, 100.0, 1.0, tooltip="Percent of variance covered.", callback=self.on_update, decimals=1, addToLayout=False, keyboardTracking=False) sb2.control.setSuffix("%") grid.addWidget(sb2.control, 2, 1) OWGUI.rubber(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Commit") cb = OWGUI.checkBox(box, self, "auto_commit", "Commit on any change") b = OWGUI.button(box, self, "Commit", callback=self.update_components) OWGUI.setStopper(self, b, cb, "changed_flag", self.update_components) self.scree_plot = ScreePlot(self) # self.scree_plot.set_main_title("Scree Plot") # self.scree_plot.set_show_main_title(True) self.scree_plot.set_axis_title(owaxis.xBottom, "Principal Components") self.scree_plot.set_show_axis_title(owaxis.xBottom, 1) self.scree_plot.set_axis_title(owaxis.yLeft, "Proportion of Variance") self.scree_plot.set_show_axis_title(owaxis.yLeft, 1) self.variance_curve = self.scree_plot.add_curve( "Variance", Qt.red, Qt.red, 2, xData=[], yData=[], style=OWCurve.Lines, enableLegend=True, lineWidth=2, autoScale=1, x_axis_key=owaxis.xBottom, y_axis_key=owaxis.yLeft, ) self.cumulative_variance_curve = self.scree_plot.add_curve( "Cumulative Variance", Qt.darkYellow, Qt.darkYellow, 2, xData=[], yData=[], style=OWCurve.Lines, enableLegend=True, lineWidth=2, autoScale=1, x_axis_key=owaxis.xBottom, y_axis_key=owaxis.yLeft, ) self.mainArea.layout().addWidget(self.scree_plot) self.connect(self.scree_plot, SIGNAL("cutoff_moved(double)"), self.on_cutoff_moved) self.connect(self.graphButton, SIGNAL("clicked()"), self.scree_plot.save_to_file) self.components = None self.variances = None self.variances_sum = None self.projector_full = None self.currently_selected = 0 self.resize(800, 400)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "Data Table") self.inputs = [("Examples", ExampleTable, self.dataset, Multiple + Default)] self.outputs = [("Selected Examples", ExampleTable)] self.data = {} # key: id, value: ExampleTable self.showMetas = {} # key: id, value: (True/False, columnList) self.showMeta = 1 self.showAttributeLabels = 1 self.showDistributions = 1 self.distColorRgb = (220, 220, 220, 255) self.distColor = QColor(*self.distColorRgb) self.locale = QLocale() self.autoCommit = False self.loadSettings() # info box infoBox = OWGUI.widgetBox(self.controlArea, "Info") self.infoEx = OWGUI.widgetLabel(infoBox, 'No data on input.') self.infoMiss = OWGUI.widgetLabel(infoBox, ' ') OWGUI.widgetLabel(infoBox, ' ') self.infoAttr = OWGUI.widgetLabel(infoBox, ' ') self.infoMeta = OWGUI.widgetLabel(infoBox, ' ') OWGUI.widgetLabel(infoBox, ' ') self.infoClass = OWGUI.widgetLabel(infoBox, ' ') infoBox.setMinimumWidth(200) OWGUI.separator(self.controlArea) # settings box boxSettings = OWGUI.widgetBox(self.controlArea, "Settings") self.cbShowMeta = OWGUI.checkBox(boxSettings, self, "showMeta", 'Show meta attributes', callback=self.cbShowMetaClicked) self.cbShowMeta.setEnabled(False) self.cbShowAttLbls = OWGUI.checkBox( boxSettings, self, "showAttributeLabels", 'Show attribute labels (if any)', callback=self.cbShowAttLabelsClicked) self.cbShowAttLbls.setEnabled(True) self.cbShowDistributions = OWGUI.checkBox( boxSettings, self, "showDistributions", 'Visualize continuous values', callback=self.cbShowDistributions) colBox = OWGUI.indentedBox(boxSettings, orientation="horizontal") OWGUI.widgetLabel(colBox, "Color: ") self.colButton = OWGUI.toolButton(colBox, self, self.changeColor, width=20, height=20, debuggingEnabled=0) OWGUI.rubber(colBox) resizeColsBox = OWGUI.widgetBox(boxSettings, 0, "horizontal", 0) OWGUI.label(resizeColsBox, self, "Resize columns: ") OWGUI.button(resizeColsBox, self, "+", self.increaseColWidth, tooltip="Increase the width of the columns", width=30) OWGUI.button(resizeColsBox, self, "-", self.decreaseColWidth, tooltip="Decrease the width of the columns", width=30) OWGUI.rubber(resizeColsBox) self.btnResetSort = OWGUI.button( boxSettings, self, "Restore Order of Examples", callback=self.btnResetSortClicked, tooltip="Show examples in the same order as they appear in the file" ) OWGUI.separator(self.controlArea) selectionBox = OWGUI.widgetBox(self.controlArea, "Selection") self.sendButton = OWGUI.button(selectionBox, self, "Send selections", self.commit) cb = OWGUI.checkBox(selectionBox, self, "autoCommit", "Commit on any change", callback=self.commitIf) OWGUI.setStopper(self, self.sendButton, cb, "selectionChangedFlag", self.commit) OWGUI.rubber(self.controlArea) # GUI with tabs self.tabs = OWGUI.tabWidget(self.mainArea) self.id2table = {} # key: widget id, value: table self.table2id = {} # key: table, value: widget id self.connect(self.tabs, SIGNAL("currentChanged(QWidget*)"), self.tabClicked) self.selectionChangedFlag = False self.updateColor()
def __init__(self, parent=None, signalManager=None, name="Impute"): OWWidget.__init__(self, parent, signalManager, name, wantMainArea=0) self.inputs = [("Examples", ExampleTable, self.setData, Default), ("Learner for Imputation", orange.Learner, self.setModel)] self.outputs = [("Examples", ExampleTable), ("Imputer", orange.ImputerConstructor)] self.attrIcons = self.createAttributeIconDict() self.defaultMethod = 0 self.selectedAttr = 0 self.indiType = 0 self.imputeClass = 0 self.autosend = 1 self.methods = {} self.dataChanged = False self.model = self.data = None self.indiValue = "" self.indiValCom = 0 self.loadSettings() bgTreat = OWGUI.radioButtonsInBox(self.controlArea, self, "defaultMethod", self.defaultMethods, "Default imputation method", callback=self.sendIf, addSpace=True) self.indibox = OWGUI.widgetBox( self.controlArea, "Individual attribute settings", orientation="horizontal") #, addSpace=True) attrListBox = OWGUI.widgetBox(self.indibox) self.attrList = OWGUI.listBox(attrListBox, self, callback=self.individualSelected) self.attrList.setMinimumWidth(220) self.attrList.setItemDelegate( ImputeListItemDelegate(self, self.attrList)) indiMethBox = OWGUI.widgetBox(self.indibox) indiMethBox.setFixedWidth(160) self.indiButtons = OWGUI.radioButtonsInBox( indiMethBox, self, "indiType", [ "Default (above)", "Don't impute", "Avg/Most frequent", "Model-based", "Random", "Remove examples", "Value" ], 1, callback=self.indiMethodChanged) self.indiValueCtrlBox = OWGUI.indentedBox(self.indiButtons) self.indiValueLineEdit = OWGUI.lineEdit(self.indiValueCtrlBox, self, "indiValue", callback=self.lineEditChanged) #self.indiValueLineEdit.hide() valid = QDoubleValidator(self) valid.setRange(-1e30, 1e30, 10) self.indiValueLineEdit.setValidator(valid) self.indiValueComboBox = OWGUI.comboBox( self.indiValueCtrlBox, self, "indiValCom", callback=self.valueComboChanged) self.indiValueComboBox.hide() OWGUI.rubber(indiMethBox) self.btAllToDefault = OWGUI.button(indiMethBox, self, "Set All to Default", callback=self.allToDefault) OWGUI.separator(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Class Imputation") #, addSpace=True) self.cbImputeClass = OWGUI.checkBox(box, self, "imputeClass", "Impute class values", callback=self.sendIf) OWGUI.separator(self.controlArea) snbox = OWGUI.widgetBox(self.controlArea, "Send data and imputer") self.btApply = OWGUI.button(snbox, self, "Apply", callback=self.sendDataAndImputer) OWGUI.checkBox(snbox, self, "autosend", "Send automatically", callback=self.enableAuto, disables=[(-1, self.btApply)]) self.individualSelected(self.selectedAttr) self.btApply.setDisabled(self.autosend) self.setBtAllToDefault() self.resize(200, 200)
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, "Confusion Matrix", 1) # inputs self.inputs = [("Evaluation Results", orngTest.ExperimentResults, self.setTestResults, Default)] self.outputs = [("Selected Examples", ExampleTable, 8)] self.selectedLearner = [] self.learnerNames = [] self.selectionDirty = 0 self.autoApply = True self.appendPredictions = True self.appendProbabilities = False self.shownQuantity = 0 self.learnerList = OWGUI.listBox(self.controlArea, self, "selectedLearner", "learnerNames", box="Learners", callback=self.learnerChanged) self.learnerList.setMinimumHeight(100) OWGUI.separator(self.controlArea) OWGUI.comboBox(self.controlArea, self, "shownQuantity", items=self.quantities, box="Show", callback=self.reprint) OWGUI.separator(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Selection") #, addSpace=True) OWGUI.button(box, self, "Correct", callback=self.selectCorrect) OWGUI.button(box, self, "Misclassified", callback=self.selectWrong) OWGUI.button(box, self, "None", callback=self.selectNone) OWGUI.separator(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Output") OWGUI.checkBox(box, self, "appendPredictions", "Append class predictions", callback=self.sendIf) OWGUI.checkBox(box, self, "appendProbabilities", "Append predicted class probabilities", callback=self.sendIf) applyButton = OWGUI.button(box, self, "Commit", callback=self.sendData) autoApplyCB = OWGUI.checkBox(box, self, "autoApply", "Commit automatically") OWGUI.setStopper(self, applyButton, autoApplyCB, "selectionDirty", self.sendData) import sip sip.delete(self.mainArea.layout()) self.layout = QGridLayout(self.mainArea) self.layout.addWidget(OWGUI.widgetLabel(self.mainArea, "Prediction"), 0, 1, Qt.AlignCenter) label = TransformedLabel("Correct Class") self.layout.addWidget(label, 2, 0, Qt.AlignCenter) # self.layout.addWidget(OWGUI.widgetLabel(self.mainArea, "Correct Class "), 2, 0, Qt.AlignCenter) self.table = OWGUI.table(self.mainArea, rows=0, columns=0, selectionMode=QTableWidget.MultiSelection, addToLayout=0) self.layout.addWidget(self.table, 2, 1) self.layout.setColumnStretch(1, 100) self.layout.setRowStretch(2, 100) self.connect(self.table, SIGNAL("itemSelectionChanged()"), self.sendIf) self.resize(700, 450)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'LearningCurveC') self.inputs = [("Data", Orange.data.Table, self.dataset), ("Learner", Orange.classification.Learner, self.learner, Multiple)] self.folds = 5 # cross validation folds self.steps = 10 # points in the learning curve self.scoringF = 0 # scoring function self.commitOnChange = 1 # compute curve on any change of parameters self.graphPointSize = 5 # size of points in the graphs self.graphDrawLines = 1 # draw lines between points in the graph self.graphShowGrid = 1 # show gridlines in the graph self.selectedLearners = [] self.loadSettings() warnings.filterwarnings("ignore", ".*builtin attribute.*", Orange.core.AttributeWarning) self.updateCurvePoints( ) # sets self.curvePoints, self.steps equidistant points from 1/self.steps to 1 self.scoring = [("Classification Accuracy", Orange.evaluation.scoring.CA), ("AUC", Orange.evaluation.scoring.AUC), ("BrierScore", Orange.evaluation.scoring.Brier_score), ("Information Score", Orange.evaluation.scoring.IS), ("Sensitivity", Orange.evaluation.scoring.sens), ("Specificity", Orange.evaluation.scoring.spec)] self.learners = [ ] # list of current learners from input channel, tuples (id, learner) self.data = None # data on which to construct the learning curve self.curves = [ ] # list of evaluation results (one per learning curve point) self.scores = [] # list of current scores, learnerID:[learner scores] # GUI box = OWGUI.widgetBox(self.controlArea, "Info") self.infoa = OWGUI.widgetLabel(box, 'No data on input.') self.infob = OWGUI.widgetLabel(box, 'No learners.') ## class selection (classQLB) OWGUI.separator(self.controlArea) # ~SPHINX start color cb~ self.cbox = OWGUI.widgetBox(self.controlArea, "Learners") self.llb = OWGUI.listBox(self.cbox, self, "selectedLearners", selectionMode=QListWidget.MultiSelection, callback=self.learnerSelectionChanged) self.llb.setMinimumHeight(50) self.blockSelectionChanges = 0 # ~SPHINX end color cb~ OWGUI.separator(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Evaluation Scores") scoringNames = [x[0] for x in self.scoring] OWGUI.comboBox(box, self, "scoringF", items=scoringNames, callback=self.computeScores) OWGUI.separator(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Options") OWGUI.spin(box, self, 'folds', 2, 100, step=1, label='Cross validation folds: ', callback=lambda: self.computeCurve() if self.commitOnChange else None) OWGUI.spin(box, self, 'steps', 2, 100, step=1, label='Learning curve points: ', callback=[ self.updateCurvePoints, lambda: self.computeCurve() if self.commitOnChange else None ]) OWGUI.checkBox(box, self, 'commitOnChange', 'Apply setting on any change') self.commitBtn = OWGUI.button(box, self, "Apply Setting", callback=self.computeCurve, disabled=1) # ~SPHINX start main area tabs~ # start of content (right) area tabs = OWGUI.tabWidget(self.mainArea) # graph tab tab = OWGUI.createTabPage(tabs, "Graph") self.graph = OWGraph(tab) self.graph.setAxisAutoScale(QwtPlot.xBottom) self.graph.setAxisAutoScale(QwtPlot.yLeft) tab.layout().addWidget(self.graph) self.setGraphGrid() # table tab tab = OWGUI.createTabPage(tabs, "Table") self.table = OWGUI.table(tab, selectionMode=QTableWidget.NoSelection) # ~SPHINX end main area tabs~ self.resize(550, 200)
def __init__(self, parent=None, signalManager=None, name="Multi Dimensional Scaling"): OWWidget.__init__(self, parent, signalManager, name, wantGraph=True) self.inputs = [("Distances", orange.SymMatrix, self.cmatrix), ("Data Subset", ExampleTable, self.cselected)] self.outputs = [("Data", ExampleTable)] self.StressFunc = 3 self.minStressDelta = 5e-5 self.maxIterations = 5000 self.maxImprovment = 10 self.autoSendSelection = 0 self.toolbarSelection = 0 self.selectionOptions = 0 self.computeStress = 1 self.ReDraw = 1 self.NumIter = 1 self.RefreshMode = 0 self.applyLSMT = 0 self.stressFunc = [("Kruskal stress", orngMDS.KruskalStress), ("Sammon stress", orngMDS.SammonStress), ("Signed Sammon stress", orngMDS.SgnSammonStress), ("Signed relative stress", orngMDS.SgnRelStress)] self.graph = MDSPlot(self.mainArea) self.mainArea.layout().addWidget(self.graph) self.loadSettings() tabs = OWGUI.tabWidget(self.controlArea) mds = OWGUI.createTabPage(tabs, "MDS") graph = OWGUI.createTabPage(tabs, "Graph") ##MDS Tab init = OWGUI.widgetBox(mds, "Initialization") OWGUI.button(init, self, "Randomize", self.randomize) OWGUI.button(init, self, "Jitter", self.jitter) OWGUI.button(init, self, "Torgerson", self.torgerson) opt = OWGUI.widgetBox(mds, "Optimization") self.startButton = OWGUI.button(opt, self, "Optimize", self.testStart) OWGUI.button(opt, self, "Single Step", self.smacofStep) box = OWGUI.widgetBox(opt, "Stress Function") OWGUI.comboBox(box, self, "StressFunc", items=[a[0] for a in self.stressFunc], callback=self.updateStress) OWGUI.radioButtonsInBox( opt, self, "RefreshMode", ["Every step", "Every 10 steps", "Every 100 steps"], "Refresh During Optimization", callback=lambda: 1) self.stopping = OWGUI.widgetBox(opt, "Stopping Conditions") OWGUI.hSlider(OWGUI.widgetBox(self.stopping, "Min. stress change", flat=True), self, "minStressDelta", minValue=5e-5, maxValue=1e-2, step=5e-5, labelFormat="%.5f", intOnly=0) OWGUI.hSlider(OWGUI.widgetBox(self.stopping, "Max. number of steps", flat=True), self, "maxIterations", minValue=10, maxValue=5000, step=10, labelFormat="%i") ##Graph Tab OWGUI.hSlider(graph, self, "graph.PointSize", box="Point Size", minValue=1, maxValue=20, callback=self.graph.updateData) self.colorCombo = OWGUI.comboBox(graph, self, "graph.ColorAttr", box="Color", callback=self.graph.updateData) self.sizeCombo = OWGUI.comboBox(graph, self, "graph.SizeAttr", box="Size", callback=self.graph.updateData) self.shapeCombo = OWGUI.comboBox(graph, self, "graph.ShapeAttr", box="Shape", callback=self.graph.updateData) self.nameCombo = OWGUI.comboBox(graph, self, "graph.NameAttr", box="Label", callback=self.graph.updateData) box = OWGUI.widgetBox(graph, "Distances & Stress") OWGUI.checkBox(box, self, "graph.ShowStress", "Show similar pairs", callback=self.graph.updateLinesRepaint) b2 = OWGUI.widgetBox(box) OWGUI.widgetLabel(b2, "Proportion of connected pairs") OWGUI.separator(b2, height=3) sl = OWGUI.hSlider( b2, self, "graph.proportionGraphed", minValue=0, maxValue=20, callback=self.graph.updateLinesRepaint, tooltip= "Proportion of connected pairs (Maximum of 1000 lines will be drawn" ) OWGUI.checkBox(box, self, "graph.differentWidths", "Show distance by line width", callback=self.graph.updateLinesRepaint) OWGUI.checkBox(box, self, "graph.stressByTransparency", "Show stress by transparency", callback=self.graph.updateData) OWGUI.checkBox(box, self, "graph.stressBySize", "Show stress by symbol size", callback=self.updateStressBySize) self.updateStressBySize(True) OWGUI.checkBox(graph, self, "graph.antialias_points", label="Use antialiasing", box="Antialiasing", tooltip="Use antialiasing for beter quality graphics", callback=self.graph.updateData) self.zoomToolbar = OWToolbars.ZoomSelectToolbar( self, graph, self.graph, self.autoSendSelection) self.connect(self.zoomToolbar.buttonSendSelections, SIGNAL("clicked()"), self.sendSelections) self.graph.autoSendSelectionCallback = lambda: self.autoSendSelection and self.sendSelections( ) OWGUI.checkBox(graph, self, "autoSendSelection", "Auto send selected") OWGUI.radioButtonsInBox(graph, self, "selectionOptions", [ "Don't append", "Append coordinates", "Append coordinates as meta" ], box="Append coordinates", callback=self.sendIf) mds.setSizePolicy(QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)) graph.setSizePolicy( QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)) self.controlArea.setMinimumWidth(250) OWGUI.rubber(mds) OWGUI.rubber(self.controlArea) infoBox = OWGUI.widgetBox(mds, "Info") self.infoA = OWGUI.widgetLabel(infoBox, "Avg. stress:") self.infoB = OWGUI.widgetLabel(infoBox, "Num. steps") # OWGUI.button(self.controlArea, self, "Save", self.graph.saveToFile, debuggingEnabled = 0) self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile) self.resize(900, 630) self.done = True self.data = None self.selectedInputExamples = [] self.selectedInput = []
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'Itemset visualizer') self.inputs = [ ("Graph with ExampleTable", orange.Graph, self.setGraph), ("Example Subset", orange.ExampleTable, self.setExampleSubset) ] self.outputs = [("Selected Examples", ExampleTable), ("Selected Graph", orange.Graph)] self.markerAttributes = [] self.tooltipAttributes = [] self.attributes = [] self.autoSendSelection = False self.graphShowGrid = 1 # show gridlines in the graph self.markNConnections = 2 self.markNumber = 0 self.markProportion = 0 self.markSearchString = "" self.markDistance = 2 self.frSteps = 1 self.hubs = 0 self.color = 0 self.nVertices = self.nMarked = self.nSelected = self.nHidden = self.nShown = self.nEdges = self.verticesPerEdge = self.edgesPerVertex = self.diameter = 0 self.optimizeWhat = 1 self.stopOptimization = 0 self.loadSettings() self.visualize = None self.graph = OWIntemsetCanvas(self, self.mainArea, "Network") #start of content (right) area self.box = QVBoxLayout(self.mainArea) self.box.addWidget(self.graph) self.tabs = QTabWidget(self.controlArea) self.displayTab = QVGroupBox(self) self.mainTab = self.displayTab self.markTab = QVGroupBox(self) self.infoTab = QVGroupBox(self) self.protoTab = QVGroupBox(self) self.tabs.insertTab(self.displayTab, "Display") self.tabs.insertTab(self.markTab, "Mark") self.tabs.insertTab(self.infoTab, "Info") self.tabs.insertTab(self.protoTab, "Prototypes") OWGUI.separator(self.controlArea) self.optimizeBox = OWGUI.radioButtonsInBox(self.mainTab, self, "optimizeWhat", [], "Optimize", addSpace=False) OWGUI.button(self.optimizeBox, self, "Random", callback=self.random) self.frButton = OWGUI.button(self.optimizeBox, self, "Fruchterman Reingold", callback=self.fr, toggleButton=1) OWGUI.spin(self.optimizeBox, self, "frSteps", 1, 10000, 1, label="Iterations: ") OWGUI.button(self.optimizeBox, self, "F-R Radial", callback=self.frRadial) OWGUI.button(self.optimizeBox, self, "Circular Original", callback=self.circularOriginal) OWGUI.button(self.optimizeBox, self, "Circular Crossing Reduction", callback=self.circularCrossingReduction) self.showLabels = 0 OWGUI.checkBox(self.mainTab, self, 'showLabels', 'Show labels', callback=self.showLabelsClick) self.labelsOnMarkedOnly = 0 OWGUI.checkBox(self.mainTab, self, 'labelsOnMarkedOnly', 'Show labels on marked nodes only', callback=self.labelsOnMarked) OWGUI.separator(self.mainTab) OWGUI.button(self.mainTab, self, "Show degree distribution", callback=self.showDegreeDistribution) OWGUI.button(self.mainTab, self, "Save network", callback=self.saveNetwork) ib = OWGUI.widgetBox(self.markTab, "Info", addSpace=True) OWGUI.label( ib, self, "Vertices (shown/hidden): %(nVertices)i (%(nShown)i/%(nHidden)i)") OWGUI.label( ib, self, "Selected and marked vertices: %(nSelected)i - %(nMarked)i") ribg = OWGUI.radioButtonsInBox(self.markTab, self, "hubs", [], "Method", callback=self.setHubs, addSpace=True) OWGUI.appendRadioButton(ribg, self, "hubs", "Mark vertices given in the input signal") OWGUI.appendRadioButton(ribg, self, "hubs", "Find vertices which label contain") self.ctrlMarkSearchString = OWGUI.lineEdit( OWGUI.indentedBox(ribg), self, "markSearchString", callback=self.setSearchStringTimer, callbackOnType=True) self.searchStringTimer = QTimer(self) self.connect(self.searchStringTimer, SIGNAL("timeout()"), self.setHubs) OWGUI.appendRadioButton(ribg, self, "hubs", "Mark neighbours of focused vertex") OWGUI.appendRadioButton(ribg, self, "hubs", "Mark neighbours of selected vertices") ib = OWGUI.indentedBox(ribg, orientation=0) self.ctrlMarkDistance = OWGUI.spin( ib, self, "markDistance", 0, 100, 1, label="Distance ", callback=(lambda h=2: self.setHubs(h))) self.ctrlMarkFreeze = OWGUI.button(ib, self, "&Freeze", value="graph.freezeNeighbours", toggleButton=True) OWGUI.widgetLabel(ribg, "Mark vertices with ...") OWGUI.appendRadioButton(ribg, self, "hubs", "at least N connections") OWGUI.appendRadioButton(ribg, self, "hubs", "at most N connections") self.ctrlMarkNConnections = OWGUI.spin( OWGUI.indentedBox(ribg), self, "markNConnections", 0, 1000000, 1, label="N ", callback=(lambda h=4: self.setHubs(h))) OWGUI.appendRadioButton(ribg, self, "hubs", "more connections than any neighbour") OWGUI.appendRadioButton(ribg, self, "hubs", "more connections than avg neighbour") OWGUI.appendRadioButton(ribg, self, "hubs", "most connections") ib = OWGUI.indentedBox(ribg) self.ctrlMarkNumber = OWGUI.spin( ib, self, "markNumber", 0, 1000000, 1, label="Number of vertices" + ": ", callback=(lambda h=8: self.setHubs(h))) OWGUI.widgetLabel(ib, "(More vertices are marked in case of ties)") ib = QHGroupBox("Selection", self.markTab) btnM2S = OWGUI.button(ib, self, "", callback=self.markedToSelection) btnM2S.setPixmap(QPixmap(dlg_mark2sel)) QToolTip.add(btnM2S, "Add Marked to Selection") btnS2M = OWGUI.button(ib, self, "", callback=self.markedFromSelection) btnS2M.setPixmap(QPixmap(dlg_sel2mark)) QToolTip.add(btnS2M, "Remove Marked from Selection") btnSIM = OWGUI.button(ib, self, "", callback=self.setSelectionToMarked) btnSIM.setPixmap(QPixmap(dlg_selIsmark)) QToolTip.add(btnSIM, "Set Selection to Marked") self.hideBox = QHGroupBox("Hide vertices", self.markTab) btnSEL = OWGUI.button(self.hideBox, self, "", callback=self.hideSelected) btnSEL.setPixmap(QPixmap(dlg_selected)) QToolTip.add(btnSEL, "Selected") btnUN = OWGUI.button(self.hideBox, self, "", callback=self.hideAllButSelected) btnUN.setPixmap(QPixmap(dlg_unselected)) QToolTip.add(btnUN, "Unselected") OWGUI.button(self.hideBox, self, "Show", callback=self.showAllNodes) T = OWToolbars.NavigateSelectToolbar self.zoomSelectToolbar = OWToolbars.NavigateSelectToolbar( self, self.controlArea, self.graph, self.autoSendSelection, buttons=(T.IconZoom, T.IconZoomExtent, T.IconZoomSelection, ("", "", "", None, None, 0, "navigate"), T.IconPan, ("Move selection", "buttonMoveSelection", "activateMoveSelection", QPixmap(OWToolbars.dlg_select), Qt.arrowCursor, 1, "select"), T.IconRectangle, T.IconPolygon, ("", "", "", None, None, 0, "select"), T.IconSendSelection)) ib = OWGUI.widgetBox(self.infoTab, "General", addSpace=True) OWGUI.label(ib, self, "Number of vertices: %(nVertices)i") OWGUI.label(ib, self, "Number of edges: %(nEdges)i") OWGUI.label(ib, self, "Vertices per edge: %(verticesPerEdge).2f") OWGUI.label(ib, self, "Edges per vertex: %(edgesPerVertex).2f") OWGUI.label(ib, self, "Diameter: %(diameter)i") self.insideView = 0 self.insideViewNeighbours = 2 self.insideSpin = OWGUI.spin(self.protoTab, self, "insideViewNeighbours", 1, 6, 1, label="Inside view (neighbours): ", checked="insideView", checkCallback=self.insideview, callback=self.insideviewneighbours) #OWGUI.button(self.protoTab, self, "Clustering", callback=self.clustering) OWGUI.button(self.protoTab, self, "Collapse", callback=self.collapse) self.icons = self.createAttributeIconDict() self.setHubs() self.resize(850, 700)
def __init__(self, parent=None, signalManager=None, name='C4.5'): 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), ("Classification Tree", Orange.classification.tree.TreeClassifier) ] #, ("C45 Tree", orange.C45Classifier)] # Settings self.name = 'C4.5' self.infoGain = 0 self.subset = 0 self.probThresh = 0 self.useMinObjs = 1 self.minObjs = 2 self.prune = 1 self.cf = 25 self.iterative = 0 self.manualWindow = 0 self.window = 50 self.manualIncrement = 0 self.increment = 10 self.trials = 10 self.convertToOrange = 1 self.loadSettings() self.data = None # input data set self.preprocessor = None # no preprocessing as default 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) self.wbSplit = OWGUI.widgetBox(self.controlArea, "Splitting") OWGUI.checkBox(self.wbSplit, self, 'infoGain', 'Use information gain instead of ratio (-g)') OWGUI.checkBox(self.wbSplit, self, 'subset', 'Subsetting (-s)') OWGUI.checkBox( self.wbSplit, self, 'probThresh', 'Probabilistic threshold for continuous attributes (-p)') OWGUI.separator(self.controlArea) self.wbPruning = OWGUI.widgetBox(self.controlArea, "Pruning") OWGUI.checkWithSpin(self.wbPruning, self, 'Minimal examples in leaves (-m)', 1, 1000, 'useMinObjs', 'minObjs', '', 1, labelWidth=225) OWGUI.checkWithSpin(self.wbPruning, self, 'Post pruning with confidence level (-cf) of ', 0, 100, 'prune', 'cf', '', 5, labelWidth=225) OWGUI.separator(self.controlArea) self.wbIterative = OWGUI.widgetBox(self.controlArea, "Iterative generation") self.cbIterative = OWGUI.checkBox( self.wbIterative, self, 'iterative', 'Generate the tree iteratively (-i, -t, -w)') self.spTrial = OWGUI.spin(self.wbIterative, self, 'trials', 1, 30, 1, '', " Number of trials (-t)", orientation="horizontal", labelWidth=225) self.csWindow = OWGUI.checkWithSpin( self.wbIterative, self, "Manually set initial window size (-w) to ", 10, 1000, 'manualWindow', 'window', '', 10, labelWidth=225) self.csIncrement = OWGUI.checkWithSpin( self.wbIterative, self, "Manually set window increment (-i) to ", 10, 1000, 'manualIncrement', 'increment', '', 10, labelWidth=225) self.cbIterative.disables = [ self.spTrial, self.csWindow, self.csIncrement ] self.cbIterative.makeConsistent() # OWGUI.separator(self.controlArea) # OWGUI.checkBox(self.controlArea, self, 'convertToOrange', 'Convert to orange tree structure', box = 1) OWGUI.separator(self.controlArea) OWGUI.button(self.controlArea, self, "&Apply", callback=self.setLearner, disabled=0, default=True) OWGUI.rubber(self.controlArea) self.setLearner()
def __init__(self, parent=None, signalManager=None, name="Correspondence Analysis"): OWWidget.__init__(self, parent, signalManager, name, wantGraph=True) self.inputs = [("Data", ExampleTable, self.setData)] self.outputs = [("Selected Data", ExampleTable), ("Remaining Data", ExampleTable)] self.colAttr = 0 self.rowAttr = 1 self.xPrincipalAxis = 0 self.yPrincipalAxis = 1 self.pointSize = 6 self.alpha = 240 self.jitter = 0 self.showGridlines = 0 self.percCol = 100 self.percRow = 100 self.autoSend = 0 self.loadSettings() # GUI self.graph = OWGraph(self) self.graph.sendData = self.sendData self.mainArea.layout().addWidget(self.graph) self.controlAreaTab = OWGUI.tabWidget(self.controlArea) # Graph tab self.graphTab = graphTab = OWGUI.createTabPage(self.controlAreaTab, "Graph") self.colAttrCB = OWGUI.comboBox(graphTab, self, "colAttr", "Column Attribute", tooltip="Column attribute", callback=self.runCA) self.rowAttrCB = OWGUI.comboBox(graphTab, self, "rowAttr", "Row Attribute", tooltip="Row attribute", callback=self.runCA) self.xAxisCB = OWGUI.comboBox(graphTab, self, "xPrincipalAxis", "Principal Axis X", tooltip="Principal axis X", callback=self.updateGraph) self.yAxisCB = OWGUI.comboBox(graphTab, self, "yPrincipalAxis", "Principal Axis Y", tooltip="Principal axis Y", callback=self.updateGraph) box = OWGUI.widgetBox(graphTab, "Contribution to Inertia") self.contributionInfo = OWGUI.widgetLabel(box, "NA\nNA") OWGUI.hSlider( graphTab, self, "percCol", "Percent of Column Points", 1, 100, 1, callback=self.updateGraph, tooltip= "The percent of column points with the largest contribution to inertia" ) OWGUI.hSlider( graphTab, self, "percRow", "Percent of Row Points", 1, 100, 1, callback=self.updateGraph, tooltip= "The percent of row points with the largest contribution to inertia" ) self.zoomSelect = ZoomSelectToolbar(self, graphTab, self.graph, self.autoSend) OWGUI.rubber(graphTab) # Settings tab self.settingsTab = settingsTab = OWGUI.createTabPage( self.controlAreaTab, "Settings") OWGUI.hSlider(settingsTab, self, "pointSize", "Point Size", 3, 20, step=1, callback=self.setPointSize) OWGUI.hSlider(settingsTab, self, "alpha", "Transparancy", 1, 255, step=1, callback=self.updateAlpha) OWGUI.hSlider(settingsTab, self, "jitter", "Jitter Points", 0, 20, step=1, callback=self.updateGraph) box = OWGUI.widgetBox(settingsTab, "General Settings") OWGUI.checkBox(box, self, "showGridlines", "Show gridlines", tooltip="Show gridlines in the plot.", callback=self.updateGridlines) OWGUI.rubber(settingsTab) self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile) self.contingency = None self.contColAttr = None self.contRowAttr = None self.resize(800, 600)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'SampleData', wantMainArea = 0) self.inputs = [("Data", ExampleTable, self.setData)] self.outputs = [("Sample", ExampleTable), ("Remaining Examples", ExampleTable)] # initialization of variables self.data = None # dataset (incoming stream) self.indices = None # indices that control sampling self.ind = None # indices that control sampling self.Stratified = 1 # use stratified sampling if possible? self.Repeat = 0 # can elements repeat in a sample? self.UseSpecificSeed = 0 # use a specific random seed? self.RandomSeed = 1 # specific seed used self.GroupSeed = 1 # current seed for multiple group selection self.outFold = 1 # folder/group to output self.Folds = 1 # total number of folds/groups self.SelectType = 0 # sampling type (LOO, CV, ...) self.useCases = 0 # use a specific number of cases? self.nCases = 25 # number of cases to use self.selPercentage = 30 # sample size in % self.LOO = 1 # use LOO? self.CVFolds = 10 # number of CV folds self.CVFoldsInternal = 10 # number of CV folds (for internal use) self.nGroups = 3 # number of groups self.pGroups = [0.1,0.25,0.5] # sizes of groups self.GroupText = '0.1,0.25,0.5' # assigned to Groups Control (for internal use) self.loadSettings() # GUI # Info Box box1 = OWGUI.widgetBox(self.controlArea, "Information") 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') 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) OWGUI.separator(self.controlArea) # Sampling Type Box self.s = [None, None, None, None] self.sBox = OWGUI.widgetBox(self.controlArea, "Sampling type") self.sBox.buttons = [] # Random Sampling self.s[0] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", 'Random sampling') # repeat checkbox self.h1Box = OWGUI.indentedBox(self.sBox, orientation = "horizontal") OWGUI.checkBox(self.h1Box, self, 'Repeat', 'With replacement', callback=self.settingsChanged) # specified number of elements checkbox self.h2Box = OWGUI.indentedBox(self.sBox, 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, orientation = "horizontal") OWGUI.widgetLabel(self.h3Box, "Sample size:") self.slidebox = OWGUI.indentedBox(self.sBox, 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, 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, orientation = "horizontal") OWGUI.lineEdit(gbox, self, 'GroupText', label='Subset sizes (e.g. "0.1, 0.2, 0.5"):', callback=self.multipleChanged) # Output Group Box OWGUI.separator(self.controlArea) 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.separator(self.controlArea) self.sampleButton = OWGUI.button(self.controlArea, self, 'Sample &Data', callback = self.process) self.s[self.SelectType].setChecked(True) # set initial radio button on (default sample type) OWGUI.separator(self.controlArea) # 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, "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="Logistic regression"): OWWidget.__init__(self, parent, signalManager, name, wantMainArea=0, resizingEnabled=0) self.inputs = [("Examples", ExampleTable, self.setData)] 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", addSpace=True) stepwiseCb = OWGUI.checkBox(box, self, "stepwiseLR", "Stepwise attribute selection") ibox = OWGUI.indentedBox(box) 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() 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 __init__(self,parent=None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "Rank") self.inputs = [("Examples", ExampleTable, self.setData)] self.outputs = [("Reduced Example Table", ExampleTable, Default + Single), ("ExampleTable Attributes", ExampleTable, NonDefault)] self.settingsList += self.measuresAttrs self.logORIdx = self.measuresShort.index("log OR") self.nDecimals = 3 self.reliefK = 10 self.reliefN = 20 self.nIntervals = 4 self.sortBy = 0 self.selectMethod = 2 self.nSelected = 5 self.autoApply = True self.showDistributions = 1 self.distColorRgb = (220,220,220, 255) self.distColor = QColor(*self.distColorRgb) self.minmax = {} self.data = None for meas in self.measuresAttrs: setattr(self, meas, True) self.loadSettings() labelWidth = 80 box = OWGUI.widgetBox(self.controlArea, "Scoring", addSpace=True) for meas, valueName in zip(self.measures, self.measuresAttrs): if valueName == "computeReliefF": hbox = OWGUI.widgetBox(box, orientation = "horizontal") OWGUI.checkBox(hbox, self, valueName, meas, callback=self.measuresChanged) hbox.layout().addSpacing(5) smallWidget = OWGUI.SmallWidgetLabel(hbox, pixmap = 1, box = "ReliefF Parameters", tooltip = "Show ReliefF parameters") OWGUI.spin(smallWidget.widget, self, "reliefK", 1, 20, label="Neighbours", labelWidth=labelWidth, orientation=0, callback=self.reliefChanged, callbackOnReturn = True) OWGUI.spin(smallWidget.widget, self, "reliefN", 20, 100, label="Examples", labelWidth=labelWidth, orientation=0, callback=self.reliefChanged, callbackOnReturn = True) OWGUI.button(smallWidget.widget, self, "Load defaults", callback = self.loadReliefDefaults) OWGUI.rubber(hbox) else: OWGUI.checkBox(box, self, valueName, meas, callback=self.measuresChanged) OWGUI.separator(box) OWGUI.comboBox(box, self, "sortBy", label = "Sort by"+" ", items = ["No Sorting", "Attribute Name", "Number of Values"] + self.measures, orientation=0, valueType = int, callback=self.sortingChanged) box = OWGUI.widgetBox(self.controlArea, "Discretization", addSpace=True) OWGUI.spin(box, self, "nIntervals", 2, 20, label="Intervals: ", orientation=0, callback=self.discretizationChanged, callbackOnReturn = True) box = OWGUI.widgetBox(self.controlArea, "Precision", addSpace=True) OWGUI.spin(box, self, "nDecimals", 1, 6, label="No. of decimals: ", orientation=0, callback=self.decimalsChanged) box = OWGUI.widgetBox(self.controlArea, "Score bars", orientation="horizontal", addSpace=True) self.cbShowDistributions = OWGUI.checkBox(box, self, "showDistributions", 'Enable', callback = self.cbShowDistributions) # colBox = OWGUI.indentedBox(box, orientation = "horizontal") OWGUI.rubber(box) box = OWGUI.widgetBox(box, orientation="horizontal") wl = OWGUI.widgetLabel(box, "Color: ") OWGUI.separator(box) self.colButton = OWGUI.toolButton(box, self, self.changeColor, width=20, height=20, debuggingEnabled = 0) self.cbShowDistributions.disables.extend([wl, self.colButton]) self.cbShowDistributions.makeConsistent() # OWGUI.rubber(box) selMethBox = OWGUI.widgetBox(self.controlArea, "Select attributes", addSpace=True) self.clearButton = OWGUI.button(selMethBox, self, "Clear", callback=self.clearSelection) self.clearButton.setDisabled(True) buttonGrid = QGridLayout() selMethRadio = OWGUI.radioButtonsInBox(selMethBox, self, "selectMethod", [], callback=self.selectMethodChanged) b1 = OWGUI.appendRadioButton(selMethRadio, self, "selectMethod", "All", insertInto=selMethRadio, callback=self.selectMethodChanged, addToLayout=False) b2 = OWGUI.appendRadioButton(selMethRadio, self, "selectMethod", "Manual", insertInto=selMethRadio, callback=self.selectMethodChanged, addToLayout=False) b3 = OWGUI.appendRadioButton(selMethRadio, self, "selectMethod", "Best ranked", insertInto=selMethRadio, callback=self.selectMethodChanged, addToLayout=False) # brBox = OWGUI.widgetBox(selMethBox, orientation="horizontal", margin=0) # OWGUI.appendRadioButton(selMethRadio, self, "selectMethod", "Best ranked", insertInto=brBox, callback=self.selectMethodChanged) spin = OWGUI.spin(OWGUI.widgetBox(selMethRadio, addToLayout=False), self, "nSelected", 1, 100, orientation=0, callback=self.nSelectedChanged) buttonGrid.addWidget(b1, 0, 0) buttonGrid.addWidget(b2, 1, 0) buttonGrid.addWidget(b3, 2, 0) buttonGrid.addWidget(spin, 2, 1) selMethRadio.layout().addLayout(buttonGrid) OWGUI.separator(selMethBox) applyButton = OWGUI.button(selMethBox, self, "Commit", callback = self.apply) autoApplyCB = OWGUI.checkBox(selMethBox, self, "autoApply", "Commit automatically") OWGUI.setStopper(self, applyButton, autoApplyCB, "dataChanged", self.apply) OWGUI.rubber(self.controlArea) self.table = QTableWidget() self.mainArea.layout().addWidget(self.table) self.table.setSelectionBehavior(QAbstractItemView.SelectRows) self.table.setSelectionMode(QAbstractItemView.MultiSelection) self.table.verticalHeader().setResizeMode(QHeaderView.ResizeToContents) self.table.setItemDelegate(RankItemDelegate(self, self.table)) self.topheader = self.table.horizontalHeader() self.topheader.setSortIndicatorShown(1) self.topheader.setHighlightSections(0) self.setMeasures() self.resetInternals() self.connect(self.table.horizontalHeader(), SIGNAL("sectionClicked(int)"), self.headerClick) self.connect(self.table, SIGNAL("clicked (const QModelIndex&)"), self.selectItem) self.connect(self.table, SIGNAL("itemSelectionChanged()"), self.onSelectionChanged) self.resize(690,500) self.updateColor()
def __init__(self,parent=None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "Mosaic display", True, True) #set default settings self.data = None self.unprocessedSubsetData = None self.subsetData = None self.names = [] # class values self.inputs = [("Data", ExampleTable, self.setData, Default), ("Data Subset", ExampleTable, self.setSubsetData)] self.outputs = [("Selected Data", ExampleTable), ("Learner", orange.Learner)] #load settings self.colorSettings = None self.selectedSchemaIndex = 0 self.interiorColoring = 0 self.cellspace = 4 self.showAprioriDistributionBoxes = 1 self.useBoxes = 1 self.showSubsetDataBoxes = 1 self.horizontalDistribution = 0 self.showAprioriDistributionLines = 0 self.boxSize = 5 self.exploreAttrPermutations = 0 self.attr1 = "" self.attr2 = "" self.attr3 = "" self.attr4 = "" self.attributeNameOffset = 30 self.attributeValueOffset = 15 self.residuals = [] # residual values if the residuals are visualized self.aprioriDistributions = [] self.colorPalette = None self.permutationDict = {} self.manualAttributeValuesDict = {} self.conditionalDict = None self.conditionalSubsetDict = None self.activeRule = None self.removeUnusedValues = 0 self.selectionRectangle = None self.selectionConditionsHistorically = [] self.selectionConditions = [] # color paletes for visualizing pearsons residuals #self.blueColors = [QColor(255, 255, 255), QColor(117, 149, 255), QColor(38, 43, 232), QColor(1,5,173)] self.blueColors = [QColor(255, 255, 255), QColor(210, 210, 255), QColor(110, 110, 255), QColor(0,0,255)] self.redColors = [QColor(255, 255, 255), QColor(255, 200, 200), QColor(255, 100, 100), QColor(255, 0, 0)] self.loadSettings() self.tabs = OWGUI.tabWidget(self.controlArea) self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main") self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings") self.canvas = QGraphicsScene() self.canvasView = MosaicSceneView(self, self.canvas, self.mainArea) self.mainArea.layout().addWidget(self.canvasView) self.canvasView.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.canvasView.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.canvasView.setRenderHint(QPainter.Antialiasing) #self.canvasView.setAlignment(Qt.AlignLeft | Qt.AlignTop) #GUI #add controls to self.controlArea widget #self.controlArea.setMinimumWidth(235) texts = ["1st Attribute", "2nd Attribute", "3rd Attribute", "4th Attribute"] for i in range(1,5): box = OWGUI.widgetBox(self.GeneralTab, texts[i-1], orientation = "horizontal") combo = OWGUI.comboBox(box, self, "attr" + str(i), None, callback = self.updateGraphAndPermList, sendSelectedValue = 1, valueType = str) butt = OWGUI.button(box, self, "", callback = self.orderAttributeValues, tooltip = "Change the order of attribute values", debuggingEnabled = 0) butt.setFixedSize(26, 24) butt.setCheckable(1) butt.setIcon(QIcon(os.path.join(self.widgetDir, "icons/Dlg_sort.png"))) setattr(self, "sort"+str(i), butt) setattr(self, "attr" + str(i)+ "Combo", combo) self.optimizationDlg = OWMosaicOptimization(self, self.signalManager) optimizationButtons = OWGUI.widgetBox(self.GeneralTab, "Dialogs", orientation = "horizontal") OWGUI.button(optimizationButtons, self, "VizRank", callback = self.optimizationDlg.reshow, debuggingEnabled = 0, tooltip = "Find attribute combinations that will separate different classes as clearly as possible.") self.collapsableWBox = OWGUI.collapsableWidgetBox(self.GeneralTab, "Explore Attribute Permutations", self, "exploreAttrPermutations", callback = self.permutationListToggle) self.permutationList = OWGUI.listBox(self.collapsableWBox, self, callback = self.setSelectedPermutation) #self.permutationList.hide() self.GeneralTab.layout().addStretch(100) # ###################### # SETTINGS TAB # ###################### box5 = OWGUI.widgetBox(self.SettingsTab, "Colors in Cells Represent...", addSpace = 1) OWGUI.comboBox(box5, self, "interiorColoring", None, items = self.interiorColoringOpts, callback = self.updateGraph) #box5.setSizePolicy(QSizePolicy(QSizePolicy.Minimum , QSizePolicy.Fixed )) box = OWGUI.widgetBox(self.SettingsTab, "Visual Settings", addSpace = 1) OWGUI.hSlider(box, self, 'cellspace', label = "Cell distance: ", minValue=1, maxValue=15, step=1, callback = self.updateGraph, tooltip = "What is the minimum distance between two rectangles in the plot?") OWGUI.checkBox(box, self, "removeUnusedValues", "Remove unused attribute values", tooltip = "Do you want to remove unused attribute values?\nThis setting will not be considered until new data is received.") self.box6 = OWGUI.widgetBox(self.SettingsTab, "Cell Distribution Settings", addSpace = 1) OWGUI.comboBox(self.box6, self, 'horizontalDistribution', items = ["Show Distribution Vertically", "Show Distribution Horizontally"], tooltip = "Do you wish to see class distribution drawn horizontally or vertically?", callback = self.updateGraph) OWGUI.checkBox(self.box6, self, 'showAprioriDistributionLines', 'Show apriori distribution with lines', callback = self.updateGraph, tooltip = "Show the lines that represent the apriori class distribution") self.box8 = OWGUI.widgetBox(self.SettingsTab, "Boxes in Cells", addSpace = 1) OWGUI.hSlider(self.box8, self, 'boxSize', label = "Size: ", minValue=1, maxValue=15, step=1, callback = self.updateGraph, tooltip = "What is the size of the boxes on the left and right edge of each cell?") OWGUI.checkBox(self.box8, self, 'showSubsetDataBoxes', 'Show class distribution of subset data', callback = self.updateGraph, tooltip = "Show small boxes at right (or bottom) edge of cells to represent class distribution of examples from example subset input.") cb = OWGUI.checkBox(self.box8, self, 'useBoxes', 'Use boxes on left to show...', callback = self.updateGraph, tooltip = "Show small boxes at left (or top) edge of cells to represent additional information.") indBox = OWGUI.indentedBox(self.box8, sep=OWGUI.checkButtonOffsetHint(cb)) OWGUI.comboBox(indBox, self, 'showAprioriDistributionBoxes', items = self.subboxesOpts, tooltip = "Show additional boxes for each mosaic cell representing:\n - expected class distribution (assuming independence between attributes)\n - apriori class distribution (based on all examples).", callback = self.updateGraph) hbox = OWGUI.widgetBox(self.SettingsTab, "Colors", addSpace = 1) OWGUI.button(hbox, self, "Set Colors", self.setColors, tooltip = "Set the color palette for class values", debuggingEnabled = 0) #self.box6.setSizePolicy(QSizePolicy(QSizePolicy.Minimum , QSizePolicy.Fixed )) self.SettingsTab.layout().addStretch(1) self.connect(self.graphButton, SIGNAL("clicked()"), self.saveToFileCanvas) self.icons = self.createAttributeIconDict() self.resize(830, 550) self.VizRankLearner = MosaicTreeLearner(self.optimizationDlg) self.send("Learner", self.VizRankLearner) self.wdChildDialogs = [self.optimizationDlg] # used when running widget debugging self.collapsableWBox.updateControls() dlg = self.createColorDialog() self.colorPalette = dlg.getDiscretePalette("discPalette") self.selectionColorPalette = [QColor(*col) for col in OWColorPalette.defaultRGBColors]
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "FeatureConstructor") self.inputs = [("Data", orange.ExampleTable, self.setData)] self.outputs = [("Data", ExampleTable)] self.expression = self.attrname = "" self.selected_def = [] self.def_labels = [] self.data = None self.definitions = [] self.selected_features = 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, "selected_features", items=["(all attributes)"], callback=self.feature_list_selected) sortedFuncs = sorted(m for m in 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( inspect.getdoc(AttrComputer.FUNCTIONS[func])) hb = OWGUI.widgetBox(db, None, "horizontal", addSpace=True) OWGUI.button(hb, self, "Add", callback=self.addAttr, autoDefault=True) OWGUI.button(hb, self, "Update", callback=self.updateAttr) OWGUI.button(hb, self, "Remove", callback=self.remove_feature) OWGUI.button(hb, self, "Remove All", callback=self.remove_all_features) self.lbDefinitions = OWGUI.listBox(db, self, "selected_def", "def_labels", callback=self.select_feature) 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="Pade"): OWWidget.__init__(self, parent, signalManager, name, wantMainArea=0) #initialize base class self.inputs = [("Examples", ExampleTable, self.onDataInput)] self.outputs = [("Examples", ExampleTable)] self.attributes = [] self.dimensions = [] self.output = 0 self.outputAttr = 0 self.derivativeAsMeta = 0 self.savedDerivativeAsMeta = 0 self.correlationsAsMeta = 1 self.differencesAsMeta = 1 self.originalAsMeta = 1 self.enableThreshold = 0 self.threshold = 0.0 self.method = 2 self.useMQCNotation = False #self.persistence = 40 self.nNeighbours = 30 self.loadSettings() box = OWGUI.widgetBox(self.controlArea, "Attributes", addSpace=True) lb = self.lb = OWGUI.listBox(box, self, "dimensions", "attributes", selectionMode=QListWidget.MultiSelection, callback=self.dimensionsChanged) hbox = OWGUI.widgetBox(box, orientation=0) OWGUI.button(hbox, self, "All", callback=self.onAllAttributes) OWGUI.button(hbox, self, "None", callback=self.onNoAttributes) lb.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) lb.setMinimumSize(200, 200) box = OWGUI.widgetBox(self.controlArea, "Method", addSpace=24) OWGUI.comboBox(box, self, "method", callback=self.methodChanged, items=self.methodNames) # self.nNeighboursSpin = OWGUI.spin(box, self, "nNeighbours", 10, 200, 10, label = "Number of neighbours" + " ", callback = self.methodChanged) #self.persistenceSpin = OWGUI.spin(box, self, "persistence", 0, 100, 5, label = "Persistence (0-100)" + " ", callback = self.methodChanged, controlWidth=50) OWGUI.separator(box) hbox = OWGUI.widgetBox(box, orientation=0) threshCB = OWGUI.checkBox(hbox, self, "enableThreshold", "Ignore differences below ") # OWGUI.rubber(hbox, orientation = 0) ledit = OWGUI.lineEdit(hbox, self, "threshold", valueType=float, validator=QDoubleValidator(0, 1e30, 0, self), controlWidth=50) threshCB.disables.append(ledit) threshCB.makeConsistent() OWGUI.checkBox(box, self, "useMQCNotation", label="Use MQC notation") box = OWGUI.radioButtonsInBox(self.controlArea, self, "output", self.outputTypes, box="Output class", addSpace=True, callback=self.dimensionsChanged) self.outputLB = OWGUI.comboBox(OWGUI.indentedBox(box), self, "outputAttr", callback=self.outputDiffChanged) box = OWGUI.widgetBox(self.controlArea, "Output meta attributes", addSpace=True) self.metaCB = OWGUI.checkBox(box, self, "derivativeAsMeta", label="Qualitative constraint") OWGUI.checkBox(box, self, "differencesAsMeta", label="Derivatives of selected attributes") OWGUI.checkBox(box, self, "correlationsAsMeta", label="Absolute values of derivatives") OWGUI.checkBox(box, self, "originalAsMeta", label="Original class attribute") self.applyButton = OWGUI.button(self.controlArea, self, "&Apply", callback=self.apply)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "Parallel Coordinates", TRUE) #add a graph widget self.graph = OWParallelGraph(self, self.mainArea) self.mainArea.layout().addWidget(self.graph) self.showAllAttributes = 0 self.inputs = [("Examples", ExampleTable, self.setData, Default), ("Example Subset", ExampleTable, self.setSubsetData), ("Attribute Selection List", AttributeList, self.setShownAttributes)] self.outputs = [("Selected Examples", ExampleTable), ("Unselected Examples", ExampleTable), ("Attribute Selection List", AttributeList)] #set default settings self.data = None self.subsetData = None self.autoSendSelection = 1 self.attrDiscOrder = "Unordered" self.attrContOrder = "Unordered" self.projections = None self.correlationDict = {} self.middleLabels = "Correlations" self.attributeSelectionList = None self.toolbarSelection = 0 self.colorSettings = None self.selectedSchemaIndex = 0 self.graph.jitterSize = 10 self.graph.showDistributions = 1 self.graph.showStatistics = 0 self.graph.showAttrValues = 1 self.graph.useSplines = 0 self.graph.enabledLegend = 1 #load settings self.loadSettings() #GUI self.tabs = OWGUI.tabWidget(self.controlArea) self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main") self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings") self.createShowHiddenLists(self.GeneralTab, callback=self.updateGraph) self.connect(self.shownAttribsLB, SIGNAL('itemDoubleClicked(QListWidgetItem*)'), self.flipAttribute) self.optimizationDlg = ParallelOptimization( self, signalManager=self.signalManager) self.optimizationDlgButton = OWGUI.button( self.GeneralTab, self, "Optimization Dialog", callback=self.optimizationDlg.reshow, debuggingEnabled=0) self.zoomSelectToolbar = OWToolbars.ZoomSelectToolbar( self, self.GeneralTab, self.graph, self.autoSendSelection, buttons=(1, 2, 0, 7, 8)) self.connect(self.zoomSelectToolbar.buttonSendSelections, SIGNAL("clicked()"), self.sendSelections) #connect controls to appropriate functions self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile) # #################################### # SETTINGS functionality box = OWGUI.widgetBox(self.SettingsTab, "Transparency") OWGUI.hSlider(box, self, 'graph.alphaValue', label="Examples: ", minValue=0, maxValue=255, step=10, callback=self.updateGraph, tooltip="Alpha value used for drawing example lines") OWGUI.hSlider( box, self, 'graph.alphaValue2', label="Rest: ", minValue=0, maxValue=255, step=10, callback=self.updateGraph, tooltip="Alpha value used to draw statistics, example subsets, ..." ) box = OWGUI.widgetBox(self.SettingsTab, "Jittering Options") OWGUI.comboBox(box, self, "graph.jitterSize", label='Jittering size (% of size): ', orientation='horizontal', callback=self.setJitteringSize, items=self.jitterSizeNums, sendSelectedValue=1, valueType=float) # visual settings box = OWGUI.widgetBox(self.SettingsTab, "Visual Settings") OWGUI.checkBox(box, self, 'graph.showAttrValues', 'Show attribute values', callback=self.updateGraph) OWGUI.checkBox(box, self, 'graph.useAntialiasing', 'Use antialiasing', callback=self.updateGraph) OWGUI.checkBox(box, self, 'graph.useSplines', 'Show splines', callback=self.updateGraph, tooltip="Show lines using splines") OWGUI.checkBox(box, self, 'graph.enabledLegend', 'Show legend', callback=self.updateGraph) box = OWGUI.widgetBox(self.SettingsTab, "Axis Distance") resizeColsBox = OWGUI.widgetBox(box, 0, "horizontal", 0) OWGUI.label(resizeColsBox, self, "Increase/decrease distance: ") b = OWGUI.toolButton(resizeColsBox, self, self.increaseAxesDistance, tooltip="Increase the distance between the axes", width=30, height=20) b.setText("+") b = OWGUI.toolButton(resizeColsBox, self, self.decreaseAxesDistance, tooltip="Decrease the distance between the axes", width=30, height=20) b.setText("-") OWGUI.rubber(resizeColsBox) OWGUI.checkBox( box, self, "graph.autoUpdateAxes", "Auto scale X axis", tooltip="Auto scale X axis to show all visualized attributes", callback=self.updateGraph) box = OWGUI.widgetBox(self.SettingsTab, "Statistical Information") OWGUI.comboBox( box, self, "graph.showStatistics", label="Statistics: ", orientation="horizontal", labelWidth=90, items=["No statistics", "Means, deviations", "Median, quartiles"], callback=self.updateGraph, sendSelectedValue=0, valueType=int) OWGUI.comboBox( box, self, "middleLabels", label="Middle labels: ", orientation="horizontal", labelWidth=90, items=["No labels", "Correlations", "VizRank"], callback=self.updateGraph, tooltip= "The information do you wish to view on top in the middle of coordinate axes", sendSelectedValue=1, valueType=str) OWGUI.checkBox( box, self, 'graph.showDistributions', 'Show distributions', callback=self.updateGraph, tooltip= "Show bars with distribution of class values (only for discrete attributes)" ) box = OWGUI.widgetBox(self.SettingsTab, "Colors", orientation="horizontal") OWGUI.button( box, self, "Set colors", self.setColors, tooltip= "Set the canvas background color and color palette for coloring continuous variables", debuggingEnabled=0) box = OWGUI.widgetBox(self.SettingsTab, "Auto Send Selected Data When...") OWGUI.checkBox( box, self, 'autoSendSelection', 'Adding/Removing selection areas', callback=self.selectionChanged, tooltip= "Send selected data whenever a selection area is added or removed") OWGUI.checkBox( box, self, 'graph.sendSelectionOnUpdate', 'Moving/Resizing selection areas', tooltip= "Send selected data when a user moves or resizes an existing selection area" ) self.graph.autoSendSelectionCallback = self.selectionChanged self.SettingsTab.layout().addStretch(100) self.icons = self.createAttributeIconDict() dlg = self.createColorDialog() self.graph.contPalette = dlg.getContinuousPalette("contPalette") self.graph.discPalette = dlg.getDiscretePalette("discPalette") self.graph.setCanvasBackground(dlg.getColor("Canvas")) [ self.zoomSelectToolbar.actionZooming, self.zoomSelectToolbar.actionRectangleSelection, self.zoomSelectToolbar.actionPolygonSelection ][self.toolbarSelection](*[]) self.cbShowAllAttributes() self.resize(900, 700)
def __init__(self, parent=None, signalManager=None, name='kNN'): OWWidget.__init__(self, parent, signalManager, name, wantMainArea=0, resizingEnabled=0) self.callbackDeposit = [] self.inputs = [("Examples", ExampleTable, self.setData)] 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) self.resize(100, 250)
def __init__(self, parent=None, signalManager=None, name="Select data"): OWWidget.__init__(self, parent, signalManager, name, wantMainArea=0) #initialize base class self.inputs = [("Examples", ExampleTable, self.setData)] self.outputs = [("Matching Examples", ExampleTable, Default), ("Non-Matching Examples", 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") self.lblAndCon = OWGUI.widgetLabel(boxVal, "and") self.leNum2 = OWGUI.lineEdit(boxVal, self, "Num2") 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) 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)