def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'LearningCurveC') self.inputs = [("Data", ExampleTable, self.dataset), ("Learner", orange.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.AttributeWarning) self.setCurvePoints( ) # sets self.curvePoints, self.steps equidistantpoints from 1/self.steps to 1 self.scoring = [("Classification Accuracy", orngStat.CA), ("AUC", orngStat.AUC), ("BrierScore", orngStat.BrierScore), ("Information Score", orngStat.IS), ("Sensitivity", orngStat.sens), ("Specificity", orngStat.spec)] self.learners = [ ] # list of current learners from input channel, tuples (id, learner) self.data = None # data on which to construct the learning curve self.curves = [ ] # list of evaluation results (one per learning curve point) self.scores = [] # list of current scores, learnerID:[learner scores] # GUI box = OWGUI.widgetBox(self.controlArea, "Info") self.infoa = OWGUI.widgetLabel(box, 'No data on input.') self.infob = OWGUI.widgetLabel(box, 'No learners.') ## class selection (classQLB) OWGUI.separator(self.controlArea) self.cbox = OWGUI.widgetBox(self.controlArea, "Learners") self.llb = OWGUI.listBox(self.cbox, self, "selectedLearners", selectionMode=QListWidget.MultiSelection, callback=self.learnerSelectionChanged) self.llb.setMinimumHeight(50) self.blockSelectionChanges = 0 OWGUI.separator(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Evaluation Scores") scoringNames = [x[0] for x in self.scoring] OWGUI.comboBox(box, self, "scoringF", items=scoringNames, callback=self.computeScores) OWGUI.separator(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Options") OWGUI.spin(box, self, 'folds', 2, 100, step=1, label='Cross validation folds: ', callback=lambda: self.computeCurve(self.commitOnChange)) OWGUI.spin(box, self, 'steps', 2, 100, step=1, label='Learning curve points: ', callback=[ self.setCurvePoints, lambda: self.computeCurve(self.commitOnChange) ]) OWGUI.checkBox(box, self, 'commitOnChange', 'Apply setting on any change') self.commitBtn = OWGUI.button(box, self, "Apply Setting", callback=self.computeCurve, disabled=1) # start of content (right) area tabs = OWGUI.tabWidget(self.mainArea) # graph widget tab = OWGUI.createTabPage(tabs, "Graph") self.graph = OWGraph(tab) self.graph.setAxisAutoScale(QwtPlot.xBottom) self.graph.setAxisAutoScale(QwtPlot.yLeft) tab.layout().addWidget(self.graph) self.setGraphGrid() # table widget tab = OWGUI.createTabPage(tabs, "Table") self.table = OWGUI.table(tab, selectionMode=QTableWidget.NoSelection) self.resize(550, 200)
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)