def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "FeatureConstructor") # To enable the use of primary table, uncomment the next line and comment the following one # self.inputs = [("Primary Table", dataUtilities.DataTable, self.setData), ("Additional Tables", dataUtilities.DataTable, self.setMoreData, Multiple)] self.inputs = [("Tables", orange.ExampleTable, self.setMoreData, Multiple)] self.outputs = [("Examples", ExampleTable)] self.mergeAttributes = 0 self.primary = None self.additional = {} bg = self.bgMerge = OWGUI.radioButtonsInBox( self.controlArea, self, "mergeAttributes", [], "Domains merging", callback=self.apply ) OWGUI.widgetLabel(bg, "") # "When there is no primary table, the domain should be") OWGUI.appendRadioButton(bg, self, "mergeAttributes", "Union of attributes appearing in all tables") OWGUI.appendRadioButton(bg, self, "mergeAttributes", "Intersection of attributes in all tables") # OWGUI.widgetLabel(bg, "The resulting table will have class only if there is no conflict betwen input classes.") infoBox = OWGUI.widgetBox(self, "Concatenate status") self.infoStatus = OWGUI.widgetLabel(infoBox, "") self.viewBT = OWGUI.button( self.controlArea, self, "&View converted incompatible attributes", callback=self.viewIncompatible, disabled=1, ) self.adjustSize()
def __init__(self, parent=None, 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): BaseEditor.__init__(self, parent) self.measureInd = 0 self.selectBy = 0 self.bestN = 10 self.bestP = 10 box = OWGUI.radioButtonsInBox(self, self, "selectBy", [], "Feature selection", callback=self.onChange) OWGUI.comboBox(box, self, "measureInd", items=[name for (name, _) in self.MEASURES], label="Measure", callback=self.onChange) hbox1 = OWGUI.widgetBox(box, orientation="horizontal", margin=0) rb1 = OWGUI.appendRadioButton(box, self, "selectBy", "Best", insertInto=hbox1, callback=self.onChange) self.spin1 = OWGUI.spin(OWGUI.widgetBox(hbox1), self, "bestN", 1, 10000, step=1, controlWidth=75, callback=self.onChange, posttext="features") OWGUI.rubber(hbox1) hbox2 = OWGUI.widgetBox(box, orientation="horizontal", margin=0) rb2 = OWGUI.appendRadioButton(box, self, "selectBy", "Best", insertInto=hbox2, callback=self.onChange) self.spin2 = OWGUI.spin(OWGUI.widgetBox(hbox2), self, "bestP", 1, 100, step=1, controlWidth=75, callback=self.onChange, posttext="% features") OWGUI.rubber(hbox2) self.updateSpinStates() OWGUI.rubber(box)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "Concatenate", wantMainArea=0) self.inputs = [("Primary Table", orange.ExampleTable, self.setData), ("Additional Tables", orange.ExampleTable, self.setMoreData, Multiple)] self.outputs = [("Examples", ExampleTable)] self.mergeAttributes = 0 self.primary = None self.additional = {} bg = self.bgMerge = OWGUI.radioButtonsInBox(self.controlArea, self, "mergeAttributes", [], "Domains merging", callback=self.apply) OWGUI.widgetLabel( bg, "When there is no primary table, the domain should be:") OWGUI.appendRadioButton(bg, self, "mergeAttributes", "Union of attributes appearing in all tables") OWGUI.appendRadioButton(bg, self, "mergeAttributes", "Intersection of attributes in all tables") OWGUI.widgetLabel( bg, "The resulting table will have class only if there is no conflict between input classes." ) self.adjustSize()
def __init__(self, parent=None): BaseEditor.__init__(self, parent) self.discInd = 0 self.numberOfIntervals = 3 # box = OWGUI.widgetBox(self, "Discretize") rb = OWGUI.radioButtonsInBox(self, self, "discInd", [], box="Discretize", callback=self.onChange) for label, _, _ in self.DISCRETIZERS[:-1]: OWGUI.appendRadioButton(rb, self, "discInd", label) self.sliderBox = OWGUI.widgetBox( OWGUI.indentedBox(rb, sep=OWGUI.checkButtonOffsetHint(rb.buttons[-1])), "Num. of intervals (for equal width/frequency)") OWGUI.hSlider(self.sliderBox, self, "numberOfIntervals", callback=self.onChange, minValue=1) OWGUI.appendRadioButton(rb, self, "discInd", self.DISCRETIZERS[-1][0]) OWGUI.rubber(rb) self.updateSliderBox()
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "FeatureConstructor") self.inputs = [("Primary Table", orange.ExampleTable, self.setData), ("Additional Tables", orange.ExampleTable, self.setMoreData, Multiple)] self.outputs = [("Examples", ExampleTable)] self.mergeAttributes = 0 self.dataSourceSelected = 1 self.addIdAs = 0 self.dataSourceName = "clusterId" self.primary = None self.additional = {} self.loadSettings() bg = self.bgMerge = OWGUI.radioButtonsInBox(self.controlArea, self, "mergeAttributes", [], "Domains merging", callback=self.apply) OWGUI.widgetLabel( bg, "When there is no primary table, the domain should be") OWGUI.appendRadioButton(bg, self, "mergeAttributes", "Union of attributes appearing in all tables") OWGUI.appendRadioButton(bg, self, "mergeAttributes", "Intersection of attributes in all tables") OWGUI.widgetLabel( bg, "The resulting table will have class only if there is no conflict betwen input classes." ) box = OWGUI.widgetBox(self.controlArea, "Data source IDs") cb = OWGUI.checkBox(box, self, "dataSourceSelected", "Append data source IDs") self.classificationBox = ib = OWGUI.widgetBox(box) le = OWGUI.lineEdit(ib, self, "dataSourceName", "Name" + " ", orientation='horizontal', valueType=str) OWGUI.separator(ib, height=4) aa = OWGUI.comboBox( ib, self, "addIdAs", label="Place" + " ", orientation='horizontal', items=["Class attribute", "Attribute", "Meta attribute"]) cb.disables.append(ib) cb.makeConsistent() OWGUI.separator(box) OWGUI.button(box, self, "Apply Changes", callback=self.apply) self.adjustSize()
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "Pubmed Network View", wantMainArea=0) self.inputs = [] self.outputs = [("Nx View", Orange.network.NxView)] self._nhops = 2 self._edge_threshold = 0.5 self._n_max_neighbors = 20 self.selected_titles = [] self.titles = [] self.filter = "" self.ids = [] self._selected_nodes = [] self._algorithm = 0 self._k_algorithm = 0.3 self.loadSettings() box = OWGUI.widgetBox(self.controlArea, "Paper Selection", orientation="vertical") OWGUI.lineEdit(box, self, "filter", callback=self.filter_list, callbackOnType=True) self.list_titles = OWGUI.listBox( box, self, "selected_titles", "titles", selectionMode=QListWidget.MultiSelection, callback=self.update_view ) OWGUI.separator(self.controlArea) box_pref = OWGUI.widgetBox(self.controlArea, "Preferences", orientation="vertical") OWGUI.spin(box_pref, self, "_nhops", 1, 6, 1, label="Number of hops: ", callback=self.update_view) OWGUI.spin( box_pref, self, "_n_max_neighbors", 1, 100, 1, label="Max number of neighbors: ", callback=self.update_view ) OWGUI.doubleSpin( box_pref, self, "_edge_threshold", 0, 1, step=0.01, label="Edge threshold: ", callback=self.update_view ) OWGUI.separator(self.controlArea) box_alg = OWGUI.widgetBox(self.controlArea, "Interest Propagation Algorithm", orientation="vertical") radio_box = OWGUI.radioButtonsInBox(box_alg, self, "_algorithm", [], callback=self.update_view) OWGUI.appendRadioButton(radio_box, self, "_algorithm", "Without Clustering", callback=self.update_view) OWGUI.doubleSpin( OWGUI.indentedBox(radio_box), self, "_k_algorithm", 0, 1, step=0.01, label="Parameter k: ", callback=self.update_view, ) OWGUI.appendRadioButton(radio_box, self, "_algorithm", "With Clustering", callback=self.update_view) self.inside_view = PubmedNetworkView(self) self.send("Nx View", self.inside_view)
def __init__(self,parent=None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "Concatenate", wantMainArea=False, resizingEnabled=False) self.inputs = [("Primary Data", orange.ExampleTable, self.setData), ("Additional Data", orange.ExampleTable, self.setMoreData, Multiple)] self.outputs = [("Data", ExampleTable)] self.mergeAttributes = 0 self.dataSourceSelected = 1 self.addIdAs = 0 self.dataSourceName = "clusterId" self.primary = None self.additional = {} self.loadSettings() bg = self.bgMerge = OWGUI.radioButtonsInBox(self.controlArea, self, "mergeAttributes", [], "Domains merging", callback = self.apply) OWGUI.widgetLabel(bg, "When there is no primary table, the domain should be") OWGUI.appendRadioButton(bg, self, "mergeAttributes", "Union of attributes appearing in all tables") OWGUI.appendRadioButton(bg, self, "mergeAttributes", "Intersection of attributes in all tables") bg.layout().addSpacing(6) label = OWGUI.widgetLabel(bg, "The resulting table will have class only if there is no conflict between input classes.") label.setWordWrap(True) OWGUI.separator(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Data source IDs", addSpace=True) cb = OWGUI.checkBox(box, self, "dataSourceSelected", "Append data source IDs") self.classificationBox = ib = OWGUI.indentedBox(box, sep=OWGUI.checkButtonOffsetHint(cb)) form = QFormLayout( spacing=8, labelAlignment=Qt.AlignLeft, formAlignment=Qt.AlignLeft, fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow ) ib.layout().addLayout(form) form.addRow("Name", OWGUI.lineEdit(ib, self, "dataSourceName", valueType=str)) aa = OWGUI.comboBox(ib, self, "addIdAs", items=["Class attribute", "Attribute", "Meta attribute"]) cb.disables.append(ib) cb.makeConsistent() form.addRow("Place", aa) OWGUI.button(self.controlArea, self, "Apply Changes", callback = self.apply, default=True) OWGUI.rubber(self.controlArea) self.adjustSize() self.dataReport = None
def __init__(self, parent=None): BaseEditor.__init__(self, parent) self.methodInd = 0 self.sampleN = 100 self.sampleP = 25 box = OWGUI.radioButtonsInBox(self, self, "methodInd", [], box="Sample", callback=self.onChange) w1 = OWGUI.widgetBox(box, orientation="horizontal", margin=0) rb1 = OWGUI.appendRadioButton(box, self, "methodInd", "Sample", insertInto=w1) self.sb1 = OWGUI.spin(OWGUI.widgetBox(w1), self, "sampleN", min=1, max=100000, step=1, controlWidth=75, callback=self.onChange, posttext="data instances") OWGUI.rubber(w1) w2 = OWGUI.widgetBox(box, orientation="horizontal", margin=0) rb2 = OWGUI.appendRadioButton(box, self, "methodInd", "Sample", insertInto=w2) self.sb2 = OWGUI.spin(OWGUI.widgetBox(w2), self, "sampleP", min=1, max=100, step=1, controlWidth=75, callback=self.onChange, posttext="% data instances") OWGUI.rubber(w2) self.updateSpinStates() OWGUI.rubber(box)
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, name='AttributeDistance'): self.callbackDeposit = [] # deposit for OWGUI callback functions OWWidget.__init__(self, parent, signalManager, name, wantMainArea=0, resizingEnabled=0) self.inputs = [("Examples", ExampleTable, self.dataset)] self.outputs = [("Distance Matrix", orange.SymMatrix)] self.data = None self.classInteractions = 0 self.loadSettings() rb = OWGUI.radioButtonsInBox(self.controlArea, self, "classInteractions", [], "Distance", callback=self.toggleClass) OWGUI.widgetLabel( rb, "Measures on discrete attributes\n (continuous attributes are discretized into five intervals)" ) for b in self.discMeasures: OWGUI.appendRadioButton(rb, self, "classInteractions", b) OWGUI.widgetLabel( rb, "\n" + "Measures on continuous attributes\n (discrete attributes are treated as ordinal)" ) for b in self.contMeasures: OWGUI.appendRadioButton(rb, self, "classInteractions", b) OWGUI.rubber(self.controlArea) self.resize(215, 50)
def __init__(self, parent=None, signalManager = None, name='AttributeDistance'): self.callbackDeposit = [] # deposit for OWGUI callback functions OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0, resizingEnabled = 0) self.inputs = [("Data", ExampleTable, self.dataset)] self.outputs = [("Distances", orange.SymMatrix)] self.data = None self.classInteractions = 0 self.loadSettings() rb = OWGUI.radioButtonsInBox(self.controlArea, self, "classInteractions", [], "Distance", callback=self.toggleClass) OWGUI.widgetLabel(rb, "Measures on discrete attributes\n (continuous attributes are discretized into five intervals)") for b in self.discMeasures: OWGUI.appendRadioButton(rb, self, "classInteractions", b) OWGUI.widgetLabel(rb, "\n"+"Measures on continuous attributes\n (discrete attributes are treated as ordinal)") for b in self.contMeasures: OWGUI.appendRadioButton(rb, self, "classInteractions", b) OWGUI.rubber(self.controlArea) self.resize(215,50)
def __init__(self,parent=None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "Concatenate", wantMainArea=0) self.inputs = [("Primary Data", orange.ExampleTable, self.setData), ("Additional Data", orange.ExampleTable, self.setMoreData, Multiple)] self.outputs = [("Data", ExampleTable)] self.mergeAttributes = 0 self.dataSourceSelected = 1 self.addIdAs = 0 self.dataSourceName = "clusterId" self.primary = None self.additional = {} self.loadSettings() bg = self.bgMerge = OWGUI.radioButtonsInBox(self.controlArea, self, "mergeAttributes", [], "Domains merging", callback = self.apply) OWGUI.widgetLabel(bg, "When there is no primary table, the domain should be") OWGUI.appendRadioButton(bg, self, "mergeAttributes", "Union of attributes appearing in all tables") OWGUI.appendRadioButton(bg, self, "mergeAttributes", "Intersection of attributes in all tables") OWGUI.widgetLabel(bg, "The resulting table will have class only if there is no conflict between input classes.") OWGUI.separator(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Data source IDs", addSpace=True) cb = OWGUI.checkBox(box, self, "dataSourceSelected", "Append data source IDs") self.classificationBox = ib = OWGUI.indentedBox(box, sep=OWGUI.checkButtonOffsetHint(cb)) le = OWGUI.lineEdit(ib, self, "dataSourceName", "Name" + " ", orientation='horizontal', valueType = str) OWGUI.separator(ib, height = 4) aa = OWGUI.comboBox(ib, self, "addIdAs", label = "Place" + " ", orientation = 'horizontal', items = ["Class attribute", "Attribute", "Meta attribute"]) cb.disables.append(ib) cb.makeConsistent() OWGUI.button(self.controlArea, self, "Apply Changes", callback = self.apply, default=True) OWGUI.rubber(self.controlArea) self.adjustSize() self.dataReport = None
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'Nx Clustering') self.inputs = [("Network", Orange.network.Graph, self.setNetwork, Default)] self.outputs = [("Network", Orange.network.Graph)] self.net = None self.method = 0 self.iterationHistory = 0 self.autoApply = 0 self.iterations = 1000 self.hop_attenuation = 0.1 self.loadSettings() OWGUI.spin(self.controlArea, self, "iterations", 1, 100000, 1, label="Iterations: ") 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.appendRadioButton(ribg, self, "method", "Label propagation clustering (Leung et al., 2009)", callback=self.cluster) OWGUI.doubleSpin(OWGUI.indentedBox(ribg), self, "hop_attenuation", 0, 1, 0.01, label="Hop attenuation (delta): ") self.info = OWGUI.widgetLabel(self.controlArea, ' ') OWGUI.checkBox(self.controlArea, self, "iterationHistory", "Append clustering data on each iteration", callback=self.cluster) OWGUI.checkBox(self.controlArea, self, "autoApply", "Commit automatically") OWGUI.button(self.controlArea, self, "Commit", callback=lambda b=True: self.cluster(b))
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "FeatureConstructor") #To enable the use of primary table, uncomment the next line and comment the following one #self.inputs = [("Primary Table", dataUtilities.DataTable, self.setData), ("Additional Tables", dataUtilities.DataTable, self.setMoreData, Multiple)] self.inputs = [("Tables", orange.ExampleTable, self.setMoreData, Multiple)] self.outputs = [("Examples", ExampleTable)] self.mergeAttributes = 0 self.primary = None self.additional = {} bg = self.bgMerge = OWGUI.radioButtonsInBox(self.controlArea, self, "mergeAttributes", [], "Domains merging", callback=self.apply) OWGUI.widgetLabel( bg, "") # "When there is no primary table, the domain should be") OWGUI.appendRadioButton(bg, self, "mergeAttributes", "Union of attributes appearing in all tables") OWGUI.appendRadioButton(bg, self, "mergeAttributes", "Intersection of attributes in all tables") #OWGUI.widgetLabel(bg, "The resulting table will have class only if there is no conflict betwen input classes.") infoBox = OWGUI.widgetBox(self, "Concatenate status") self.infoStatus = OWGUI.widgetLabel(infoBox, '') self.viewBT = OWGUI.button(self.controlArea, self, "&View converted incompatible attributes", callback=self.viewIncompatible, disabled=1) self.adjustSize()
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'Pubmed Network View', wantMainArea=0) self.inputs = [] self.outputs = [("Nx View", Orange.network.NxView)] self._nhops = 2 self._edge_threshold = 0.5 self._n_max_neighbors = 20 self.selected_titles = [] self.titles = [] self.filter = '' self.ids = [] self._selected_nodes = [] self._algorithm = 0 self._k_algorithm = 0.3 self.loadSettings() box = OWGUI.widgetBox(self.controlArea, "Paper Selection", orientation="vertical") OWGUI.lineEdit(box, self, "filter", callback=self.filter_list, callbackOnType=True) self.list_titles = OWGUI.listBox(box, self, "selected_titles", "titles", selectionMode=QListWidget.MultiSelection, callback=self.update_view) OWGUI.separator(self.controlArea) box_pref = OWGUI.widgetBox(self.controlArea, "Preferences", orientation="vertical") OWGUI.spin(box_pref, self, "_nhops", 1, 6, 1, label="Number of hops: ", callback=self.update_view) OWGUI.spin(box_pref, self, "_n_max_neighbors", 1, 100, 1, label="Max number of neighbors: ", callback=self.update_view) OWGUI.doubleSpin(box_pref, self, "_edge_threshold", 0, 1, step=0.01, label="Edge threshold: ", callback=self.update_view) OWGUI.separator(self.controlArea) box_alg = OWGUI.widgetBox(self.controlArea, "Interest Propagation Algorithm", orientation="vertical") radio_box = OWGUI.radioButtonsInBox(box_alg, self, "_algorithm", [], callback=self.update_view) OWGUI.appendRadioButton(radio_box, self, "_algorithm", "Without Clustering", callback=self.update_view) OWGUI.doubleSpin(OWGUI.indentedBox(radio_box), self, "_k_algorithm", 0, 1, step=0.01, label="Parameter k: ", callback=self.update_view) OWGUI.appendRadioButton(radio_box, self, "_algorithm", "With Clustering", callback=self.update_view) self.inside_view = PubmedNetworkView(self) self.send("Nx View", self.inside_view)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'Itemset visualizer') self.inputs = [("Graph with Data", orange.Graph, self.setGraph), ("Data Subset", orange.ExampleTable, self.setExampleSubset)] self.outputs = [("Selected Data", 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="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, "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 addHistogramControls(self, parent=None): # set default settings self.spinLowerThreshold = 0 self.spinLowerChecked = False self.spinUpperThreshold = 0 self.spinUpperChecked = False self.netOption = 0 self.dstWeight = 0 self.kNN = 0 self.andor = 0 self.matrix = None self.excludeLimit = 2 self.percentil = 0 self.graph = None self.graph_matrix = None if parent is None: parent = self.controlArea boxGeneral = OWGUI.widgetBox(parent, box="Distance boundaries") ribg = OWGUI.widgetBox(boxGeneral, None, orientation="horizontal", addSpace=False) OWGUI.lineEdit(ribg, self, "spinLowerThreshold", "Lower", orientation='horizontal', callback=self.changeLowerSpin, valueType=float, enterPlaceholder=True, controlWidth=100) OWGUI.lineEdit(ribg, self, "spinUpperThreshold", "Upper ", orientation='horizontal', callback=self.changeUpperSpin, valueType=float, enterPlaceholder=True, controlWidth=100) ribg.layout().addStretch(1) #ribg = OWGUI.radioButtonsInBox(boxGeneral, self, "andor", [], orientation='horizontal', callback = self.generateGraph) #OWGUI.appendRadioButton(ribg, self, "andor", "OR", callback = self.generateGraph) #b = OWGUI.appendRadioButton(ribg, self, "andor", "AND", callback = self.generateGraph) #b.setEnabled(False) #ribg.hide(False) ribg = OWGUI.widgetBox(boxGeneral, None, orientation="horizontal", addSpace=False) OWGUI.spin(ribg, self, "kNN", 0, 1000, 1, label="kNN ", orientation='horizontal', callback=self.generateGraph, callbackOnReturn=1, controlWidth=100) OWGUI.doubleSpin(ribg, self, "percentil", 0, 100, 0.1, label="Percentile", orientation='horizontal', callback=self.setPercentil, callbackOnReturn=1, controlWidth=100) ribg.layout().addStretch(1) # Options self.attrColor = "" ribg = OWGUI.radioButtonsInBox(parent, self, "netOption", [], "Options", callback=self.generateGraph) OWGUI.appendRadioButton(ribg, self, "netOption", "All vertices", callback=self.generateGraph) hb = OWGUI.widgetBox(ribg, None, orientation="horizontal", addSpace=False) OWGUI.appendRadioButton(ribg, self, "netOption", "Large components only. Min nodes:", insertInto=hb, callback=self.generateGraph) OWGUI.spin(hb, self, "excludeLimit", 2, 100, 1, callback=(lambda h=True: self.generateGraph(h))) OWGUI.appendRadioButton(ribg, self, "netOption", "Largest connected component only", callback=self.generateGraph) OWGUI.appendRadioButton(ribg, self, "netOption", "Connected component with vertex") self.attribute = None self.attributeCombo = OWGUI.comboBox(parent, self, "attribute", box="Filter attribute", orientation='horizontal')#, callback=self.setVertexColor) ribg = OWGUI.radioButtonsInBox(parent, self, "dstWeight", [], "Distance -> Weight", callback=self.generateGraph) hb = OWGUI.widgetBox(ribg, None, orientation="horizontal", addSpace=False) OWGUI.appendRadioButton(ribg, self, "dstWeight", "Weight := distance", insertInto=hb, callback=self.generateGraph) OWGUI.appendRadioButton(ribg, self, "dstWeight", "Weight := 1 - distance", insertInto=hb, callback=self.generateGraph) self.label = '' self.searchString = OWGUI.lineEdit(self.attributeCombo.box, self, "label", callback=self.setSearchStringTimer, callbackOnType=True) self.searchStringTimer = QTimer(self) self.connect(self.searchStringTimer, SIGNAL("timeout()"), self.generateGraph) if str(self.netOption) != '3': self.attributeCombo.box.setEnabled(False)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'SampleData', wantMainArea=0) self.inputs = [("Data", ExampleTable, self.setData)] self.outputs = [("Data Sample", ExampleTable), ("Remaining Data", ExampleTable)] # initialization of variables self.data = None # dataset (incoming stream) self.indices = None # indices that control sampling self.Stratified = 1 # use stratified sampling if possible? self.Repeat = 0 # can elements repeat in a sample? self.UseSpecificSeed = 0 # use a specific random seed? self.RandomSeed = 1 # specific seed used self.GroupSeed = 1 # current seed for multiple group selection self.outFold = 1 # folder/group to output self.Folds = 1 # total number of folds/groups self.SelectType = 0 # sampling type (LOO, CV, ...) self.useCases = 0 # use a specific number of cases? self.nCases = 25 # number of cases to use self.selPercentage = 30 # sample size in % self.CVFolds = 10 # number of CV folds self.nGroups = 3 # number of groups self.pGroups = [0.1, 0.25, 0.5] # sizes of groups self.GroupText = '0.1,0.25,0.5' # assigned to Groups Control (for internal use) self.autocommit = False # Invalidated settings flag. self.outputInvalidateFlag = False self.loadSettings() # GUI # Info Box box1 = OWGUI.widgetBox(self.controlArea, "Information", addSpace=True) # Input data set info self.infoa = OWGUI.widgetLabel(box1, 'No data on input.') # Sampling type/parameters info self.infob = OWGUI.widgetLabel(box1, ' ') # Output data set info self.infoc = OWGUI.widgetLabel(box1, ' ') # Options Box box2 = OWGUI.widgetBox(self.controlArea, 'Options', addSpace=True) OWGUI.checkBox(box2, self, 'Stratified', 'Stratified (if possible)', callback=self.settingsChanged) OWGUI.checkWithSpin(box2, self, 'Set random seed:', 0, 32767, 'UseSpecificSeed', 'RandomSeed', checkCallback=self.settingsChanged, spinCallback=self.settingsChanged) # Sampling Type Box self.s = [None, None, None, None] self.sBox = OWGUI.widgetBox(self.controlArea, "Sampling type", addSpace=True) self.sBox.buttons = [] # Random Sampling self.s[0] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", 'Random sampling') # indent indent = OWGUI.checkButtonOffsetHint(self.s[0]) # repeat checkbox self.h1Box = OWGUI.indentedBox(self.sBox, sep=indent, orientation="horizontal") OWGUI.checkBox(self.h1Box, self, 'Repeat', 'With replacement', callback=self.settingsChanged) # specified number of elements checkbox self.h2Box = OWGUI.indentedBox(self.sBox, sep=indent, orientation="horizontal") check, _ = OWGUI.checkWithSpin(self.h2Box, self, 'Sample size (instances):', 1, 1000000000, 'useCases', 'nCases', checkCallback=self.settingsChanged, spinCallback=self.settingsChanged) # percentage slider self.h3Box = OWGUI.indentedBox(self.sBox, sep=indent) OWGUI.widgetLabel(self.h3Box, "Sample size:") self.slidebox = OWGUI.widgetBox(self.h3Box, orientation="horizontal") OWGUI.hSlider(self.slidebox, self, 'selPercentage', minValue=1, maxValue=100, step=1, ticks=10, labelFormat=" %d%%", callback=self.settingsChanged) # Sample size (instances) check disables the Percentage slider. # TODO: Should be an exclusive option (radio buttons) check.disables.extend([(-1, self.h3Box)]) check.makeConsistent() # Cross Validation sampling options self.s[1] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", "Cross validation") box = OWGUI.indentedBox(self.sBox, sep=indent, orientation="horizontal") OWGUI.spin(box, self, 'CVFolds', 2, 100, step=1, label='Number of folds: ', callback=self.settingsChanged) # Leave-One-Out self.s[2] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", "Leave-one-out") # Multiple Groups self.s[3] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", 'Multiple subsets') gbox = OWGUI.indentedBox(self.sBox, sep=indent, orientation="horizontal") OWGUI.lineEdit(gbox, self, 'GroupText', label='Subset sizes (e.g. "0.1, 0.2, 0.5"):', callback=self.multipleChanged) # Output Group Box box = OWGUI.widgetBox(self.controlArea, 'Output Data for Fold / Group', addSpace=True) self.foldcombo = OWGUI.comboBox(box, self, "outFold", items=range(1, 101), label='Fold / group:', orientation="horizontal", sendSelectedValue=1, valueType=int, callback=self.invalidate) self.foldcombo.setEnabled(self.SelectType != 0) # Sample Data box OWGUI.rubber(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Sample Data") cb = OWGUI.checkBox(box, self, "autocommit", "Sample on any change") self.sampleButton = OWGUI.button(box, self, 'Sample &Data', callback=self.sdata, default=True) OWGUI.setStopper(self, self.sampleButton, cb, "outputInvalidateFlag", callback=self.sdata) # set initial radio button on (default sample type) self.s[self.SelectType].setChecked(True) # Connect radio buttons (SelectType) for i, button in enumerate(self.s): button.toggled[bool].connect( lambda state, i=i: self.samplingTypeChanged(state, i)) self.process() self.resize(200, 275)
def addHistogramControls(self, parent=None): # set default settings self.spinLowerThreshold = 0 self.spinLowerChecked = False self.spinUpperThreshold = 0 self.spinUpperChecked = False self.netOption = 0 self.dstWeight = 0 self.kNN = 0 self.andor = 0 self.matrix = None self.excludeLimit = 1 self.percentil = 0 if parent is None: parent = self.controlArea boxGeneral = OWGUI.widgetBox(parent, box = "Distance boundaries") OWGUI.lineEdit(boxGeneral, self, "spinLowerThreshold", "Lower:", orientation='horizontal', callback=self.changeLowerSpin, valueType=float) OWGUI.lineEdit(boxGeneral, self, "spinUpperThreshold", "Upper:", orientation='horizontal', callback=self.changeUpperSpin, valueType=float) ribg = OWGUI.radioButtonsInBox(boxGeneral, self, "andor", [], orientation='horizontal', callback = self.generateGraph) OWGUI.appendRadioButton(ribg, self, "andor", "OR", callback = self.generateGraph) b = OWGUI.appendRadioButton(ribg, self, "andor", "AND", callback = self.generateGraph) b.setEnabled(False) OWGUI.spin(boxGeneral, self, "kNN", 0, 1000, 1, label="kNN:", orientation='horizontal', callback=self.generateGraph) OWGUI.doubleSpin(boxGeneral, self, "percentil", 0, 100, 0.1, label="Percentil:", orientation='horizontal', callback=self.setPercentil, callbackOnReturn=1) # Options self.attrColor = "" ribg = OWGUI.radioButtonsInBox(parent, self, "netOption", [], "Options", callback = self.generateGraph) OWGUI.appendRadioButton(ribg, self, "netOption", "All vertices", callback = self.generateGraph) OWGUI.appendRadioButton(ribg, self, "netOption", "Exclude small components", callback = self.generateGraph) OWGUI.spin(OWGUI.indentedBox(ribg), self, "excludeLimit", 1, 100, 1, label="Less vertices than: ", callback = (lambda h=True: self.generateGraph(h))) OWGUI.appendRadioButton(ribg, self, "netOption", "Largest connected component only", callback = self.generateGraph) OWGUI.appendRadioButton(ribg, self, "netOption", "Connected component with vertex") self.attribute = None self.attributeCombo = OWGUI.comboBox(ribg, self, "attribute", box = "Filter attribute")#, callback=self.setVertexColor) ribg = OWGUI.radioButtonsInBox(parent, self, "dstWeight", [], "Distance -> Weight", callback = self.generateGraph) OWGUI.appendRadioButton(ribg, self, "dstWeight", "Weight := distance", callback = self.generateGraph) OWGUI.appendRadioButton(ribg, self, "dstWeight", "Weight := 1 - distance", callback = self.generateGraph) self.label = '' self.searchString = OWGUI.lineEdit(self.attributeCombo.box, self, "label", callback=self.setSearchStringTimer, callbackOnType=True) self.searchStringTimer = QTimer(self) self.connect(self.searchStringTimer, SIGNAL("timeout()"), self.generateGraph) if str(self.netOption) != '3': self.attributeCombo.box.setEnabled(False)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "TestLearners") self.inputs = [("Data", ExampleTable, self.setData, Default), ("Separate Test Data", ExampleTable, self.setTestData), ("Learner", orange.Learner, self.setLearner, Multiple), ("Preprocess", PreprocessedLearner, self.setPreprocessor)] self.outputs = [("Evaluation Results", orngTest.ExperimentResults)] # Settings self.resampling = 0 # cross-validation self.nFolds = 5 # cross validation folds self.pLearning = 70 # size of learning set when sampling [%] self.pRepeat = 10 self.precision = 4 self.applyOnAnyChange = True self.selectedCScores = [ i for (i, s) in enumerate(self.cStatistics) if s.show ] self.selectedRScores = [ i for (i, s) in enumerate(self.rStatistics) if s.show ] self.targetClass = 0 self.loadSettings() self.resampling = 0 # cross-validation self.stat = self.cStatistics self.data = None # input data set self.testdata = None # separate test data set self.learners = {} # set of learners (input) self.results = None # from orngTest self.preprocessor = None self.controlArea.layout().setSpacing(8) # GUI self.sBtns = OWGUI.radioButtonsInBox( self.controlArea, self, "resampling", box="Sampling", btnLabels=self.resamplingMethods[:1], callback=self.newsampling) indent = OWGUI.checkButtonOffsetHint(self.sBtns.buttons[-1]) ibox = OWGUI.widgetBox(OWGUI.indentedBox(self.sBtns, sep=indent)) OWGUI.spin(ibox, self, 'nFolds', 2, 100, step=1, label='Number of folds:', callback=lambda p=0: self.conditionalRecompute(p)) OWGUI.separator(self.sBtns, height=3) OWGUI.appendRadioButton(self.sBtns, self, "resampling", self.resamplingMethods[1]) # leave one out OWGUI.separator(self.sBtns, height=3) OWGUI.appendRadioButton(self.sBtns, self, "resampling", self.resamplingMethods[2]) # random sampling ibox = OWGUI.widgetBox(OWGUI.indentedBox(self.sBtns, sep=indent)) OWGUI.spin(ibox, self, 'pRepeat', 1, 100, step=1, label='Repeat train/test:', callback=lambda p=2: self.conditionalRecompute(p)) OWGUI.widgetLabel(ibox, "Relative training set size:") OWGUI.hSlider(ibox, self, 'pLearning', minValue=10, maxValue=100, step=1, ticks=10, labelFormat=" %d%%", callback=lambda p=2: self.conditionalRecompute(p)) OWGUI.separator(self.sBtns, height=3) OWGUI.appendRadioButton(self.sBtns, self, "resampling", self.resamplingMethods[3]) # test on train OWGUI.separator(self.sBtns, height=3) OWGUI.appendRadioButton(self.sBtns, self, "resampling", self.resamplingMethods[4]) # test on test self.trainDataBtn = self.sBtns.buttons[-2] self.testDataBtn = self.sBtns.buttons[-1] self.testDataBtn.setDisabled(True) # box = OWGUI.widgetBox(self.sBtns, orientation='vertical', addSpace=False) # OWGUI.separator(box) OWGUI.separator(self.sBtns) OWGUI.checkBox(self.sBtns, self, 'applyOnAnyChange', label="Apply on any change", callback=self.applyChange) self.applyBtn = OWGUI.button(self.sBtns, self, "&Apply", callback=lambda f=True: self.recompute(f)) self.applyBtn.setDisabled(True) if self.resampling == 4: self.resampling = 3 # OWGUI.separator(self.controlArea) # statistics self.statLayout = QStackedLayout() # self.cbox = OWGUI.widgetBox(self.controlArea, spacing=8, margin=0) # self.cbox.layout().setSpacing(8) self.cbox = OWGUI.widgetBox(self.controlArea, addToLayout=False) self.cStatLabels = [s.name for s in self.cStatistics] self.cstatLB = OWGUI.listBox(self.cbox, self, 'selectedCScores', 'cStatLabels', box="Performance scores", selectionMode=QListWidget.MultiSelection, callback=self.newscoreselection) # OWGUI.separator(self.cbox) self.cbox.layout().addSpacing(8) self.targetCombo = OWGUI.comboBox(self.cbox, self, "targetClass", orientation=0, callback=[self.changedTarget], box="Target class") self.rStatLabels = [s.name for s in self.rStatistics] self.rbox = OWGUI.widgetBox(self.controlArea, "Performance scores", addToLayout=False) self.rstatLB = OWGUI.listBox(self.rbox, self, 'selectedRScores', 'rStatLabels', selectionMode=QListWidget.MultiSelection, callback=self.newscoreselection) self.statLayout.addWidget(self.cbox) self.statLayout.addWidget(self.rbox) self.controlArea.layout().addLayout(self.statLayout) self.statLayout.setCurrentWidget(self.cbox) # self.rstatLB.box.hide() # score table # table with results self.g = OWGUI.widgetBox(self.mainArea, 'Evaluation Results') self.tab = OWGUI.table(self.g, selectionMode=QTableWidget.NoSelection) #self.lab = QLabel(self.g) self.resize(680, 470)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "Network from Distances") self.inputs = [("Distance Matrix", orange.SymMatrix, self.setMatrix)] self.outputs = [("Network", orngNetwork.Network), ("Examples", ExampleTable), ("Distance Matrix", orange.SymMatrix)] # set default settings self.spinLowerThreshold = 0 self.spinLowerChecked = False self.spinUpperThreshold = 0 self.spinUpperChecked = False self.netOption = 0 self.dstWeight = 0 self.kNN = 0 self.andor = 0 self.data = None self.excludeLimit = 1 # get settings from the ini file, if they exist self.loadSettings() # GUI # general settings boxHistogram = OWGUI.widgetBox(self.mainArea, box = "Distance histogram") self.histogram = OWHist(self, boxHistogram) boxHistogram.layout().addWidget(self.histogram) boxHistogram.setMinimumWidth(500) boxHistogram.setMinimumHeight(300) boxGeneral = OWGUI.widgetBox(self.controlArea, box = "Distance boundaries") OWGUI.lineEdit(boxGeneral, self, "spinLowerThreshold", "Lower:", orientation='horizontal', callback=self.changeLowerSpin, valueType=float) OWGUI.lineEdit(boxGeneral, self, "spinUpperThreshold", "Upper:", orientation='horizontal', callback=self.changeUpperSpin, valueType=float) ribg = OWGUI.radioButtonsInBox(boxGeneral, self, "andor", [], orientation='horizontal', callback = self.generateGraph) OWGUI.appendRadioButton(ribg, self, "andor", "OR", callback = self.generateGraph) b = OWGUI.appendRadioButton(ribg, self, "andor", "AND", callback = self.generateGraph) b.setEnabled(False) OWGUI.spin(boxGeneral, self, "kNN", 0, 1000, 1, label="kNN:", orientation='horizontal', callback=self.generateGraph) # Options self.attrColor = "" ribg = OWGUI.radioButtonsInBox(self.controlArea, self, "netOption", [], "Options", callback = self.generateGraph) OWGUI.appendRadioButton(ribg, self, "netOption", "All vertices", callback = self.generateGraph) OWGUI.appendRadioButton(ribg, self, "netOption", "Exclude small components", callback = self.generateGraph) OWGUI.spin(OWGUI.indentedBox(ribg), self, "excludeLimit", 1, 100, 1, label="Less vertices than: ", callback = (lambda h=True: self.generateGraph(h))) OWGUI.appendRadioButton(ribg, self, "netOption", "Largest connected component only", callback = self.generateGraph) OWGUI.appendRadioButton(ribg, self, "netOption", "Connected component with vertex") self.attribute = None self.attributeCombo = OWGUI.comboBox(ribg, self, "attribute", box = "Filter attribute")#, callback=self.setVertexColor) ribg = OWGUI.radioButtonsInBox(self.controlArea, self, "dstWeight", [], "Distance -> Weight", callback = self.generateGraph) OWGUI.appendRadioButton(ribg, self, "dstWeight", "Weight := distance", callback = self.generateGraph) OWGUI.appendRadioButton(ribg, self, "dstWeight", "Weight := 1 - distance", callback = self.generateGraph) self.label = '' self.searchString = OWGUI.lineEdit(self.attributeCombo.box, self, "label", callback=self.setSearchStringTimer, callbackOnType=True) self.searchStringTimer = QTimer(self) self.connect(self.searchStringTimer, SIGNAL("timeout()"), self.generateGraph) if str(self.netOption) != '3': self.attributeCombo.box.setEnabled(False) # info boxInfo = OWGUI.widgetBox(self.controlArea, box = "Network info") self.infoa = OWGUI.widgetLabel(boxInfo, "No data loaded.") self.infob = OWGUI.widgetLabel(boxInfo, '') self.infoc = OWGUI.widgetLabel(boxInfo, '') self.resize(700, 100)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "Itemset visualizer") self.inputs = [ ("Graph with Data", orange.Graph, self.setGraph), ("Data Subset", orange.ExampleTable, self.setExampleSubset), ] self.outputs = [("Selected Data", 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): OWWidget.__init__(self, parent, signalManager, 'k-Means Clustering') self.inputs = [("Examples", ExampleTable, self.setData)] self.outputs = [("Examples", ExampleTable), ("Centroids", ExampleTable)] #set default settings self.K = 2 self.optimized = True self.optimizationFrom = 2 self.optimizationTo = 5 self.scoring = 0 self.distanceMeasure = 0 self.initializationType = 0 self.restarts = 1 self.classifySelected = 1 self.addIdAs = 0 self.runAnyChange = 1 self.classifyName = "Cluster" self.settingsChanged = False self.loadSettings() self.data = None # holds input data self.km = None # holds clustering object # GUI definition # settings box = OWGUI.widgetBox(self.controlArea, "Clusters (k)") bg = OWGUI.radioButtonsInBox(box, self, "optimized", [], callback=self.setOptimization) fixedBox = OWGUI.widgetBox(box, orientation="horizontal") button = OWGUI.appendRadioButton(bg, self, "optimized", "Fixed", insertInto=fixedBox, tooltip="Fixed number of clusters") self.fixedSpinBox = OWGUI.spin(OWGUI.widgetBox(fixedBox), self, "K", min=2, max=30, tooltip="Fixed number of clusters", callback=self.update, callbackOnReturn=True) OWGUI.rubber(fixedBox) optimizedBox = OWGUI.widgetBox(box) button = OWGUI.appendRadioButton(bg, self, "optimized", "Optimized", insertInto=optimizedBox) option = QStyleOptionButton() option.initFrom(button) box = OWGUI.indentedBox( optimizedBox, qApp.style().subElementRect(QStyle.SE_CheckBoxIndicator, option, button).width() - 3) self.optimizationBox = box OWGUI.spin(box, self, "optimizationFrom", label="From", min=2, max=99, tooltip="Minimum number of clusters to try", callback=self.updateOptimizationFrom, callbackOnReturn=True) b = OWGUI.spin(box, self, "optimizationTo", label="To", min=3, max=100, tooltip="Maximum number of clusters to try", callback=self.updateOptimizationTo, callbackOnReturn=True) # b.control.setLineEdit(OWGUI.LineEditWFocusOut(b)) OWGUI.comboBox(box, self, "scoring", label="Scoring", orientation="horizontal", items=[m[0] for m in self.scoringMethods], callback=self.update) box = OWGUI.widgetBox(self.controlArea, "Settings", addSpace=True) # OWGUI.spin(box, self, "K", label="Number of clusters"+" ", min=1, max=30, step=1, # callback = self.initializeClustering) OWGUI.comboBox(box, self, "distanceMeasure", label="Distance measures", items=[name for name, _ in self.distanceMeasures], tooltip=None, indent=20, callback=self.update) cb = OWGUI.comboBox(box, self, "initializationType", label="Initialization", items=[name for name, _ in self.initializations], tooltip=None, indent=20, callback=self.update) OWGUI.spin(cb.box, self, "restarts", label="Restarts", orientation="horizontal", min=1, max=100, callback=self.update, callbackOnReturn=True) box = OWGUI.widgetBox(self.controlArea, "Cluster IDs") cb = OWGUI.checkBox(box, self, "classifySelected", "Append cluster indices") box = OWGUI.indentedBox(box) form = QWidget() le = OWGUI.lineEdit( form, self, "classifyName", None, #"Name" + " ", orientation="horizontal", #controlWidth=100, valueType=str, # callback=self.sendData, # callbackOnReturn=True ) cc = OWGUI.comboBox( form, self, "addIdAs", label=" ", #"Place" + " ", orientation="horizontal", items=["Class attribute", "Attribute", "Meta attribute"], ) layout = QFormLayout() layout.setSpacing(8) layout.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow) layout.setLabelAlignment(Qt.AlignLeft | Qt.AlignJustify) layout.addRow("Name ", le) layout.addRow("Place ", cc) # le.setFixedWidth(cc.sizeHint().width()) form.setLayout(layout) box.layout().addWidget(form) cb.disables.append(box) # cb.disables.append(cc.box) cb.makeConsistent() # OWGUI.separator(box) box = OWGUI.widgetBox(self.controlArea, "Run", addSpace=True) cb = OWGUI.checkBox(box, self, "runAnyChange", "Run after any change") self.runButton = b = OWGUI.button(box, self, "Run Clustering", callback=self.run) OWGUI.setStopper(self, b, cb, "settingsChanged", callback=self.run) OWGUI.rubber(self.controlArea) # display of clustering results self.optimizationReportBox = OWGUI.widgetBox(self.mainArea) tableBox = OWGUI.widgetBox(self.optimizationReportBox, "Optimization Report") self.table = OWGUI.table(tableBox, selectionMode=QTableWidget.SingleSelection) self.table.setHorizontalScrollMode(QTableWidget.ScrollPerPixel) self.table.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.table.setSelectionBehavior(QAbstractItemView.SelectRows) self.table.setColumnCount(3) self.table.setHorizontalHeaderLabels(["k", "Best", "Score"]) self.table.verticalHeader().hide() self.table.horizontalHeader().setStretchLastSection(True) self.table.setItemDelegateForColumn( 2, OWGUI.TableBarItem(self, self.table)) self.table.setItemDelegateForColumn(1, OWGUI.IndicatorItemDelegate(self)) self.table.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) self.table.hide() self.connect(self.table, SIGNAL("itemSelectionChanged()"), self.tableItemSelected) self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) self.mainArea.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) OWGUI.rubber(self.topWidgetPart) self.updateOptimizationGui()
def __init__(self, parent=None, signalManager=None, name="SVM"): 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, Default), ("Classifier", orange.Classifier, Default), ("Support Vectors", ExampleTable)] self.kernel_type = 2 self.gamma = 0.0 self.coef0 = 0.0 self.degree = 3 self.C = 1.0 self.p = 0.1 self.eps = 1e-3 self.nu = 0.5 self.shrinking = 1 self.probability=1 self.useNu=0 self.nomogram=0 self.normalization=1 self.data = None self.selFlag=False self.preprocessor = None self.name="SVM" 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) b = OWGUI.radioButtonsInBox(self.controlArea, self, "useNu", [], box="SVM Type", orientation = QGridLayout(), addSpace=True) b.layout().addWidget(OWGUI.appendRadioButton(b, self, "useNu", "C-SVM", addToLayout=False), 0, 0, Qt.AlignLeft) b.layout().addWidget(QLabel("Cost (C)", b), 0, 1, Qt.AlignRight) b.layout().addWidget(OWGUI.doubleSpin(b, self, "C", 0.1, 512.0, 0.1, decimals=2, addToLayout=False, callback=lambda *x: self.setType(0), alignment=Qt.AlignRight, tooltip= "Cost for a mis-classified training instance."), 0, 2) b.layout().addWidget(OWGUI.appendRadioButton(b, self, "useNu", u"ν-SVM", addToLayout=False), 1, 0, Qt.AlignLeft) b.layout().addWidget(QLabel(u"Complexity bound (\u03bd)", b), 1, 1, Qt.AlignRight) b.layout().addWidget(OWGUI.doubleSpin(b, self, "nu", 0.05, 1.0, 0.05, tooltip="Lower bound on the ratio of support vectors", addToLayout=False, callback=lambda *x: self.setType(1), alignment=Qt.AlignRight), 1, 2) self.kernelBox=b = OWGUI.widgetBox(self.controlArea, "Kernel") self.kernelradio = OWGUI.radioButtonsInBox(b, self, "kernel_type", btnLabels=[u"Linear, x∙y", u"Polynomial, (g x∙y + c)^d", u"RBF, exp(-g|x-y|²)", u"Sigmoid, tanh(g x∙y + c)"], callback=self.changeKernel) OWGUI.separator(b) self.gcd = OWGUI.widgetBox(b, orientation="horizontal") self.leg = OWGUI.doubleSpin(self.gcd, self, "gamma",0.0,10.0,0.0001, decimals=5, label=" g: ", orientation="horizontal", callback=self.changeKernel, alignment=Qt.AlignRight) self.led = OWGUI.doubleSpin(self.gcd, self, "coef0", 0.0,10.0,0.0001, label=" c: ", orientation="horizontal", callback=self.changeKernel, alignment=Qt.AlignRight) self.lec = OWGUI.doubleSpin(self.gcd, self, "degree", 0.0,10.0,0.5, label=" d: ", orientation="horizontal", callback=self.changeKernel, alignment=Qt.AlignRight) OWGUI.separator(self.controlArea) self.optionsBox=b=OWGUI.widgetBox(self.controlArea, "Options", addSpace=True) OWGUI.doubleSpin(b,self, "eps", 0.0005, 1.0, 0.0005, label=u"Numerical tolerance", labelWidth = 180, orientation="horizontal", tooltip="Numerical tolerance of termination criterion.", alignment=Qt.AlignRight) self.probBox = OWGUI.checkBox(b,self, "probability", label="Estimate class probabilities", tooltip="Create classifiers that support class probability estimation." ) OWGUI.checkBox(b, self, "normalization", label="Normalize data", tooltip="Use data normalization") self.paramButton=OWGUI.button(self.controlArea, self, "Automatic parameter search", callback=self.parameterSearch, tooltip="Automatically searches for parameters that optimize classifier accuracy", debuggingEnabled=0) self.paramButton.setDisabled(True) OWGUI.button(self.controlArea, self,"&Apply", callback=self.applySettings, default=True) OWGUI.rubber(self.controlArea) self.loadSettings() self.changeKernel() self.searching=False self.applySettings()
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): OWWidget.__init__(self, parent, signalManager, "SampleData", wantMainArea=0) self.inputs = [("Data", ExampleTable, self.setData)] self.outputs = [("Data Sample", ExampleTable), ("Remaining Data", ExampleTable)] # initialization of variables self.data = None # dataset (incoming stream) self.indices = None # indices that control sampling self.Stratified = 1 # use stratified sampling if possible? self.Repeat = 0 # can elements repeat in a sample? self.UseSpecificSeed = 0 # use a specific random seed? self.RandomSeed = 1 # specific seed used self.GroupSeed = 1 # current seed for multiple group selection self.outFold = 1 # folder/group to output self.Folds = 1 # total number of folds/groups self.SelectType = 0 # sampling type (LOO, CV, ...) self.useCases = 0 # use a specific number of cases? self.nCases = 25 # number of cases to use self.selPercentage = 30 # sample size in % self.CVFolds = 10 # number of CV folds self.nGroups = 3 # number of groups self.pGroups = [0.1, 0.25, 0.5] # sizes of groups self.GroupText = "0.1,0.25,0.5" # assigned to Groups Control (for internal use) self.autocommit = False # Invalidated settings flag. self.outputInvalidateFlag = False self.loadSettings() # GUI # Info Box box1 = OWGUI.widgetBox(self.controlArea, "Information", addSpace=True) # Input data set info self.infoa = OWGUI.widgetLabel(box1, "No data on input.") # Sampling type/parameters info self.infob = OWGUI.widgetLabel(box1, " ") # Output data set info self.infoc = OWGUI.widgetLabel(box1, " ") # Options Box box2 = OWGUI.widgetBox(self.controlArea, "Options", addSpace=True) OWGUI.checkBox(box2, self, "Stratified", "Stratified (if possible)", callback=self.settingsChanged) OWGUI.checkWithSpin( box2, self, "Set random seed:", 0, 32767, "UseSpecificSeed", "RandomSeed", checkCallback=self.settingsChanged, spinCallback=self.settingsChanged, ) # Sampling Type Box self.s = [None, None, None, None] self.sBox = OWGUI.widgetBox(self.controlArea, "Sampling type", addSpace=True) self.sBox.buttons = [] # Random Sampling self.s[0] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", "Random sampling") # indent indent = OWGUI.checkButtonOffsetHint(self.s[0]) # repeat checkbox self.h1Box = OWGUI.indentedBox(self.sBox, sep=indent, orientation="horizontal") OWGUI.checkBox(self.h1Box, self, "Repeat", "With replacement", callback=self.settingsChanged) # specified number of elements checkbox self.h2Box = OWGUI.indentedBox(self.sBox, sep=indent, orientation="horizontal") check, _ = OWGUI.checkWithSpin( self.h2Box, self, "Sample size (instances):", 1, 1000000000, "useCases", "nCases", checkCallback=self.settingsChanged, spinCallback=self.settingsChanged, ) # percentage slider self.h3Box = OWGUI.indentedBox(self.sBox, sep=indent) OWGUI.widgetLabel(self.h3Box, "Sample size:") self.slidebox = OWGUI.widgetBox(self.h3Box, orientation="horizontal") OWGUI.hSlider( self.slidebox, self, "selPercentage", minValue=1, maxValue=100, step=1, ticks=10, labelFormat=" %d%%", callback=self.settingsChanged, ) # Sample size (instances) check disables the Percentage slider. # TODO: Should be an exclusive option (radio buttons) check.disables.extend([(-1, self.h3Box)]) check.makeConsistent() # Cross Validation sampling options self.s[1] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", "Cross validation") box = OWGUI.indentedBox(self.sBox, sep=indent, orientation="horizontal") OWGUI.spin(box, self, "CVFolds", 2, 100, step=1, label="Number of folds: ", callback=self.settingsChanged) # Leave-One-Out self.s[2] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", "Leave-one-out") # Multiple Groups self.s[3] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", "Multiple subsets") gbox = OWGUI.indentedBox(self.sBox, sep=indent, orientation="horizontal") OWGUI.lineEdit( gbox, self, "GroupText", label='Subset sizes (e.g. "0.1, 0.2, 0.5"):', callback=self.multipleChanged ) # Output Group Box box = OWGUI.widgetBox(self.controlArea, "Output Data for Fold / Group", addSpace=True) self.foldcombo = OWGUI.comboBox( box, self, "outFold", items=range(1, 101), label="Fold / group:", orientation="horizontal", sendSelectedValue=1, valueType=int, callback=self.invalidate, ) self.foldcombo.setEnabled(self.SelectType != 0) # Sample Data box OWGUI.rubber(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Sample Data") cb = OWGUI.checkBox(box, self, "autocommit", "Sample on any change") self.sampleButton = OWGUI.button(box, self, "Sample &Data", callback=self.sdata, default=True) OWGUI.setStopper(self, self.sampleButton, cb, "outputInvalidateFlag", callback=self.sdata) # set initial radio button on (default sample type) self.s[self.SelectType].setChecked(True) # Connect radio buttons (SelectType) for i, button in enumerate(self.s): button.toggled[bool].connect(lambda state, i=i: self.samplingTypeChanged(state, i)) self.process() self.resize(200, 275)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'SampleData', wantMainArea=0) self.inputs = [("Data", ExampleTable, self.setData)] self.outputs = [("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", addSpace=True) self.infoa = OWGUI.widgetLabel(box1, 'No data on input.') self.infob = OWGUI.widgetLabel(box1, ' ') self.infoc = OWGUI.widgetLabel(box1, ' ') # Options Box box2 = OWGUI.widgetBox(self.controlArea, 'Options', addSpace=True) OWGUI.checkBox(box2, self, 'Stratified', 'Stratified (if possible)', callback=self.settingsChanged) OWGUI.checkWithSpin(box2, self, 'Set random seed:', 0, 32767, 'UseSpecificSeed', 'RandomSeed', checkCallback=self.settingsChanged, spinCallback=self.settingsChanged) # Sampling Type Box self.s = [None, None, None, None] self.sBox = OWGUI.widgetBox(self.controlArea, "Sampling type", addSpace=True) self.sBox.buttons = [] # Random Sampling self.s[0] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", 'Random sampling') # indent indent = sep = OWGUI.checkButtonOffsetHint(self.s[0]) # repeat checkbox self.h1Box = OWGUI.indentedBox(self.sBox, sep=indent, orientation="horizontal") OWGUI.checkBox(self.h1Box, self, 'Repeat', 'With replacement', callback=self.settingsChanged) # specified number of elements checkbox self.h2Box = OWGUI.indentedBox(self.sBox, sep=indent, orientation="horizontal") OWGUI.checkWithSpin(self.h2Box, self, 'Sample size (instances):', 1, 1000000000, 'useCases', 'nCases', checkCallback=[self.uCases, self.settingsChanged], spinCallback=self.settingsChanged) OWGUI.rubber(self.h2Box) # percentage slider self.h3Box = OWGUI.indentedBox(self.sBox, sep=indent, orientation="horizontal") OWGUI.widgetLabel(self.h3Box, "Sample size:") self.slidebox = OWGUI.indentedBox(self.sBox, sep=indent, orientation="horizontal") OWGUI.hSlider(self.slidebox, self, 'selPercentage', minValue=1, maxValue=100, step=1, ticks=10, labelFormat=" %d%%", callback=self.settingsChanged) # Cross Validation self.s[1] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", 'Cross validation') box = OWGUI.indentedBox(self.sBox, sep=indent, orientation="horizontal") OWGUI.spin(box, self, 'CVFolds', 2, 100, step=1, label='Number of folds: ', callback=[self.changeCombo, self.settingsChanged]) OWGUI.rubber(box) # Leave-One-Out self.s[2] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", 'Leave-one-out') # Multiple Groups self.s[3] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", 'Multiple subsets') gbox = OWGUI.indentedBox(self.sBox, sep=indent, orientation="horizontal") OWGUI.lineEdit(gbox, self, 'GroupText', label='Subset sizes (e.g. "0.1, 0.2, 0.5"):', callback=self.multipleChanged) # Output Group Box self.foldcombo = OWGUI.comboBox(self.controlArea, self, "outFold", 'Output Data for Fold / Group', 'Fold / group:', orientation="horizontal", items=list(range(1, 101)), callback=self.foldChanged, sendSelectedValue=1, valueType=int) self.foldcombo.setEnabled(False) # Select Data Button OWGUI.rubber(self.controlArea) self.sampleButton = OWGUI.button(self.controlArea, self, 'Sample &Data', callback=self.process, addToLayout=False) self.buttonBackground.layout().setDirection(QBoxLayout.TopToBottom) self.buttonBackground.layout().insertWidget(0, self.sampleButton) self.buttonBackground.show() self.s[self.SelectType].setChecked( True) # set initial radio button on (default sample type) # CONNECTIONS # set connections for RadioButton (SelectType) self.dummy1 = [None] * len(self.s) for i in range(len(self.s)): self.dummy1[i] = lambda x, v=i: self.sChanged(x, v) self.connect(self.s[i], SIGNAL("toggled(bool)"), self.dummy1[i]) # final touch self.resize(200, 275)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'SampleData', wantMainArea = 0) self.inputs = [("Data", ExampleTable, self.setData)] self.outputs = [("Data Sample", ExampleTable), ("Remaining Data", ExampleTable)] # initialization of variables self.data = None # dataset (incoming stream) self.indices = None # indices that control sampling self.ind = None # indices that control sampling self.Stratified = 1 # use stratified sampling if possible? self.Repeat = 0 # can elements repeat in a sample? self.UseSpecificSeed = 0 # use a specific random seed? self.RandomSeed = 1 # specific seed used self.GroupSeed = 1 # current seed for multiple group selection self.outFold = 1 # folder/group to output self.Folds = 1 # total number of folds/groups self.SelectType = 0 # sampling type (LOO, CV, ...) self.useCases = 0 # use a specific number of cases? self.nCases = 25 # number of cases to use self.selPercentage = 30 # sample size in % self.LOO = 1 # use LOO? self.CVFolds = 10 # number of CV folds self.CVFoldsInternal = 10 # number of CV folds (for internal use) self.nGroups = 3 # number of groups self.pGroups = [0.1,0.25,0.5] # sizes of groups self.GroupText = '0.1,0.25,0.5' # assigned to Groups Control (for internal use) self.loadSettings() # GUI # Info Box box1 = OWGUI.widgetBox(self.controlArea, "Information", addSpace=True) self.infoa = OWGUI.widgetLabel(box1, 'No data on input.') self.infob = OWGUI.widgetLabel(box1, ' ') self.infoc = OWGUI.widgetLabel(box1, ' ') # Options Box box2 = OWGUI.widgetBox(self.controlArea, 'Options', addSpace=True) OWGUI.checkBox(box2, self, 'Stratified', 'Stratified (if possible)', callback=self.settingsChanged) OWGUI.checkWithSpin(box2, self, 'Set random seed:', 0, 32767, 'UseSpecificSeed', 'RandomSeed', checkCallback=self.settingsChanged, spinCallback=self.settingsChanged) # Sampling Type Box self.s = [None, None, None, None] self.sBox = OWGUI.widgetBox(self.controlArea, "Sampling type", addSpace=True) self.sBox.buttons = [] # Random Sampling self.s[0] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", 'Random sampling') # indent indent = sep=OWGUI.checkButtonOffsetHint(self.s[0]) # repeat checkbox self.h1Box = OWGUI.indentedBox(self.sBox, sep=indent, orientation = "horizontal") OWGUI.checkBox(self.h1Box, self, 'Repeat', 'With replacement', callback=self.settingsChanged) # specified number of elements checkbox self.h2Box = OWGUI.indentedBox(self.sBox, sep=indent, orientation = "horizontal") OWGUI.checkWithSpin(self.h2Box, self, 'Sample size (instances):', 1, 1000000000, 'useCases', 'nCases', checkCallback=[self.uCases, self.settingsChanged], spinCallback=self.settingsChanged) OWGUI.rubber(self.h2Box) # percentage slider self.h3Box = OWGUI.indentedBox(self.sBox, sep=indent, orientation = "horizontal") OWGUI.widgetLabel(self.h3Box, "Sample size:") self.slidebox = OWGUI.indentedBox(self.sBox, sep=indent, orientation = "horizontal") OWGUI.hSlider(self.slidebox, self, 'selPercentage', minValue=1, maxValue=100, step=1, ticks=10, labelFormat=" %d%%", callback=self.settingsChanged) # Cross Validation self.s[1] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", 'Cross validation') box = OWGUI.indentedBox(self.sBox, sep=indent, orientation = "horizontal") OWGUI.spin(box, self, 'CVFolds', 2, 100, step=1, label='Number of folds: ', callback=[self.changeCombo, self.settingsChanged]) OWGUI.rubber(box) # Leave-One-Out self.s[2] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", 'Leave-one-out') # Multiple Groups self.s[3] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", 'Multiple subsets') gbox = OWGUI.indentedBox(self.sBox, sep=indent, orientation = "horizontal") OWGUI.lineEdit(gbox, self, 'GroupText', label='Subset sizes (e.g. "0.1, 0.2, 0.5"):', callback=self.multipleChanged) # Output Group Box self.foldcombo = OWGUI.comboBox(self.controlArea, self, "outFold", 'Output Data for Fold / Group', 'Fold / group:', orientation = "horizontal", items = range(1,101), callback = self.foldChanged, sendSelectedValue = 1, valueType = int) self.foldcombo.setEnabled(False) # Select Data Button OWGUI.rubber(self.controlArea) self.sampleButton = OWGUI.button(self.controlArea, self, 'Sample &Data', callback = self.process, addToLayout=False, default=True) self.buttonBackground.layout().setDirection(QBoxLayout.TopToBottom) self.buttonBackground.layout().insertWidget(0, self.sampleButton) self.buttonBackground.show() self.s[self.SelectType].setChecked(True) # set initial radio button on (default sample type) # CONNECTIONS # set connections for RadioButton (SelectType) self.dummy1 = [None]*len(self.s) for i in range(len(self.s)): self.dummy1[i] = lambda x, v=i: self.sChanged(x, v) self.connect(self.s[i], SIGNAL("toggled(bool)"), self.dummy1[i]) # final touch self.resize(200, 275)