Ejemplo n.º 1
0
    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()
Ejemplo n.º 2
0
    def __init__(self,parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "Itemsets", wantMainArea = 0)

        from OWItemsets import Itemsets
        self.inputs = [("Data", ExampleTable, self.setData)]
        self.outputs = [("Itemsets", Itemsets)]

        self.minSupport = 60
        self.maxRules = 10000
        self.useSparseAlgorithm = False
        self.loadSettings()

        self.dataset = None

        box = OWGUI.widgetBox(self.space, "Settings", addSpace = True)
        OWGUI.checkBox(box, self, 'useSparseAlgorithm', 'Use algorithm for sparse data', tooltip="Use original Agrawal's algorithm")
        OWGUI.widgetLabel(box, "Minimal support [%]")
        OWGUI.hSlider(box, self, 'minSupport', minValue=1, maxValue=100, ticks=10, step = 1)
        OWGUI.separator(box, 0, 0)
        OWGUI.widgetLabel(box, 'Maximal number of rules')
        OWGUI.hSlider(box, self, 'maxRules', minValue=10000, maxValue=100000, step=10000, ticks=10000, debuggingEnabled = 0)

        OWGUI.button(self.space, self, "&Find Itemsets", self.findItemsets, default=True)

        OWGUI.rubber(self.controlArea)
        self.adjustSize()
    def __init__(self,parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "Calibration Plot", 1)

        # inputs
        self.inputs=[("Evaluation Results", orngTest.ExperimentResults, self.results, Default)]

        #set default settings
        self.CalibrationCurveWidth = 3
        self.ShowDiagonal = TRUE
        self.ShowRugs = TRUE
        #load settings
        self.loadSettings()

        # temp variables
        self.dres = None
        self.targetClass = None
        self.numberOfClasses = 0
        self.graphs = []
        self.classifierColor = None
        self.numberOfClassifiers = 0
        self.classifiers = []
        self.selectedClassifiers = []

        # GUI
        import sip
        sip.delete(self.mainArea.layout())
        self.graphsGridLayoutQGL = QGridLayout(self.mainArea)
        self.mainArea.setLayout(self.graphsGridLayoutQGL)

        ## save each ROC graph in separate file
        self.graph = None
        self.connect(self.graphButton, SIGNAL("clicked()"), self.saveToFile)

        ## general tab
        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.generalTab = OWGUI.createTabPage(self.tabs, "General")
        self.settingsTab = OWGUI.createTabPage(self.tabs, "Settings")

        self.splitQS = QSplitter()
        self.splitQS.setOrientation(Qt.Vertical)

        ## target class
        self.classCombo = OWGUI.comboBox(self.generalTab, self, 'targetClass', box='Target class', items=[], callback=self.target)
        OWGUI.separator(self.generalTab)

        ## classifiers selection (classifiersQLB)
        self.classifiersQVGB = OWGUI.widgetBox(self.generalTab, "Classifiers")
        self.classifiersQLB = OWGUI.listBox(self.classifiersQVGB, self, "selectedClassifiers", selectionMode = QListWidget.MultiSelection, callback = self.classifiersSelectionChange)
        self.unselectAllClassifiersQLB = OWGUI.button(self.classifiersQVGB, self, "(Un)select all", callback = self.SUAclassifiersQLB)

        ## settings tab
        OWGUI.hSlider(self.settingsTab, self, 'CalibrationCurveWidth', box='Calibration Curve Width', minValue=1, maxValue=9, step=1, callback=self.setCalibrationCurveWidth, ticks=1)
        OWGUI.checkBox(self.settingsTab, self, 'ShowDiagonal', 'Show Diagonal Line', tooltip='', callback=self.setShowDiagonal)
        OWGUI.checkBox(self.settingsTab, self, 'ShowRugs', 'Show Rugs', tooltip='', callback=self.setShowRugs)
        self.settingsTab.layout().addStretch(100)
Ejemplo n.º 4
0
 def _slider(self, widget, value, label, min_value, max_value, step, cb_name):
     OWGUI.hSlider(
         widget,
         self._plot,
         value,
         label=label,
         minValue=min_value,
         maxValue=max_value,
         step=step,
         callback=self._get_callback(cb_name),
     )
Ejemplo n.º 5
0
    def __init__(self,parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "AssociationRules", wantMainArea = 0)

        self.inputs = [("Examples", ExampleTable, self.setData)]
        self.outputs = [("Association Rules", orange.AssociationRules)]

        self.useSparseAlgorithm = 0
        self.classificationRules = 0
        self.minSupport = 40
        self.minConfidence = 20
        self.maxRules = 10000
        self.loadSettings()

        self.dataset = None

        box = OWGUI.widgetBox(self.space, "Algorithm", addSpace = True)
        self.cbSparseAlgorithm = OWGUI.checkBox(box, self, 'useSparseAlgorithm', 'Use algorithm for sparse data', tooltip="Use original Agrawal's algorithm", callback = self.checkSparse)
        self.cbClassificationRules = OWGUI.checkBox(box, self, 'classificationRules', 'Induce classification rules', tooltip="Induce classification rules")
        self.checkSparse()

        box = OWGUI.widgetBox(self.space, "Pruning", addSpace = True)
        OWGUI.widgetLabel(box, "Minimal support [%]")
        OWGUI.hSlider(box, self, 'minSupport', minValue=1, maxValue=100, ticks=10, step = 1)
        OWGUI.separator(box, 0, 0)
        OWGUI.widgetLabel(box, 'Minimal confidence [%]')
        OWGUI.hSlider(box, self, 'minConfidence', minValue=1, maxValue=100, ticks=10, step = 1)
        OWGUI.separator(box, 0, 0)
        OWGUI.widgetLabel(box, 'Maximal number of rules')
        OWGUI.hSlider(box, self, 'maxRules', minValue=10000, maxValue=100000, step=10000, ticks=10000, debuggingEnabled = 0)

        OWGUI.button(self.space, self, "&Build rules", self.generateRules)

        OWGUI.rubber(self.controlArea)
        
        self.adjustSize()
Ejemplo n.º 6
0
    def __init__(self,parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "AssociationRules", wantMainArea = 0)

        self.inputs = [("Data", ExampleTable, self.setData)]
        self.outputs = [("Association Rules", orange.AssociationRules)]

        self.useSparseAlgorithm = 0
        self.classificationRules = 0
        self.minSupport = 40
        self.minConfidence = 20
        self.maxRules = 10000
        self.loadSettings()

        self.dataset = None

        box = OWGUI.widgetBox(self.space, "Algorithm", addSpace = True)
        self.cbSparseAlgorithm = OWGUI.checkBox(box, self, 'useSparseAlgorithm',
                                        'Use algorithm for sparse data',
                                        tooltip="Use original Agrawal's algorithm",
                                        callback=self.checkSparse)
        
        self.cbClassificationRules = OWGUI.checkBox(box, self, 'classificationRules',
                                        'Induce classification rules',
                                        tooltip="Induce classification rules")
        self.checkSparse()

        box = OWGUI.widgetBox(self.space, "Pruning", addSpace = True)
        OWGUI.widgetLabel(box, "Minimal support [%]")
        OWGUI.hSlider(box, self, 'minSupport', minValue=1, maxValue=100, ticks=10, step = 1)
        OWGUI.separator(box, 0, 0)
        OWGUI.widgetLabel(box, 'Minimal confidence [%]')
        OWGUI.hSlider(box, self, 'minConfidence', minValue=1, maxValue=100, ticks=10, step = 1)
        OWGUI.separator(box, 0, 0)
        OWGUI.widgetLabel(box, 'Maximal number of rules')
        OWGUI.hSlider(box, self, 'maxRules', minValue=10000, maxValue=100000, step=10000, ticks=10000, debuggingEnabled = 0)

        OWGUI.button(self.space, self, "&Build rules", self.generateRules, default=True)

        OWGUI.rubber(self.controlArea)
        
        self.adjustSize()
Ejemplo n.º 7
0
    def __init__(self,parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "Sieve Multigram", wantGraph = True, wantStatusBar = True)

        self.inputs = [("Data", ExampleTable, self.setData), ("Features", AttributeList, self.setShownAttributes)]
        self.outputs = []

        #add a graph widget
        self.graph = OWSieveMultigramGraph(self.mainArea)
        self.graph.useAntialiasing = 1
        self.mainArea.layout().addWidget(self.graph)

        #set default settings
        self.graphCanvasColor = str(QColor(Qt.white).name())
        self.data = None
        self.graph.lineWidth = 3
        self.graph.minPearson = 2
        self.graph.maxPearson = 10
        self.showAllAttributes = 0

        # add a settings dialog and initialize its values
        self.loadSettings()

        #GUI
        # add a settings dialog and initialize its values
        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main")
        self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings")

        #add controls to self.controlArea widget
        self.createShowHiddenLists(self.GeneralTab, callback = self.updateGraph)

        OWGUI.button(self.GeneralTab, self, "Find Interesting Attr.", callback = self.interestingSubsetSelection, debuggingEnabled = 0)

        OWGUI.hSlider(self.SettingsTab, self, 'graph.lineWidth', box = 1, label = "Max line width:", minValue=1, maxValue=10, step=1, callback = self.updateGraph)
        residualBox = OWGUI.widgetBox(self.SettingsTab, "Attribute independence (Pearson residuals)")
        OWGUI.hSlider(residualBox, self, 'graph.maxPearson', label = "Max residual:", minValue=4, maxValue=12, step=1, callback = self.updateGraph)
        OWGUI.hSlider(residualBox, self, 'graph.minPearson', label = "Min residual:", minValue=0, maxValue=4, step=1, callback = self.updateGraph, tooltip = "The minimal absolute residual value that will be shown in graph")
        self.SettingsTab.layout().addStretch(100)

        self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile)
        self.resize(800, 600)
Ejemplo n.º 8
0
    def __init__(self,
                 parent=None,
                 signalManager=None,
                 name='Classification Tree Viewer'):
        OWWidget.__init__(self, parent, signalManager, name)

        self.dataLabels = (('Majority class', 'Class'),
                           ('Probability of majority class', 'P(Class)'),
                           ('Probability of target class',
                            'P(Target)'), ('Number of instances', '# Inst'),
                           ('Relative distribution', 'Distribution (rel)'),
                           ('Absolute distribution', 'Distribution (abs)'))

        #        self.callbackDeposit = []

        self.inputs = [("Classification Tree", orange.TreeClassifier,
                        self.setClassificationTree)]
        self.outputs = [("Examples", ExampleTable)]

        # Settings
        for s in self.settingsList[:6]:
            setattr(self, s, 1)
        self.expslider = 5
        self.targetClass = 0
        self.loadSettings()

        self.tree = None
        self.sliderValue = 5
        self.precision = 3
        self.precFrmt = "%%2.%if" % self.precision

        # GUI
        # parameters

        self.dBox = OWGUI.widgetBox(self.controlArea, 'Displayed information')
        for i in range(len(self.dataLabels)):
            checkColumn(self.dBox, self, self.dataLabels[i][0],
                        self.settingsList[i])

        OWGUI.separator(self.controlArea)

        self.slider = OWGUI.hSlider(self.controlArea,
                                    self,
                                    "sliderValue",
                                    box='Expand/shrink to level',
                                    minValue=1,
                                    maxValue=9,
                                    step=1,
                                    callback=self.sliderChanged)

        OWGUI.separator(self.controlArea)
        self.targetCombo = OWGUI.comboBox(self.controlArea,
                                          self,
                                          "targetClass",
                                          items=[],
                                          box="Target class",
                                          callback=self.setTarget,
                                          addSpace=True)

        self.infBox = OWGUI.widgetBox(self.controlArea, 'Tree size')
        self.infoa = OWGUI.widgetLabel(self.infBox, 'No tree.')
        self.infob = OWGUI.widgetLabel(self.infBox, ' ')

        OWGUI.rubber(self.controlArea)

        # list view
        self.splitter = QSplitter(Qt.Vertical, self.mainArea)
        self.mainArea.layout().addWidget(self.splitter)

        self.v = QTreeWidget(self.splitter)
        self.splitter.addWidget(self.v)
        self.v.setAllColumnsShowFocus(1)
        self.v.setHeaderLabels(['Classification Tree'] +
                               [label[1] for label in self.dataLabels])
        self.v.setColumnWidth(0, 250)
        self.connect(self.v, SIGNAL("itemSelectionChanged()"),
                     self.viewSelectionChanged)

        # rule
        self.rule = QTextEdit(self.splitter)
        self.splitter.addWidget(self.rule)
        self.rule.setReadOnly(1)
        self.splitter.setStretchFactor(0, 2)
        self.splitter.setStretchFactor(1, 1)

        self.resize(800, 400)

        self.resize(830, 400)
    def __init__(self,
                 parent=None,
                 signalManager=None,
                 name="Correspondence Analysis"):
        OWWidget.__init__(self, parent, signalManager, name, wantGraph=True)

        self.inputs = [("Data", ExampleTable, self.setData)]
        self.outputs = [("Selected Data", ExampleTable),
                        ("Remaining Data", ExampleTable)]

        self.colAttr = 0
        self.rowAttr = 1
        self.xPrincipalAxis = 0
        self.yPrincipalAxis = 1
        self.pointSize = 6
        self.alpha = 240
        self.jitter = 0
        self.showGridlines = 0
        self.percCol = 100
        self.percRow = 100
        self.autoSend = 0

        self.loadSettings()

        # GUI
        self.graph = OWGraph(self)
        self.graph.sendData = self.sendData
        self.mainArea.layout().addWidget(self.graph)

        self.controlAreaTab = OWGUI.tabWidget(self.controlArea)
        # Graph tab
        self.graphTab = graphTab = OWGUI.createTabPage(self.controlAreaTab,
                                                       "Graph")
        self.colAttrCB = OWGUI.comboBox(graphTab,
                                        self,
                                        "colAttr",
                                        "Column Attribute",
                                        tooltip="Column attribute",
                                        callback=self.runCA)

        self.rowAttrCB = OWGUI.comboBox(graphTab,
                                        self,
                                        "rowAttr",
                                        "Row Attribute",
                                        tooltip="Row attribute",
                                        callback=self.runCA)

        self.xAxisCB = OWGUI.comboBox(graphTab,
                                      self,
                                      "xPrincipalAxis",
                                      "Principal Axis X",
                                      tooltip="Principal axis X",
                                      callback=self.updateGraph)

        self.yAxisCB = OWGUI.comboBox(graphTab,
                                      self,
                                      "yPrincipalAxis",
                                      "Principal Axis Y",
                                      tooltip="Principal axis Y",
                                      callback=self.updateGraph)

        box = OWGUI.widgetBox(graphTab, "Contribution to Inertia")
        self.contributionInfo = OWGUI.widgetLabel(box, "NA\nNA")

        OWGUI.hSlider(
            graphTab,
            self,
            "percCol",
            "Percent of Column Points",
            1,
            100,
            1,
            callback=self.updateGraph,
            tooltip=
            "The percent of column points with the largest contribution to inertia"
        )

        OWGUI.hSlider(
            graphTab,
            self,
            "percRow",
            "Percent of Row Points",
            1,
            100,
            1,
            callback=self.updateGraph,
            tooltip=
            "The percent of row points with the largest contribution to inertia"
        )

        self.zoomSelect = ZoomSelectToolbar(self, graphTab, self.graph,
                                            self.autoSend)
        OWGUI.rubber(graphTab)

        # Settings tab
        self.settingsTab = settingsTab = OWGUI.createTabPage(
            self.controlAreaTab, "Settings")
        OWGUI.hSlider(settingsTab,
                      self,
                      "pointSize",
                      "Point Size",
                      3,
                      20,
                      step=1,
                      callback=self.setPointSize)

        OWGUI.hSlider(settingsTab,
                      self,
                      "alpha",
                      "Transparancy",
                      1,
                      255,
                      step=1,
                      callback=self.updateAlpha)

        OWGUI.hSlider(settingsTab,
                      self,
                      "jitter",
                      "Jitter Points",
                      0,
                      20,
                      step=1,
                      callback=self.updateGraph)

        box = OWGUI.widgetBox(settingsTab, "General Settings")
        OWGUI.checkBox(box,
                       self,
                       "showGridlines",
                       "Show gridlines",
                       tooltip="Show gridlines in the plot.",
                       callback=self.updateGridlines)
        OWGUI.rubber(settingsTab)

        self.connect(self.graphButton, SIGNAL("clicked()"),
                     self.graph.saveToFile)

        self.contingency = None
        self.contColAttr = None
        self.contRowAttr = None

        self.resize(800, 600)
Ejemplo n.º 10
0
    def __init__(self, parent=None, signalManager=None, name="SOM visualizer"):
        OWWidget.__init__(self, parent, signalManager, name)
        self.inputs = [("SOMMap", orngSOM.SOMMap, self.setSomMap),
                       ("Examples", ExampleTable, self.data)]
        self.outputs = [("Examples", ExampleTable)]

        self.labelNodes = 0
        self.commitOnChange = 0
        self.backgroundCheck = 1
        self.backgroundMode = 0
        self.histogram = 1
        self.attribute = 0
        self.discHistMode = 0
        self.targetValue = 0
        self.contHistMode = 0
        self.inputSet = 0

        self.somMap = None
        self.examples = None
        self.selectionChanged = False

        ##        layout = QVBoxLayout(self.mainArea) #,QVBoxLayout.TopToBottom,0)
        self.scene = SOMScene(self, self)
        self.sceneView = QGraphicsView(self.scene, self.mainArea)
        self.sceneView.viewport().setMouseTracking(True)

        self.mainArea.layout().addWidget(self.sceneView)

        self.loadSettings()
        call = lambda: self.scene.redrawSom()

        histTab = mainTab = self.controlArea

        self.mainTab = mainTab
        self.histTab = histTab

        self.backgroundBox = OWGUI.widgetBox(mainTab, "Background")
        #OWGUI.checkBox(self.backgroundBox, self, "backgroundCheck","Show background", callback=self.setBackground)
        b = OWGUI.radioButtonsInBox(self.backgroundBox,
                                    self,
                                    "scene.drawMode",
                                    self.drawModes,
                                    callback=self.setBackground)
        b.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed))
        self.componentCombo = OWGUI.comboBox(OWGUI.indentedBox(b),
                                             self,
                                             "scene.component",
                                             callback=self.setBackground)
        self.componentCombo.setEnabled(self.scene.drawMode == 2)
        OWGUI.checkBox(self.backgroundBox,
                       self,
                       "scene.showGrid",
                       "Show grid",
                       callback=self.scene.updateGrid)
        #b=OWGUI.widgetBox(mainTab, "Histogram")
        #OWGUI.separator(mainTab)

        b = OWGUI.widgetBox(mainTab,
                            "Histogram")  ##QVButtonGroup("Histogram", mainTab)
        #        b.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed))
        OWGUI.checkBox(b,
                       self,
                       "histogram",
                       "Show histogram",
                       callback=self.setHistogram)
        OWGUI.radioButtonsInBox(OWGUI.indentedBox(b),
                                self,
                                "inputSet",
                                ["Use training set", "Use input subset"],
                                callback=self.setHistogram)
        #OWGUI.separator(mainTab)

        b1 = OWGUI.widgetBox(mainTab)  ##QVBox(mainTab)
        #        b1.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed))
        b = OWGUI.hSlider(b1,
                          self,
                          "scene.objSize",
                          "Plot size",
                          10,
                          100,
                          step=10,
                          ticks=10,
                          callback=call)
        #        b.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed))
        #OWGUI.checkBox(b1, self, "labelNodes", "Node Labeling", callback=self.canvas.updateLabels)
        #OWGUI.separator(b1)

        b1 = OWGUI.widgetBox(b1, "Tooltip Info")
        OWGUI.checkBox(b1,
                       self,
                       "scene.showToolTip",
                       "Show tooltip",
                       callback=self.scene.updateToolTips)
        OWGUI.checkBox(b1,
                       self,
                       "scene.includeCodebook",
                       "Include codebook vector",
                       callback=self.scene.updateToolTips)
        b1.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed))
        #OWGUI.separator(mainTab)

        self.histogramBox = OWGUI.widgetBox(histTab, "Coloring")
        self.attributeCombo = OWGUI.comboBox(self.histogramBox,
                                             self,
                                             "attribute",
                                             callback=self.setHistogram)

        self.discTab = OWGUI.radioButtonsInBox(
            OWGUI.indentedBox(self.histogramBox),
            self,
            "discHistMode",
            ["Pie chart", "Majority value", "Majority value prob."],
            box=1,
            callback=self.setHistogram)
        self.discTab.setSizePolicy(
            QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed))
        #self.targetValueCombo=OWGUI.comboBox(b, self, "targetValue", callback=self.setHistogram)
        ##        QVBox(discTab)
        ##        b=QVButtonGroup(contTab)
        ##        b.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed))
        self.contTab = OWGUI.radioButtonsInBox(
            OWGUI.indentedBox(self.histogramBox),
            self,
            "contHistMode", ["Default", "Average value"],
            box=1,
            callback=self.setHistogram)
        self.contTab.setSizePolicy(
            QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed))
        ##        QVBox(contTab)

        ##        OWGUI.rubber(mainTab)

        b = OWGUI.widgetBox(self.controlArea, "Selection")
        OWGUI.button(b,
                     self,
                     "&Invert selection",
                     callback=self.scene.invertSelection)
        button = OWGUI.button(b, self, "&Commit", callback=self.commit)
        check = OWGUI.checkBox(b, self, "commitOnChange", "Commit on change")
        OWGUI.setStopper(self, button, check, "selectionChanged", self.commit)

        OWGUI.separator(self.controlArea)
        OWGUI.button(self.controlArea,
                     self,
                     "&Save Graph",
                     callback=self.saveGraph,
                     debuggingEnabled=0)

        self.selectionList = []
        self.ctrlPressed = False
        ##        self.setFocusPolicy(QWidget.StrongFocus)
        self.resize(800, 500)
Ejemplo n.º 11
0
    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)
Ejemplo n.º 12
0
    def __init__(self, parent=None, signalManager=None, name="Image viewer"):
        OWWidget.__init__(self, parent, signalManager, name, wantGraph=True)

        self.inputs = [("Data", ExampleTable, self.setData)]
        self.outputs = [("Data", ExampleTable)]

        self.imageAttr = 0
        self.titleAttr = 0
        self.zoom = 25
        self.autoCommit = False
        self.selectionChangedFlag = False

        #
        # GUI
        #

        self.loadSettings()

        self.info = OWGUI.widgetLabel(
            OWGUI.widgetBox(self.controlArea, "Info"), "Waiting for input\n")

        self.imageAttrCB = OWGUI.comboBox(
            self.controlArea,
            self,
            "imageAttr",
            box="Image Filename Attribute",
            tooltip="Attribute with image filenames",
            callback=[self.clearScene, self.setupScene],
            addSpace=True)

        self.titleAttrCB = OWGUI.comboBox(self.controlArea,
                                          self,
                                          "titleAttr",
                                          box="Title Attribute",
                                          tooltip="Attribute with image title",
                                          callback=self.updateTitles,
                                          addSpace=True)

        OWGUI.hSlider(self.controlArea,
                      self,
                      "zoom",
                      box="Zoom",
                      minValue=1,
                      maxValue=100,
                      step=1,
                      callback=self.updateZoom,
                      createLabel=False)

        OWGUI.separator(self.controlArea)

        box = OWGUI.widgetBox(self.controlArea, "Selection")
        b = OWGUI.button(box, self, "Commit", callback=self.commit)
        cb = OWGUI.checkBox(box,
                            self,
                            "autoCommit",
                            "Commit on any change",
                            tooltip="Send selections on any change",
                            callback=self.commitIf)

        OWGUI.setStopper(self,
                         b,
                         cb,
                         "selectionChangedFlag",
                         callback=self.commit)

        OWGUI.rubber(self.controlArea)

        self.scene = GraphicsScene()
        self.sceneView = QGraphicsView(self.scene, self)
        self.sceneView.setAlignment(Qt.AlignTop | Qt.AlignLeft)
        self.sceneView.setRenderHint(QPainter.Antialiasing, True)
        self.sceneView.setRenderHint(QPainter.TextAntialiasing, True)
        self.sceneView.setFocusPolicy(Qt.WheelFocus)
        self.sceneView.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self.sceneView.installEventFilter(self)
        self.mainArea.layout().addWidget(self.sceneView)

        self.scene.selectionChanged.connect(self.onSelectionChanged)
        self.scene.selectionRectPointChanged.connect(
            self.onSelectionRectPointChanged, Qt.QueuedConnection)
        self.graphButton.clicked.connect(self.saveScene)
        self.resize(800, 600)

        self.thumbnailWidget = None
        self.sceneLayout = None
        self.selectedExamples = []

        #: List of _ImageItems
        self.items = []

        self._errcount = 0
        self._successcount = 0

        self.loader = ImageLoader(self)

        # Add the "orange-sf" path prefix for locating files
        # distributed using `serverfiles`.
        sfdir = serverfiles.localpath()
        if sfdir not in [unicode(p) for p in QDir.searchPaths("orange-sf")]:
            QDir.addSearchPath("orange-sf", sfdir)
Ejemplo n.º 13
0
    def __init__(self,parent=None, signalManager = None, name = "Linear Projection", graphClass = None):
        OWVisWidget.__init__(self, parent, signalManager, name, TRUE)

        self.inputs = [("Data", ExampleTable, self.setData, Default),
                       ("Data Subset", ExampleTable, self.setSubsetData),
                       ("Features", AttributeList, self.setShownAttributes),
                       ("Evaluation Results", orngTest.ExperimentResults, self.setTestResults),
                       ("VizRank Learner", orange.Learner, self.setVizRankLearner),
                       ("Distances", orange.SymMatrix, self.setDistances)]
        self.outputs = [("Selected Data", ExampleTable), ("Other Data", ExampleTable), ("Features", AttributeList), ("FreeViz Learner", orange.Learner)]

        # local variables
        self.showAllAttributes = 0
        self.valueScalingType = 0
        self.autoSendSelection = 1
        self.data = None
        self.subsetData = None
        self.distances = None
        self.toolbarSelection = 0
        self.classificationResults = None
        self.outlierValues = None
        self.attributeSelectionList = None
        self.colorSettings = None
        self.selectedSchemaIndex = 0
        self.addProjectedPositions = 0
        self.resetAnchors = 0

        #add a graph widget
        if graphClass:
            self.graph = graphClass(self, self.mainArea, name)
        else:
            self.graph = OWLinProjGraph(self, self.mainArea, name)
        self.mainArea.layout().addWidget(self.graph)

        # graph variables
        self.graph.manualPositioning = 0
        self.graph.hideRadius = 0
        self.graph.showAnchors = 1
        self.graph.jitterContinuous = 0
        self.graph.showProbabilities = 0
        self.graph.useDifferentSymbols = 0
        self.graph.useDifferentColors = 1
        self.graph.tooltipKind = 0
        self.graph.tooltipValue = 0
        self.graph.scaleFactor = 1.0
        self.graph.squareGranularity = 3
        self.graph.spaceBetweenCells = 1
        self.graph.showAxisScale = 0
        self.graph.showValueLines = 0
        self.graph.valueLineLength = 5

        #load settings
        self.loadSettings()

##        # cluster dialog
##        self.clusterDlg = ClusterOptimization(self, self.signalManager, self.graph, name)
##        self.graph.clusterOptimization = self.clusterDlg

        # optimization dialog
        if name.lower() == "radviz":
            self.vizrank = OWVizRank(self, self.signalManager, self.graph, orngVizRank.RADVIZ, name)
            self.connect(self.graphButton, SIGNAL("clicked()"), self.saveToFile)
        elif name.lower() == "polyviz":
            self.vizrank = OWVizRank(self, self.signalManager, self.graph, orngVizRank.POLYVIZ, name)
            self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile)
        else:
            self.vizrank = OWVizRank(self, self.signalManager, self.graph, orngVizRank.LINEAR_PROJECTION, name)
            self.connect(self.graphButton, SIGNAL("clicked()"), self.saveToFile)

        self.optimizationDlg = self.vizrank  # for backward compatibility

        self.graph.normalizeExamples = (name.lower() == "radviz")       # ignore settings!! if we have radviz then normalize, otherwise not.

        #GUI
        # add a settings dialog and initialize its values

        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main")
        self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings", canScroll = 1)

        #add controls to self.controlArea widget
        self.createShowHiddenLists(self.GeneralTab, callback = self.updateGraphAndAnchors)

        self.optimizationButtons = OWGUI.widgetBox(self.GeneralTab, "Optimization Dialogs", orientation = "horizontal")
        self.vizrankButton = OWGUI.button(self.optimizationButtons, self, "VizRank", callback = self.vizrank.reshow, tooltip = "Opens VizRank dialog, where you can search for interesting projections with different subsets of attributes.", debuggingEnabled = 0)
        self.wdChildDialogs = [self.vizrank]    # used when running widget debugging

        # freeviz dialog
        if name.lower() in ["linear projection", "radviz"]:
            self.freeVizDlg = FreeVizOptimization(self, self.signalManager, self.graph, name)
            self.wdChildDialogs.append(self.freeVizDlg)
            self.freeVizDlgButton = OWGUI.button(self.optimizationButtons, self, "FreeViz", callback = self.freeVizDlg.reshow, tooltip = "Opens FreeViz dialog, where the position of attribute anchors is optimized so that class separation is improved", debuggingEnabled = 0)
            if name.lower() == "linear projection":
                self.freeVizLearner = FreeVizLearner(self.freeVizDlg)
                self.send("FreeViz Learner", self.freeVizLearner)

##        self.clusterDetectionDlgButton = OWGUI.button(self.optimizationButtons, self, "Cluster", callback = self.clusterDlg.reshow, debuggingEnabled = 0)
##        self.vizrankButton.setMaximumWidth(63)
##        self.clusterDetectionDlgButton.setMaximumWidth(63)
##        self.freeVizDlgButton.setMaximumWidth(63)
##        self.connect(self.clusterDlg.startOptimizationButton , SIGNAL("clicked()"), self.optimizeClusters)
##        self.connect(self.clusterDlg.resultList, SIGNAL("selectionChanged()"),self.showSelectedCluster)

        self.zoomSelectToolbar = OWToolbars.ZoomSelectToolbar(self, self.GeneralTab, self.graph, self.autoSendSelection)
        self.graph.autoSendSelectionCallback = self.selectionChanged
        self.connect(self.zoomSelectToolbar.buttonSendSelections, SIGNAL("clicked()"), self.sendSelections)

        # ####################################
        # SETTINGS TAB
        # #####
        self.extraTopBox = OWGUI.widgetBox(self.SettingsTab, orientation = "vertical")
        self.extraTopBox.hide()

        box = OWGUI.widgetBox(self.SettingsTab, "Point Properties")
        OWGUI.hSlider(box, self, 'graph.pointWidth', label = "Size: ", minValue=1, maxValue=20, step=1, callback = self.updateGraph)
        OWGUI.hSlider(box, self, 'graph.alphaValue', label = "Transparency: ", minValue=0, maxValue=255, step=10, callback = self.updateGraph)

        box = OWGUI.widgetBox(self.SettingsTab, "Jittering Options")
        OWGUI.comboBoxWithCaption(box, self, "graph.jitterSize", 'Jittering size (% of range):', callback = self.resetGraphData, items = self.jitterSizeNums, sendSelectedValue = 1, valueType = float)
        OWGUI.checkBox(box, self, 'graph.jitterContinuous', 'Jitter continuous attributes', callback = self.resetGraphData, tooltip = "Does jittering apply also on continuous attributes?")

        box = OWGUI.widgetBox(self.SettingsTab, "Scaling Options")
        OWGUI.qwtHSlider(box, self, "graph.scaleFactor", label = 'Inflate points by: ', minValue=1.0, maxValue= 10.0, step=0.1, callback = self.updateGraph, tooltip="If points lie too much together you can expand their position to improve perception", maxWidth = 90)

        box = OWGUI.widgetBox(self.SettingsTab, "General Graph Settings")
        #OWGUI.checkBox(box, self, 'graph.normalizeExamples', 'Normalize examples', callback = self.updateGraph)
        OWGUI.checkBox(box, self, 'graph.showLegend', 'Show legend', callback = self.updateGraph)
        bbox = OWGUI.widgetBox(box, orientation = "horizontal")
        OWGUI.checkBox(bbox, self, 'graph.showValueLines', 'Show value lines  ', callback = self.updateGraph)
        OWGUI.qwtHSlider(bbox, self, 'graph.valueLineLength', minValue=1, maxValue=10, step=1, callback = self.updateGraph, showValueLabel = 0)
        OWGUI.checkBox(box, self, 'graph.useDifferentSymbols', 'Use different symbols', callback = self.updateGraph, tooltip = "Show different class values using different symbols")
        OWGUI.checkBox(box, self, 'graph.useDifferentColors', 'Use different colors', callback = self.updateGraph, tooltip = "Show different class values using different colors")
        OWGUI.checkBox(box, self, 'graph.showFilledSymbols', 'Show filled symbols', callback = self.updateGraph)
        OWGUI.checkBox(box, self, 'graph.useAntialiasing', 'Use antialiasing', callback = self.updateGraph)
        wbox = OWGUI.widgetBox(box, orientation = "horizontal")
        OWGUI.checkBox(wbox, self, 'graph.showProbabilities', 'Show probabilities'+'  ', callback = self.updateGraph, tooltip = "Show a background image with class probabilities")
        smallWidget = OWGUI.SmallWidgetLabel(wbox, pixmap = 1, box = "Advanced settings", tooltip = "Show advanced settings")
        OWGUI.rubber(wbox)

        box = OWGUI.widgetBox(self.SettingsTab, "Colors", orientation = "horizontal")
        OWGUI.button(box, self, "Colors", self.setColors, tooltip = "Set the canvas background color and color palette for coloring variables", debuggingEnabled = 0)

        box = OWGUI.widgetBox(self.SettingsTab, "Tooltips Settings")
        OWGUI.comboBox(box, self, "graph.tooltipKind", items = ["Show line tooltips", "Show visible attributes", "Show all attributes"], callback = self.updateGraph)
        OWGUI.comboBox(box, self, "graph.tooltipValue", items = ["Tooltips show data values", "Tooltips show spring values"], callback = self.updateGraph, tooltip = "Do you wish that tooltips would show you original values of visualized attributes or the 'spring' values (values between 0 and 1). \nSpring values are scaled values that are used for determining the position of shown points. Observing these values will therefore enable you to \nunderstand why the points are placed where they are.")

        box = OWGUI.widgetBox(self.SettingsTab, "Auto Send Selected Data When...")
        OWGUI.checkBox(box, self, 'autoSendSelection', 'Adding/Removing selection areas', callback = self.selectionChanged, tooltip = "Send selected data whenever a selection area is added or removed")
        OWGUI.checkBox(box, self, 'graph.sendSelectionOnUpdate', 'Moving/Resizing selection areas', tooltip = "Send selected data when a user moves or resizes an existing selection area")
        OWGUI.comboBox(box, self, "addProjectedPositions", items = ["Do not modify the domain", "Append projection as attributes", "Append projection as meta attributes"], callback = self.sendSelections)
        self.selectionChanged()

        box = OWGUI.widgetBox(smallWidget.widget, orientation = "horizontal")
        OWGUI.widgetLabel(box, "Granularity:  ")
        OWGUI.hSlider(box, self, 'graph.squareGranularity', minValue=1, maxValue=10, step=1, callback = self.updateGraph)

        box = OWGUI.widgetBox(smallWidget.widget, orientation = "horizontal")
        OWGUI.checkBox(box, self, 'graph.spaceBetweenCells', 'Show space between cells', callback = self.updateGraph)

        self.SettingsTab.layout().addStretch(100)

        self.icons = self.createAttributeIconDict()
        self.debugSettings = ["hiddenAttributes", "shownAttributes"]

        dlg = self.createColorDialog()
        self.graph.contPalette = dlg.getContinuousPalette("contPalette")
        self.graph.discPalette = dlg.getDiscretePalette("discPalette")
        self.graph.setCanvasBackground(dlg.getColor("Canvas"))

        apply([self.zoomSelectToolbar.actionZooming, self.zoomSelectToolbar.actionRectangleSelection, self.zoomSelectToolbar.actionPolygonSelection][self.toolbarSelection], [])

        self.cbShowAllAttributes()      # update list boxes based on the check box value

        self.resize(900, 700)
Ejemplo n.º 14
0
    def __init__(self,
                 parentWidget=None,
                 signalManager=None,
                 graph=None,
                 parentName="Visualization widget"):
        OWWidget.__init__(self,
                          None,
                          signalManager,
                          "FreeViz Dialog",
                          savePosition=True,
                          wantMainArea=0,
                          wantStatusBar=1)
        FreeViz.__init__(self, graph)

        self.parentWidget = parentWidget
        self.parentName = parentName
        self.setCaption("FreeViz Optimization Dialog")
        self.cancelOptimization = 0
        self.forceRelation = 5
        self.disableAttractive = 0
        self.disableRepulsive = 0
        self.touringSpeed = 4
        self.graph = graph

        if self.graph:
            self.graph.hideRadius = 0
            self.graph.showAnchors = 1

        # differential evolution
        self.differentialEvolutionPopSize = 100
        self.DERadvizSolver = None

        self.loadSettings()

        self.layout().setMargin(0)
        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.MainTab = OWGUI.createTabPage(self.tabs, "Main")
        self.ProjectionsTab = OWGUI.createTabPage(self.tabs, "Projections")

        # ###########################
        # MAIN TAB
        OWGUI.comboBox(self.MainTab,
                       self,
                       "implementation",
                       box="FreeViz implementation",
                       items=[
                           "Fast (C) implementation",
                           "Slow (Python) implementation", "LDA"
                       ])

        box = OWGUI.widgetBox(self.MainTab, "Optimization")

        self.optimizeButton = OWGUI.button(box,
                                           self,
                                           "Optimize Separation",
                                           callback=self.optimizeSeparation)
        self.stopButton = OWGUI.button(box,
                                       self,
                                       "Stop Optimization",
                                       callback=self.stopOptimization)
        self.singleStepButton = OWGUI.button(
            box, self, "Single Step", callback=self.singleStepOptimization)
        f = self.optimizeButton.font()
        f.setBold(1)
        self.optimizeButton.setFont(f)
        self.stopButton.setFont(f)
        self.stopButton.hide()
        self.attrKNeighboursCombo = OWGUI.comboBoxWithCaption(
            box,
            self,
            "stepsBeforeUpdate",
            "Number of steps before updating graph: ",
            tooltip=
            "Set the number of optimization steps that will be executed before the updated anchor positions will be visualized",
            items=[1, 3, 5, 10, 15, 20, 30, 50, 75, 100, 150, 200, 300],
            sendSelectedValue=1,
            valueType=int)
        OWGUI.checkBox(box,
                       self,
                       "mirrorSymmetry",
                       "Keep mirror symmetry",
                       tooltip="'Rotational' keeps the second anchor upside")

        vbox = OWGUI.widgetBox(self.MainTab, "Set anchor positions")
        hbox1 = OWGUI.widgetBox(vbox, orientation="horizontal")
        OWGUI.button(hbox1, self, "Circle", callback=self.radialAnchors)
        OWGUI.button(hbox1, self, "Random", callback=self.randomAnchors)
        self.manualPositioningButton = OWGUI.button(
            hbox1, self, "Manual", callback=self.setManualPosition)
        self.manualPositioningButton.setCheckable(1)
        OWGUI.comboBox(vbox,
                       self,
                       "restrain",
                       label="Restrain anchors:",
                       orientation="horizontal",
                       items=["Unrestrained", "Fixed Length", "Fixed Angle"],
                       callback=self.setRestraints)

        box2 = OWGUI.widgetBox(self.MainTab, "Forces", orientation="vertical")

        self.cbLaw = OWGUI.comboBox(
            box2,
            self,
            "law",
            label="Law",
            labelWidth=40,
            orientation="horizontal",
            items=["Linear", "Square", "Gaussian", "KNN", "Variance"],
            callback=self.forceLawChanged)

        hbox2 = OWGUI.widgetBox(box2, orientation="horizontal")
        hbox2.layout().addSpacing(10)

        validSigma = QDoubleValidator(self)
        validSigma.setBottom(0.01)
        self.spinSigma = OWGUI.lineEdit(hbox2,
                                        self,
                                        "forceSigma",
                                        label="Kernel width (sigma) ",
                                        labelWidth=110,
                                        orientation="horizontal",
                                        valueType=float)
        self.spinSigma.setFixedSize(60, self.spinSigma.sizeHint().height())
        self.spinSigma.setSizePolicy(
            QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed))

        box2.layout().addSpacing(20)

        self.cbforcerel = OWGUI.comboBox(box2,
                                         self,
                                         "forceRelation",
                                         label="Attractive : Repulsive  ",
                                         orientation="horizontal",
                                         items=self.forceRelValues,
                                         callback=self.updateForces)
        self.cbforcebal = OWGUI.checkBox(
            box2,
            self,
            "forceBalancing",
            "Dynamic force balancing",
            tooltip=
            "Normalize the forces so that the total sums of the\nrepulsive and attractive are in the above proportion."
        )

        box2.layout().addSpacing(20)

        self.cbDisableAttractive = OWGUI.checkBox(
            box2,
            self,
            "disableAttractive",
            "Disable attractive forces",
            callback=self.setDisableAttractive)
        self.cbDisableRepulsive = OWGUI.checkBox(
            box2,
            self,
            "disableRepulsive",
            "Disable repulsive forces",
            callback=self.setDisableRepulsive)

        box = OWGUI.widgetBox(self.MainTab, "Show anchors")
        OWGUI.checkBox(box,
                       self,
                       'graph.showAnchors',
                       'Show attribute anchors',
                       callback=self.parentWidget.updateGraph)
        OWGUI.qwtHSlider(box,
                         self,
                         "graph.hideRadius",
                         label="Hide radius",
                         minValue=0,
                         maxValue=9,
                         step=1,
                         ticks=0,
                         callback=self.parentWidget.updateGraph)
        self.freeAttributesButton = OWGUI.button(box,
                                                 self,
                                                 "Remove hidden attributes",
                                                 callback=self.removeHidden)

        if parentName.lower() != "radviz":
            pcaBox = OWGUI.widgetBox(self.ProjectionsTab,
                                     "Principal Component Analysis")
            OWGUI.button(pcaBox,
                         self,
                         "Principal component analysis",
                         callback=self.findPCAProjection)
            OWGUI.button(pcaBox,
                         self,
                         "Supervised principal component analysis",
                         callback=self.findSPCAProjection)
            OWGUI.checkBox(pcaBox, self, "useGeneralizedEigenvectors",
                           "Merge examples with same class value")
            plsBox = OWGUI.widgetBox(self.ProjectionsTab,
                                     "Partial Least Squares")
            OWGUI.button(plsBox,
                         self,
                         "Partial least squares",
                         callback=self.findPLSProjection)

        box = OWGUI.widgetBox(self.ProjectionsTab, "Projection Tours")
        self.startTourButton = OWGUI.button(box,
                                            self,
                                            "Start Random Touring",
                                            callback=self.startRandomTouring)
        self.stopTourButton = OWGUI.button(box,
                                           self,
                                           "Stop Touring",
                                           callback=self.stopRandomTouring)
        self.stopTourButton.hide()
        OWGUI.hSlider(box,
                      self,
                      'touringSpeed',
                      label="Speed:  ",
                      minValue=1,
                      maxValue=10,
                      step=1)
        OWGUI.rubber(self.ProjectionsTab)

        box = OWGUI.widgetBox(self.ProjectionsTab, "Signal to Noise Heuristic")
        #OWGUI.comboBoxWithCaption(box, self, "s2nSpread", "Anchor spread: ", tooltip = "Are the anchors for each class value placed together or are they distributed along the circle", items = range(11), callback = self.s2nMixAnchors)
        box2 = OWGUI.widgetBox(box, 0, orientation="horizontal")
        OWGUI.widgetLabel(box2, "Anchor spread:           ")
        OWGUI.hSlider(box2,
                      self,
                      's2nSpread',
                      minValue=0,
                      maxValue=10,
                      step=1,
                      callback=self.s2nMixAnchors,
                      labelFormat="  %d",
                      ticks=0)
        OWGUI.comboBoxWithCaption(
            box,
            self,
            "s2nPlaceAttributes",
            "Attributes to place: ",
            tooltip=
            "Set the number of top ranked attributes to place. You can select a higher value than the actual number of attributes",
            items=self.attrsNum,
            callback=self.s2nMixAnchors,
            sendSelectedValue=1,
            valueType=int)
        OWGUI.checkBox(box, self, 'autoSetParameters',
                       'Automatically find optimal parameters')
        self.s2nMixButton = OWGUI.button(box,
                                         self,
                                         "Place anchors",
                                         callback=self.s2nMixAnchorsAutoSet)

        self.forceLawChanged()
        self.updateForces()
        self.cbforcebal.setDisabled(self.cbDisableAttractive.isChecked()
                                    or self.cbDisableRepulsive.isChecked())
        self.resize(320, 650)
 def __init__(self, parent=None, signalManager=None, name="Image viewer"):
     OWWidget.__init__(self, parent, signalManager, name, wantGraph=True)
     
     self.inputs = [("Data", ExampleTable, self.setData)]
     self.outputs = [("Data", ExampleTable)]
     
     self.imageAttr = 0
     self.titleAttr = 0
     self.zoom = 25
     self.autoCommit = False
     self.selectionChangedFlag = False
     
     # ###
     # GUI
     # ###
     
     self.loadSettings()
     
     self.imageAttrCB = OWGUI.comboBox(self.controlArea, self, "imageAttr",
                                       box="Image Filename Attribute",
                                       tooltip="Attribute with image filenames",
                                       callback=self.setupScene,
                                       addSpace=True
                                       )
     
     self.titleAttrCB = OWGUI.comboBox(self.controlArea, self, "titleAttr",
                                       box="Title Attribute",
                                       tooltip="Attribute with image title",
                                       callback=self.updateTitles,
                                       addSpace=True
                                       )
     
     OWGUI.hSlider(self.controlArea, self, "zoom",
                   box="Zoom", minValue=1, maxValue=100, step=1,
                   callback=self.updateZoom,
                   createLabel=False
                   )
     
     OWGUI.separator(self.controlArea)
     
     box = OWGUI.widgetBox(self.controlArea, "Selection")
     b = OWGUI.button(box, self, "Commit", callback=self.commit)
     cb = OWGUI.checkBox(box, self, "autoCommit", "Commit on any change",
                         tooltip="Send selections on any change",
                         callback=self.commitIf
                         )
     OWGUI.setStopper(self, b, cb, "selectionChangedFlag", callback=self.commit)
     
     OWGUI.rubber(self.controlArea)
     
     self.scene = GraphicsScene()
     self.sceneView = QGraphicsView(self.scene, self)
     self.sceneView.setAlignment(Qt.AlignTop | Qt.AlignLeft)
     self.sceneView.setRenderHint(QPainter.Antialiasing, True)
     self.sceneView.setRenderHint(QPainter.TextAntialiasing, True)
     self.sceneView.setFocusPolicy(Qt.WheelFocus)
     self.mainArea.layout().addWidget(self.sceneView)
     
     self.connect(self.scene, SIGNAL("selectionChanged()"), self.onSelectionChanged)
     self.connect(self.scene, SIGNAL("selectionRectPointChanged(QPointF)"), self.onSelectionRectPointChanged, Qt.QueuedConnection)
     self.connect(self.graphButton, SIGNAL("clicked()"), self.saveScene)
     self.resize(800, 600)
     
     self.sceneLayout = None
     self.selectedExamples = []
     self.hasTypeImageHint = False
     
     self.updateZoom()
Ejemplo n.º 16
0
    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)
Ejemplo n.º 17
0
    def __init__(self, parent=None, signalManager=None, name='TreeViewer2D'):
        OWWidget.__init__(self, parent, signalManager, name)
        self.root = None
        self.selectedNode = None

        self.inputs = [("Classification Tree", orange.TreeClassifier,
                        self.ctree)]
        self.outputs = [("Examples", ExampleTable)]

        #set default settings
        self.ZoomAutoRefresh = 0
        self.AutoArrange = 0
        self.ToolTipsEnabled = 1
        self.MaxTreeDepth = 5
        self.MaxTreeDepthB = 0
        self.LineWidth = 5
        self.LineWidthMethod = 0
        self.NodeSize = 5
        self.NodeInfo = [0, 1]

        self.NodeColorMethod = 0
        self.Zoom = 5
        self.VSpacing = 5
        self.HSpacing = 5
        self.TruncateText = 1

        self.loadSettings()
        self.NodeInfo.sort()

        # GUI definition
        self.tabs = OWGUI.tabWidget(self.controlArea)

        # GENERAL TAB
        GeneralTab = OWGUI.createTabPage(self.tabs, "General")
        TreeTab = OWGUI.createTabPage(self.tabs, "Tree")
        NodeTab = OWGUI.createTabPage(self.tabs, "Node")

        OWGUI.hSlider(GeneralTab,
                      self,
                      'Zoom',
                      box='Zoom',
                      minValue=1,
                      maxValue=10,
                      step=1,
                      callback=self.toggleZoomSlider,
                      ticks=1)
        OWGUI.hSlider(GeneralTab,
                      self,
                      'VSpacing',
                      box='Vertical spacing',
                      minValue=1,
                      maxValue=10,
                      step=1,
                      callback=self.toggleVSpacing,
                      ticks=1)
        OWGUI.hSlider(GeneralTab,
                      self,
                      'HSpacing',
                      box='Horizontal spacing',
                      minValue=1,
                      maxValue=10,
                      step=1,
                      callback=self.toggleHSpacing,
                      ticks=1)

        OWGUI.checkBox(GeneralTab,
                       self,
                       'ToolTipsEnabled',
                       'Show node tool tips',
                       tooltip='When mouse over the node show tool tip',
                       callback=self.updateNodeToolTips)
        #        OWGUI.checkBox(GeneralTab, self, 'TruncateText', 'Truncate text to fit margins',
        #                       tooltip='Truncate any text to fit the node width',
        #                       callback=self.toggleTruncateText)

        self.infBox = OWGUI.widgetBox(GeneralTab,
                                      'Tree Size',
                                      sizePolicy=QSizePolicy(
                                          QSizePolicy.Minimum,
                                          QSizePolicy.Fixed))
        self.infoa = OWGUI.widgetLabel(self.infBox, 'No tree.')
        self.infob = OWGUI.widgetLabel(self.infBox, " ")

        # TREE TAB
        OWGUI.checkWithSpin(TreeTab,
                            self,
                            'Max tree depth:',
                            1,
                            20,
                            'MaxTreeDepthB',
                            "MaxTreeDepth",
                            tooltip='Defines the depth of the tree displayed',
                            checkCallback=self.toggleTreeDepth,
                            spinCallback=self.toggleTreeDepth)
        OWGUI.spin(
            TreeTab,
            self,
            'LineWidth',
            min=1,
            max=10,
            step=1,
            label='Max line width:',
            tooltip='Defines max width of the edges that connect tree nodes',
            callback=self.toggleLineWidth)
        OWGUI.radioButtonsInBox(
            TreeTab,
            self,
            'LineWidthMethod', ['No dependency', 'Root node', 'Parent node'],
            box='Reference for Line Width',
            tooltips=[
                'All edges are of the same width',
                'Line width is relative to number of cases in root node',
                'Line width is relative to number of cases in parent node'
            ],
            callback=self.toggleLineWidth)

        # NODE TAB
        #        # Node size options
        #        OWGUI.hSlider(NodeTab, self, 'NodeSize', box='Node width',
        #                      minValue=1, maxValue=10, step=1,
        #                      callback=self.toggleNodeSize, ticks=1)

        # Node information
        OWGUI.button(self.controlArea,
                     self,
                     "Navigator",
                     self.toggleNavigator,
                     debuggingEnabled=0)
        findbox = OWGUI.widgetBox(self.controlArea, orientation="horizontal")
        self.centerRootButton = OWGUI.button(
            findbox,
            self,
            "Find Root",
            callback=lambda: self.rootNode and self.sceneView.centerOn(
                self.rootNode.x(), self.rootNode.y()))
        self.centerNodeButton=OWGUI.button(findbox, self, "Find Selected",
                                           callback=lambda :self.selectedNode and \
                                     self.sceneView.centerOn(self.selectedNode.scenePos()))
        self.NodeTab = NodeTab
        self.TreeTab = TreeTab
        self.GeneralTab = GeneralTab
        OWGUI.rubber(GeneralTab)
        OWGUI.rubber(TreeTab)
        #        OWGUI.rubber(NodeTab)
        self.rootNode = None
        self.tree = None
        self.resize(800, 500)
Ejemplo n.º 18
0
    def __init__(self, parent=None, signalManager=None, name="ScatterPlot 3D"):
        OWWidget.__init__(self, parent, signalManager, name, True)

        self.inputs = [
            ("Data", ExampleTable, self.set_data, Default),
            ("Subset Examples", ExampleTable, self.set_subset_data),
        ]
        self.outputs = [("Selected Data", ExampleTable), ("Other Data", ExampleTable)]

        self.x_attr = ""
        self.y_attr = ""
        self.z_attr = ""

        self.x_attr_discrete = False
        self.y_attr_discrete = False
        self.z_attr_discrete = False

        self.color_attr = ""
        self.size_attr = ""
        self.symbol_attr = ""
        self.label_attr = ""

        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.main_tab = OWGUI.createTabPage(self.tabs, "Main")
        self.settings_tab = OWGUI.createTabPage(self.tabs, "Settings", canScroll=True)

        self.x_attr_cb = OWGUI.comboBox(
            self.main_tab,
            self,
            "x_attr",
            box="X-axis attribute",
            tooltip="Attribute to plot on X axis.",
            callback=self.on_axis_change,
            sendSelectedValue=1,
            valueType=str,
        )

        self.y_attr_cb = OWGUI.comboBox(
            self.main_tab,
            self,
            "y_attr",
            box="Y-axis attribute",
            tooltip="Attribute to plot on Y axis.",
            callback=self.on_axis_change,
            sendSelectedValue=1,
            valueType=str,
        )

        self.z_attr_cb = OWGUI.comboBox(
            self.main_tab,
            self,
            "z_attr",
            box="Z-axis attribute",
            tooltip="Attribute to plot on Z axis.",
            callback=self.on_axis_change,
            sendSelectedValue=1,
            valueType=str,
        )

        self.color_attr_cb = OWGUI.comboBox(
            self.main_tab,
            self,
            "color_attr",
            box="Point color",
            tooltip="Attribute to use for point color",
            callback=self.on_axis_change,
            sendSelectedValue=1,
            valueType=str,
        )

        # Additional point properties (labels, size, symbol).
        additional_box = OWGUI.widgetBox(self.main_tab, "Additional Point Properties")
        self.size_attr_cb = OWGUI.comboBox(
            additional_box,
            self,
            "size_attr",
            label="Point size:",
            tooltip="Attribute to use for point size",
            callback=self.on_axis_change,
            indent=10,
            emptyString="(Same size)",
            sendSelectedValue=1,
            valueType=str,
        )

        self.symbol_attr_cb = OWGUI.comboBox(
            additional_box,
            self,
            "symbol_attr",
            label="Point symbol:",
            tooltip="Attribute to use for point symbol",
            callback=self.on_axis_change,
            indent=10,
            emptyString="(Same symbol)",
            sendSelectedValue=1,
            valueType=str,
        )

        self.label_attr_cb = OWGUI.comboBox(
            additional_box,
            self,
            "label_attr",
            label="Point label:",
            tooltip="Attribute to use for pointLabel",
            callback=self.on_axis_change,
            indent=10,
            emptyString="(No labels)",
            sendSelectedValue=1,
            valueType=str,
        )

        self.plot = ScatterPlot(self)
        self.vizrank = OWVizRank(self, self.signalManager, self.plot, orngVizRank.SCATTERPLOT3D, "ScatterPlot3D")
        self.optimization_dlg = self.vizrank

        self.optimization_buttons = OWGUI.widgetBox(self.main_tab, "Optimization dialogs", orientation="horizontal")
        OWGUI.button(
            self.optimization_buttons,
            self,
            "VizRank",
            callback=self.vizrank.reshow,
            tooltip="Opens VizRank dialog, where you can search for interesting projections with different subsets of attributes",
            debuggingEnabled=0,
        )

        box = OWGUI.widgetBox(self.settings_tab, "Point properties")
        OWGUI.hSlider(
            box,
            self,
            "plot.symbol_scale",
            label="Symbol scale",
            minValue=1,
            maxValue=20,
            tooltip="Scale symbol size",
            callback=self.on_checkbox_update,
        )

        OWGUI.hSlider(
            box,
            self,
            "plot.alpha_value",
            label="Transparency",
            minValue=10,
            maxValue=255,
            tooltip="Point transparency value",
            callback=self.on_checkbox_update,
        )
        OWGUI.rubber(box)

        box = OWGUI.widgetBox(self.settings_tab, "Jittering Options")
        self.jitter_size_combo = OWGUI.comboBox(
            box,
            self,
            "plot.jitter_size",
            label="Jittering size (% of size)" + "  ",
            orientation="horizontal",
            callback=self.handleNewSignals,
            items=self.jitter_sizes,
            sendSelectedValue=1,
            valueType=float,
        )
        OWGUI.checkBox(
            box,
            self,
            "plot.jitter_continuous",
            "Jitter continuous attributes",
            callback=self.handleNewSignals,
            tooltip="Does jittering apply also on continuous attributes?",
        )

        self.dark_theme = False

        box = OWGUI.widgetBox(self.settings_tab, "General settings")
        OWGUI.checkBox(box, self, "plot.show_x_axis_title", "X axis title", callback=self.on_checkbox_update)
        OWGUI.checkBox(box, self, "plot.show_y_axis_title", "Y axis title", callback=self.on_checkbox_update)
        OWGUI.checkBox(box, self, "plot.show_z_axis_title", "Z axis title", callback=self.on_checkbox_update)
        OWGUI.checkBox(box, self, "plot.show_legend", "Show legend", callback=self.on_checkbox_update)
        OWGUI.checkBox(box, self, "plot.use_2d_symbols", "2D symbols", callback=self.update_plot)
        OWGUI.checkBox(box, self, "dark_theme", "Dark theme", callback=self.on_theme_change)
        OWGUI.checkBox(box, self, "plot.show_grid", "Show grid", callback=self.on_checkbox_update)
        OWGUI.checkBox(box, self, "plot.show_axes", "Show axes", callback=self.on_checkbox_update)
        OWGUI.checkBox(box, self, "plot.show_chassis", "Show chassis", callback=self.on_checkbox_update)
        OWGUI.checkBox(box, self, "plot.hide_outside", "Hide outside", callback=self.on_checkbox_update)
        OWGUI.rubber(box)

        box = OWGUI.widgetBox(self.settings_tab, "Mouse", orientation="horizontal")
        OWGUI.hSlider(
            box,
            self,
            "plot.mouse_sensitivity",
            label="Sensitivity",
            minValue=1,
            maxValue=10,
            step=1,
            callback=self.plot.update,
            tooltip="Change mouse sensitivity",
        )

        gui = self.plot.gui
        buttons = gui.default_zoom_select_buttons
        buttons.insert(2, (gui.UserButton, "Rotate", "state", ROTATING, None, "Dlg_undo"))
        self.zoom_select_toolbar = gui.zoom_select_toolbar(self.main_tab, buttons=buttons)
        self.connect(self.zoom_select_toolbar.buttons[gui.SendSelection], SIGNAL("clicked()"), self.send_selection)
        self.connect(self.zoom_select_toolbar.buttons[gui.Zoom], SIGNAL("clicked()"), self.plot.unselect_all_points)
        self.plot.set_selection_behavior(OWPlot.ReplaceSelection)

        self.tooltip_kind = TooltipKind.NONE
        box = OWGUI.widgetBox(self.settings_tab, "Tooltips Settings")
        OWGUI.comboBox(
            box, self, "tooltip_kind", items=["Don't Show Tooltips", "Show Visible Attributes", "Show All Attributes"]
        )

        self.plot.mouseover_callback = self.mouseover_callback

        self.main_tab.layout().addStretch(100)
        self.settings_tab.layout().addStretch(100)

        self.mainArea.layout().addWidget(self.plot)
        self.connect(self.graphButton, SIGNAL("clicked()"), self.plot.save_to_file)

        self.loadSettings()
        self.plot.update_camera()
        self.on_theme_change()

        self.data = None
        self.subset_data = None
        self.resize(1100, 600)
Ejemplo n.º 19
0
    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)
Ejemplo n.º 20
0
    def __init__(self, parentWidget = None, signalManager = None, graph = None, parentName = "Visualization widget"):
        OWWidget.__init__(self, None, signalManager, "FreeViz Dialog", savePosition = True, wantMainArea = 0, wantStatusBar = 1)
        FreeViz.__init__(self, graph)

        self.parentWidget = parentWidget
        self.parentName = parentName
        self.setCaption("FreeViz Optimization Dialog")
        self.cancelOptimization = 0
        self.forceRelation = 5
        self.disableAttractive = 0
        self.disableRepulsive = 0
        self.touringSpeed = 4
        self.graph = graph

        if self.graph:
            self.graph.hideRadius = 0
            self.graph.showAnchors = 1

        # differential evolution
        self.differentialEvolutionPopSize = 100
        self.DERadvizSolver = None

        self.loadSettings()

        self.layout().setMargin(0)
        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.MainTab = OWGUI.createTabPage(self.tabs, "Main")
        self.ProjectionsTab = OWGUI.createTabPage(self.tabs, "Projections")

        # ###########################
        # MAIN TAB
        OWGUI.comboBox(self.MainTab, self, "implementation", box = "FreeViz implementation", items = ["Fast (C) implementation", "Slow (Python) implementation", "LDA"])

        box = OWGUI.widgetBox(self.MainTab, "Optimization")

        self.optimizeButton = OWGUI.button(box, self, "Optimize Separation", callback = self.optimizeSeparation)
        self.stopButton = OWGUI.button(box, self, "Stop Optimization", callback = self.stopOptimization)
        self.singleStepButton = OWGUI.button(box, self, "Single Step", callback = self.singleStepOptimization)
        f = self.optimizeButton.font(); f.setBold(1)
        self.optimizeButton.setFont(f)
        self.stopButton.setFont(f); self.stopButton.hide()
        self.attrKNeighboursCombo = OWGUI.comboBoxWithCaption(box, self, "stepsBeforeUpdate", "Number of steps before updating graph: ", tooltip = "Set the number of optimization steps that will be executed before the updated anchor positions will be visualized", items = [1, 3, 5, 10, 15, 20, 30, 50, 75, 100, 150, 200, 300], sendSelectedValue = 1, valueType = int)
        OWGUI.checkBox(box, self, "mirrorSymmetry", "Keep mirror symmetry", tooltip = "'Rotational' keeps the second anchor upside")

        vbox = OWGUI.widgetBox(self.MainTab, "Set anchor positions")
        hbox1 = OWGUI.widgetBox(vbox, orientation = "horizontal")
        OWGUI.button(hbox1, self, "Sphere" if "3d" in self.parentName.lower() else "Circle", callback = self.radialAnchors)
        OWGUI.button(hbox1, self, "Random", callback = self.randomAnchors)
        self.manualPositioningButton = OWGUI.button(hbox1, self, "Manual", callback = self.setManualPosition)
        self.manualPositioningButton.setCheckable(1)
        OWGUI.comboBox(vbox, self, "restrain", label="Restrain anchors:", orientation = "horizontal", items = ["Unrestrained", "Fixed Length", "Fixed Angle"], callback = self.setRestraints)

        box2 = OWGUI.widgetBox(self.MainTab, "Forces", orientation = "vertical")

        self.cbLaw = OWGUI.comboBox(box2, self, "law", label="Law", labelWidth = 40, orientation="horizontal", items=["Linear", "Square", "Gaussian", "KNN", "Variance"], callback = self.forceLawChanged)

        hbox2 = OWGUI.widgetBox(box2, orientation = "horizontal")
        hbox2.layout().addSpacing(10)

        validSigma = QDoubleValidator(self); validSigma.setBottom(0.01)
        self.spinSigma = OWGUI.lineEdit(hbox2, self, "forceSigma", label = "Kernel width (sigma) ", labelWidth = 110, orientation = "horizontal", valueType = float)
        self.spinSigma.setFixedSize(60, self.spinSigma.sizeHint().height())
        self.spinSigma.setSizePolicy(QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed))

        box2.layout().addSpacing(20)

        self.cbforcerel = OWGUI.comboBox(box2, self, "forceRelation", label= "Attractive : Repulsive  ",orientation = "horizontal", items=self.forceRelValues, callback = self.updateForces)
        self.cbforcebal = OWGUI.checkBox(box2, self, "forceBalancing", "Dynamic force balancing", tooltip="Normalize the forces so that the total sums of the\nrepulsive and attractive are in the above proportion.")

        box2.layout().addSpacing(20)

        self.cbDisableAttractive = OWGUI.checkBox(box2, self, "disableAttractive", "Disable attractive forces", callback = self.setDisableAttractive)
        self.cbDisableRepulsive = OWGUI.checkBox(box2, self, "disableRepulsive", "Disable repulsive forces", callback = self.setDisableRepulsive)

        box = OWGUI.widgetBox(self.MainTab, "Show anchors")
        OWGUI.checkBox(box, self, 'graph.showAnchors', 'Show attribute anchors', callback = self.parentWidget.updateGraph)
        OWGUI.qwtHSlider(box, self, "graph.hideRadius", label="Hide radius", minValue=0, maxValue=9, step=1, ticks=0, callback = self.parentWidget.updateGraph)
        self.freeAttributesButton = OWGUI.button(box, self, "Remove hidden attributes", callback = self.removeHidden)

        if parentName.lower() != "radviz" and parentName.lower() != "sphereviz":
            pcaBox = OWGUI.widgetBox(self.ProjectionsTab, "Principal Component Analysis")
            OWGUI.button(pcaBox, self, "Principal component analysis", callback = self.findPCAProjection)
            OWGUI.button(pcaBox, self, "Supervised principal component analysis", callback = self.findSPCAProjection)
            OWGUI.checkBox(pcaBox, self, "useGeneralizedEigenvectors", "Merge examples with same class value")
            plsBox = OWGUI.widgetBox(self.ProjectionsTab, "Partial Least Squares")
            OWGUI.button(plsBox, self, "Partial least squares", callback = self.findPLSProjection)
        
        box = OWGUI.widgetBox(self.ProjectionsTab, "Projection Tours")
        self.startTourButton = OWGUI.button(box, self, "Start Random Touring", callback = self.startRandomTouring)
        self.stopTourButton = OWGUI.button(box, self, "Stop Touring", callback = self.stopRandomTouring)
        self.stopTourButton.hide()
        OWGUI.hSlider(box, self, 'touringSpeed', label = "Speed:  ", minValue=1, maxValue=10, step=1)
        OWGUI.rubber(self.ProjectionsTab)
        
        box = OWGUI.widgetBox(self.ProjectionsTab, "Signal to Noise Heuristic")
        #OWGUI.comboBoxWithCaption(box, self, "s2nSpread", "Anchor spread: ", tooltip = "Are the anchors for each class value placed together or are they distributed along the circle", items = range(11), callback = self.s2nMixAnchors)
        box2 = OWGUI.widgetBox(box, 0, orientation = "horizontal")
        OWGUI.widgetLabel(box2, "Anchor spread:           ")
        OWGUI.hSlider(box2, self, 's2nSpread', minValue=0, maxValue=10, step=1, callback = self.s2nMixAnchors, labelFormat="  %d", ticks=0)
        OWGUI.comboBoxWithCaption(box, self, "s2nPlaceAttributes", "Attributes to place: ", tooltip = "Set the number of top ranked attributes to place. You can select a higher value than the actual number of attributes", items = self.attrsNum, callback = self.s2nMixAnchors, sendSelectedValue = 1, valueType = int)
        OWGUI.checkBox(box, self, 'autoSetParameters', 'Automatically find optimal parameters')
        self.s2nMixButton = OWGUI.button(box, self, "Place anchors", callback = self.s2nMixAnchorsAutoSet)


        self.forceLawChanged()
        self.updateForces()
        self.cbforcebal.setDisabled(self.cbDisableAttractive.isChecked() or self.cbDisableRepulsive.isChecked())
        self.resize(320,650)
Ejemplo n.º 21
0
    def __init__(self, parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "Scatter Plot", TRUE)

        self.inputs =  [("Data", ExampleTable, self.setData, Default), ("Data Subset", ExampleTable, self.setSubsetData), ("Features", AttributeList, self.setShownAttributes), ("Evaluation Results", orngTest.ExperimentResults, self.setTestResults), ("VizRank Learner", orange.Learner, self.setVizRankLearner)]
        self.outputs = [("Selected Data", ExampleTable), ("Other Data", ExampleTable)]

        self.graph = OWScatterPlotGraph(self, self.mainArea, "ScatterPlot")
        self.vizrank = OWVizRank(self, self.signalManager, self.graph, orngVizRank.SCATTERPLOT, "ScatterPlot")
        self.optimizationDlg = self.vizrank

        # local variables
        self.showGridlines = 0
        self.autoSendSelection = 1
        self.toolbarSelection = 0
        self.classificationResults = None
        self.outlierValues = None
        self.colorSettings = None
        self.selectedSchemaIndex = 0
        self.graph.sendSelectionOnUpdate = 0
        self.attributeSelectionList = None

        self.data = None
        self.subsetData = None

        #load settings
        self.loadSettings()

        #GUI
        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main")
        self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings", canScroll = True)

        #add a graph widget
        self.mainArea.layout().addWidget(self.graph)
        self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile)

        #x attribute
        self.attrX = ""
        self.attrXCombo = OWGUI.comboBox(self.GeneralTab, self, "attrX", "X-axis Attribute", callback = self.majorUpdateGraph, sendSelectedValue = 1, valueType = str)

        # y attribute
        self.attrY = ""
        self.attrYCombo = OWGUI.comboBox(self.GeneralTab, self, "attrY", "Y-axis Attribute", callback = self.majorUpdateGraph, sendSelectedValue = 1, valueType = str)

        # coloring
        self.attrColor = ""
        box = OWGUI.widgetBox(self.GeneralTab, "Point Color")
        self.attrColorCombo = OWGUI.comboBox(box, self, "attrColor", callback = self.updateGraph, sendSelectedValue=1, valueType = str, emptyString = "(Same color)")

        box = OWGUI.widgetBox(self.GeneralTab, "Additional Point Properties")
        # labelling
        self.attrLabel = ""
        self.attrLabelCombo = OWGUI.comboBox(box, self, "attrLabel", label = "Point label:", callback = self.updateGraph, sendSelectedValue = 1, valueType = str, emptyString = "(No labels)", indent = 10)

        # shaping
        self.attrShape = ""
        self.attrShapeCombo = OWGUI.comboBox(box, self, "attrShape", label = "Point shape:", callback = self.updateGraph, sendSelectedValue=1, valueType = str, emptyString = "(Same shape)", indent = 10)

        # sizing
        self.attrSize = ""
        self.attrSizeCombo = OWGUI.comboBox(box, self, "attrSize", label = "Point size:", callback = self.updateGraph, sendSelectedValue=1, valueType = str, emptyString = "(Same size)", indent = 10)

        self.optimizationButtons = OWGUI.widgetBox(self.GeneralTab, "Optimization dialogs", orientation = "horizontal")
        OWGUI.button(self.optimizationButtons, self, "VizRank", callback = self.vizrank.reshow, tooltip = "Opens VizRank dialog, where you can search for interesting projections with different subsets of attributes", debuggingEnabled = 0)

        # zooming / selection
        self.zoomSelectToolbar = OWToolbars.ZoomSelectToolbar(self, self.GeneralTab, self.graph, self.autoSendSelection)
        self.connect(self.zoomSelectToolbar.buttonSendSelections, SIGNAL("clicked()"), self.sendSelections)

        # ####################################
        # SETTINGS TAB
        # point width
        pointBox = OWGUI.widgetBox(self.SettingsTab, "Point Properties")
        OWGUI.hSlider(pointBox, self, 'graph.pointWidth', label = "Symbol size:   ", minValue=1, maxValue=20, step=1, callback = self.pointSizeChange)
        OWGUI.hSlider(pointBox, self, 'graph.alphaValue', label = "Transparency: ", minValue=0, maxValue=255, step=10, callback = self.alphaChange)

        # #####
        # jittering options
        box2 = OWGUI.widgetBox(self.SettingsTab, "Jittering Options")
        self.jitterSizeCombo = OWGUI.comboBox(box2, self, "graph.jitterSize", label = 'Jittering size (% of size)'+'  ', orientation = "horizontal", callback = self.resetGraphData, items = self.jitterSizeNums, sendSelectedValue = 1, valueType = float)
        OWGUI.checkBox(box2, self, 'graph.jitterContinuous', 'Jitter continuous attributes', callback = self.resetGraphData, tooltip = "Does jittering apply also on continuous attributes?")

        # general graph settings
        box4 = OWGUI.widgetBox(self.SettingsTab, "General Graph Settings")
        OWGUI.checkBox(box4, self, 'graph.showXaxisTitle', 'X axis title', callback = self.graph.setShowXaxisTitle)
        OWGUI.checkBox(box4, self, 'graph.showYLaxisTitle', 'Y axis title', callback = self.graph.setShowYLaxisTitle)
        OWGUI.checkBox(box4, self, 'graph.showAxisScale', 'Show axis scale', callback = self.updateGraph)
        OWGUI.checkBox(box4, self, 'graph.showLegend', 'Show legend', callback = self.updateGraph)
        OWGUI.checkBox(box4, self, 'graph.showFilledSymbols', 'Show filled symbols', callback = self.updateGraph)
        OWGUI.checkBox(box4, self, 'showGridlines', 'Show gridlines', callback = self.setShowGridlines)
        OWGUI.checkBox(box4, self, 'graph.useAntialiasing', 'Use antialiasing', callback = self.updateGraph)

        box5 = OWGUI.widgetBox(box4, orientation = "horizontal")
        OWGUI.checkBox(box5, self, 'graph.showProbabilities', 'Show probabilities'+'  ', callback = self.updateGraph, tooltip = "Show a background image with class probabilities")
        smallWidget = OWGUI.SmallWidgetLabel(box5, pixmap = 1, box = "Advanced settings", tooltip = "Show advanced settings")
        #OWGUI.rubber(box5)

        box6 = OWGUI.widgetBox(smallWidget.widget, orientation = "horizontal")
        box7 = OWGUI.widgetBox(smallWidget.widget, orientation = "horizontal")

        OWGUI.widgetLabel(box6, "Granularity:"+"  ")
        OWGUI.hSlider(box6, self, 'graph.squareGranularity', minValue=1, maxValue=10, step=1, callback = self.updateGraph)

        OWGUI.checkBox(box7, self, 'graph.spaceBetweenCells', 'Show space between cells', callback = self.updateGraph)

        self.colorButtonsBox = OWGUI.widgetBox(self.SettingsTab, "Colors", orientation = "horizontal")
        OWGUI.button(self.colorButtonsBox, self, "Set Colors", self.setColors, tooltip = "Set the canvas background color, grid color and color palette for coloring continuous variables", debuggingEnabled = 0)

        box5 = OWGUI.widgetBox(self.SettingsTab, "Tooltips Settings")
        OWGUI.comboBox(box5, self, "graph.tooltipKind", items = ["Don't Show Tooltips", "Show Visible Attributes", "Show All Attributes"], callback = self.updateGraph)

        box = OWGUI.widgetBox(self.SettingsTab, "Auto Send Selected Data When...")
        OWGUI.checkBox(box, self, 'autoSendSelection', 'Adding/Removing selection areas', callback = self.selectionChanged, tooltip = "Send selected data whenever a selection area is added or removed")
        OWGUI.checkBox(box, self, 'graph.sendSelectionOnUpdate', 'Moving/Resizing selection areas', tooltip = "Send selected data when a user moves or resizes an existing selection area")
        self.graph.autoSendSelectionCallback = self.selectionChanged

        self.GeneralTab.layout().addStretch(100)
        self.SettingsTab.layout().addStretch(100)
        self.icons = self.createAttributeIconDict()

        self.debugSettings = ["attrX", "attrY", "attrColor", "attrLabel", "attrShape", "attrSize"]
        self.wdChildDialogs = [self.vizrank]        # used when running widget debugging

        dlg = self.createColorDialog()
        self.graph.contPalette = dlg.getContinuousPalette("contPalette")
        self.graph.discPalette = dlg.getDiscretePalette("discPalette")
        self.graph.setCanvasBackground(dlg.getColor("Canvas"))
        self.graph.gridCurve.setPen(QPen(dlg.getColor("Grid")))

        self.graph.enableGridXB(self.showGridlines)
        self.graph.enableGridYL(self.showGridlines)

        apply([self.zoomSelectToolbar.actionZooming, self.zoomSelectToolbar.actionRectangleSelection, self.zoomSelectToolbar.actionPolygonSelection][self.toolbarSelection], [])
        #self.SettingsTab.resize(self.SettingsTab.sizeHint())

        self.resize(700, 550)
Ejemplo n.º 22
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, "Calibration Plot", 1)

        # inputs
        self.inputs = [("Evaluation Results", orngTest.ExperimentResults,
                        self.results, Default)]

        #set default settings
        self.CalibrationCurveWidth = 3
        self.ShowDiagonal = TRUE
        self.ShowRugs = TRUE
        #load settings
        self.loadSettings()

        # temp variables
        self.dres = None
        self.targetClass = None
        self.numberOfClasses = 0
        self.graphs = []
        self.classifierColor = None
        self.numberOfClassifiers = 0
        self.classifiers = []
        self.selectedClassifiers = []

        # GUI
        import sip
        sip.delete(self.mainArea.layout())
        self.graphsGridLayoutQGL = QGridLayout(self.mainArea)
        self.mainArea.setLayout(self.graphsGridLayoutQGL)

        ## save each ROC graph in separate file
        self.graph = None
        self.connect(self.graphButton, SIGNAL("clicked()"), self.saveToFile)

        ## general tab
        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.generalTab = OWGUI.createTabPage(self.tabs, "General")
        self.settingsTab = OWGUI.createTabPage(self.tabs, "Settings")

        self.splitQS = QSplitter()
        self.splitQS.setOrientation(Qt.Vertical)

        ## target class
        self.classCombo = OWGUI.comboBox(self.generalTab,
                                         self,
                                         'targetClass',
                                         box='Target class',
                                         items=[],
                                         callback=self.target)
        OWGUI.separator(self.generalTab)

        ## classifiers selection (classifiersQLB)
        self.classifiersQVGB = OWGUI.widgetBox(self.generalTab, "Classifiers")
        self.classifiersQLB = OWGUI.listBox(
            self.classifiersQVGB,
            self,
            "selectedClassifiers",
            selectionMode=QListWidget.MultiSelection,
            callback=self.classifiersSelectionChange)
        self.unselectAllClassifiersQLB = OWGUI.button(
            self.classifiersQVGB,
            self,
            "(Un)select all",
            callback=self.SUAclassifiersQLB)

        ## settings tab
        OWGUI.hSlider(self.settingsTab,
                      self,
                      'CalibrationCurveWidth',
                      box='Calibration Curve Width',
                      minValue=1,
                      maxValue=9,
                      step=1,
                      callback=self.setCalibrationCurveWidth,
                      ticks=1)
        OWGUI.checkBox(self.settingsTab,
                       self,
                       'ShowDiagonal',
                       'Show Diagonal Line',
                       tooltip='',
                       callback=self.setShowDiagonal)
        OWGUI.checkBox(self.settingsTab,
                       self,
                       'ShowRugs',
                       'Show Rugs',
                       tooltip='',
                       callback=self.setShowRugs)
        self.settingsTab.layout().addStretch(100)
Ejemplo n.º 23
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, "ROC Analysis", 1)

        # inputs
        self.inputs = [("Evaluation Results", orngTest.ExperimentResults,
                        self.test_results, Default)]

        # default settings
        self.PointWidth = 7
        self.CurveWidth = 3
        self.ConvexCurveWidth = 1
        self.ShowDiagonal = TRUE
        self.ConvexHullCurveWidth = 3
        self.HullColor = str(QColor(Qt.yellow).name())
        self.AveragingMethodIndex = 0  ##'merge'
        self.ShowConvexHull = TRUE
        self.ShowConvexCurves = FALSE
        self.EnablePerformance = TRUE
        self.DefaultThresholdPoint = TRUE

        #load settings
        self.loadSettings()

        # temp variables
        self.dres = None
        self.classifierColor = None
        self.numberOfClasses = 0
        self.targetClass = None
        self.numberOfClassifiers = 0
        self.numberOfIterations = 0
        self.graphs = []
        self.maxp = 1000
        self.defaultPerfLinePValues = []
        self.classifiers = []
        self.selectedClassifiers = []

        # performance analysis (temporary values
        self.FPcost = 500.0
        self.FNcost = 500.0
        self.pvalue = 50.0  ##0.400

        # list of values (remember for each class)
        self.FPcostList = []
        self.FNcostList = []
        self.pvalueList = []

        self.AveragingMethodNames = ['merge', 'vertical', 'threshold', None]
        self.AveragingMethod = self.AveragingMethodNames[min(
            3, self.AveragingMethodIndex)]

        # GUI
        import sip
        sip.delete(self.mainArea.layout())
        self.graphsGridLayoutQGL = QGridLayout(self.mainArea)
        self.mainArea.setLayout(self.graphsGridLayoutQGL)
        # save each ROC graph in separate file
        self.connect(self.graphButton, SIGNAL("clicked()"), self.saveToFile)

        ## general tab
        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.generalTab = OWGUI.createTabPage(self.tabs, "General")

        ## target class
        self.classCombo = OWGUI.comboBox(self.generalTab,
                                         self,
                                         'targetClass',
                                         box='Target class',
                                         items=[],
                                         callback=self.target)
        #self.classCombo.setMaximumSize(150, 20)

        ## classifiers selection (classifiersQLB)
        self.classifiersQVGB = OWGUI.widgetBox(self.generalTab, "Classifiers")
        self.classifiersQLB = OWGUI.listBox(
            self.classifiersQVGB,
            self,
            "selectedClassifiers",
            selectionMode=QListWidget.MultiSelection,
            callback=self.classifiersSelectionChange)
        self.unselectAllClassifiersQLB = OWGUI.button(
            self.classifiersQVGB,
            self,
            "(Un)select All",
            callback=self.SUAclassifiersQLB)

        # show convex ROC curves and show ROC convex hull
        self.convexCurvesQCB = OWGUI.checkBox(
            self.generalTab,
            self,
            'ShowConvexCurves',
            'Show convex ROC curves',
            tooltip='',
            callback=self.setShowConvexCurves)
        OWGUI.checkBox(self.generalTab,
                       self,
                       'ShowConvexHull',
                       'Show ROC convex hull',
                       tooltip='',
                       callback=self.setShowConvexHull)

        # performance analysis
        self.performanceTab = OWGUI.createTabPage(self.tabs, "Analysis")
        self.performanceTabCosts = OWGUI.widgetBox(self.performanceTab, box=1)
        OWGUI.checkBox(self.performanceTabCosts,
                       self,
                       'EnablePerformance',
                       'Show performance line',
                       tooltip='',
                       callback=self.setShowPerformanceAnalysis)
        OWGUI.checkBox(self.performanceTabCosts,
                       self,
                       'DefaultThresholdPoint',
                       'Default threshold (0.5) point',
                       tooltip='',
                       callback=self.setShowDefaultThresholdPoint)

        ## FP and FN cost ranges
        mincost = 1
        maxcost = 1000
        stepcost = 5
        self.maxpsum = 100
        self.minp = 1
        self.maxp = self.maxpsum - self.minp  ## need it also in self.pvaluesUpdated
        stepp = 1.0

        OWGUI.hSlider(self.performanceTabCosts,
                      self,
                      'FPcost',
                      box='FP Cost',
                      minValue=mincost,
                      maxValue=maxcost,
                      step=stepcost,
                      callback=self.costsChanged,
                      ticks=50)
        OWGUI.hSlider(self.performanceTabCosts,
                      self,
                      'FNcost',
                      box='FN Cost',
                      minValue=mincost,
                      maxValue=maxcost,
                      step=stepcost,
                      callback=self.costsChanged,
                      ticks=50)

        ptc = OWGUI.widgetBox(self.performanceTabCosts,
                              "Prior target class probability [%]")
        OWGUI.hSlider(ptc,
                      self,
                      'pvalue',
                      minValue=self.minp,
                      maxValue=self.maxp,
                      step=stepp,
                      callback=self.pvaluesUpdated,
                      ticks=5,
                      labelFormat="%2.1f")
        OWGUI.button(ptc, self, 'Compute from data',
                     self.setDefaultPValues)  ## reset p values to default

        ## test set selection (testSetsQLB)
        self.testSetsQVGB = OWGUI.widgetBox(self.performanceTab, "Test sets")
        self.testSetsQLB = OWGUI.listBox(
            self.testSetsQVGB,
            self,
            selectionMode=QListWidget.MultiSelection,
            callback=self.testSetsSelectionChange)
        self.unselectAllTestSetsQLB = OWGUI.button(
            self.testSetsQVGB,
            self,
            "(Un)select All",
            callback=self.SUAtestSetsQLB)

        # settings tab
        self.settingsTab = OWGUI.createTabPage(self.tabs, "Settings")
        OWGUI.radioButtonsInBox(
            self.settingsTab,
            self,
            'AveragingMethodIndex',
            ['Merge (expected ROC perf.)', 'Vertical', 'Threshold', 'None'],
            box='Averaging ROC curves',
            callback=self.selectAveragingMethod)
        OWGUI.hSlider(self.settingsTab,
                      self,
                      'PointWidth',
                      box='Point width',
                      minValue=0,
                      maxValue=9,
                      step=1,
                      callback=self.setPointWidth,
                      ticks=1)
        OWGUI.hSlider(self.settingsTab,
                      self,
                      'CurveWidth',
                      box='ROC curve width',
                      minValue=1,
                      maxValue=5,
                      step=1,
                      callback=self.setCurveWidth,
                      ticks=1)
        OWGUI.hSlider(self.settingsTab,
                      self,
                      'ConvexCurveWidth',
                      box='ROC convex curve width',
                      minValue=1,
                      maxValue=5,
                      step=1,
                      callback=self.setConvexCurveWidth,
                      ticks=1)
        OWGUI.hSlider(self.settingsTab,
                      self,
                      'ConvexHullCurveWidth',
                      box='ROC convex hull',
                      minValue=2,
                      maxValue=9,
                      step=1,
                      callback=self.setConvexHullCurveWidth,
                      ticks=1)
        OWGUI.checkBox(self.settingsTab,
                       self,
                       'ShowDiagonal',
                       'Show diagonal ROC line',
                       tooltip='',
                       callback=self.setShowDiagonal)
        self.settingsTab.layout().addStretch(100)

        self.resize(800, 600)
Ejemplo n.º 24
0
    def __init__(self, parent=None, signalManager=None, name='Correspondence Analysis', **kwargs):
        OWWidget.__init__(self, parent, signalManager, name, *kwargs)
        self.callbackDeposit = []

        self.inputs = [("Data", ExampleTable, self.dataset)]
        self.outputs = [("Selected data", ExampleTable)]
        self.recentFiles=[]

        self.data = None
        self.CA = None
        self.CAloaded = False
        self.colors = ColorPaletteHSV(2)

        #Locals
        self.showGridlines = 0
        self.autoSendSelection = 0
        self.toolbarSelection = 0
        self.percRadius = 5


        self.colorSettings = None

        # GUI
        self.tabs = OWGUI.tabWidget(self.controlArea) #QTabWidget(self.controlArea, 'tabWidget')
        self.GeneralTab = OWGUI.createTabPage(self.tabs, "General") #QVGroupBox(self)
        self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings") #QVGroupBox(self)
#        self.tabs.insertTab(self.GeneralTab, "General")
#        self.tabs.insertTab(self.SettingsTab, "Settings")

#        layout = QVBoxLayout(self.mainArea)
        self.tabsMain = OWGUI.tabWidget(self.mainArea) #QTabWidget(self.mainArea, 'tabWidgetMain')

#        layout.addWidget(self.tabsMain)

        # ScatterPlot
        self.graph = OWCorrAnalysisGraph(None, "ScatterPlot")
#        self.tabsMain.insertTab(self.graph, "Scatter Plot")
        OWGUI.createTabPage(self.tabsMain, "Scatter Plot", self.graph)

        self.icons = self.createAttributeIconDict()

        self.textData = False
        if textCorpusModul:
          OWGUI.checkBox(self.GeneralTab, self, 'textData', 'Textual data', callback = self.initAttrValues)

        #col attribute
        self.attrCol = ""
        self.attrColCombo = OWGUI.comboBox(self.GeneralTab, self, "attrCol", " Column table attribute ", callback = self.updateTables, sendSelectedValue = 1, valueType = str)

        # row attribute
        self.attrRow = ""
        self.attrRowCombo = OWGUI.comboBox(self.GeneralTab, self, "attrRow", "Row table attribute ", callback = self.updateTables, sendSelectedValue = 1, valueType = str)

        #x principal axis
        self.attrX = 0
        self.attrXCombo = OWGUI.comboBox(self.GeneralTab, self, "attrX", " Principal axis X ", callback = self.contributionBox, sendSelectedValue = 1, valueType = str)

        #y principal axis
        self.attrY = 0
        self.attrYCombo = OWGUI.comboBox(self.GeneralTab, self, "attrY", " Principal axis Y ", callback = self.contributionBox, sendSelectedValue = 1, valueType = str)

        contribution = OWGUI.widgetBox(self.GeneralTab, 'Contribution to inertia') #QVGroupBox('Contribution to inertia', self.GeneralTab)
        self.firstAxis = OWGUI.widgetLabel(contribution, 'Axis %d: %f%%' % (1, 10))
        self.secondAxis = OWGUI.widgetLabel(contribution, 'Axis %d: %f%%' % (2, 10))

        sliders = OWGUI.widgetBox(self.GeneralTab, 'Percentage of points') #QVGroupBox('Percentage of points', self.GeneralTab)
        OWGUI.widgetLabel(sliders, 'Row points')
        self.percRow = 100
        self.rowSlider = OWGUI.hSlider(sliders, self, 'percRow', minValue=1, maxValue=100, step=10, callback = self.updateGraph)
        OWGUI.widgetLabel(sliders, 'Column points')
        self.percCol = 100
        self.colSlider = OWGUI.hSlider(sliders, self, 'percCol', minValue=1, maxValue=100, step=10, callback = self.updateGraph)


        #zooming
#        self.zoomSelectToolbar = ZoomBrowseSelectToolbar(self, self.GeneralTab, self.graph, self.autoSendSelection)
        self.zoomSelectToolbar = OWToolbars.ZoomSelectToolbar(self, self.GeneralTab, self.graph, self.autoSendSelection)
        
        self.connect(self.zoomSelectToolbar.buttonSendSelections, SIGNAL("clicked()"), self.sendSelections)
#        self.connect(self.graph, SIGNAL('plotMousePressed(const QMouseEvent&)'), self.sendSelections)

        OWGUI.button(self.GeneralTab, self, 'Update Graph', self.buttonUpdate)

        OWGUI.button(self.GeneralTab, self, 'Save graph', self.graph.saveToFile)
        OWGUI.button(self.GeneralTab, self, 'Save CA', self.saveCA)
        OWGUI.button(self.GeneralTab, self, 'Load CA', self.loadCA)
        self.chosenSelection = []
        self.selections = []
        OWGUI.listBox(self.GeneralTab, self, "chosenSelection", "selections", box="Feature selection used", selectionMode = QListWidget.MultiSelection, callback = None)
        # ####################################
        # SETTINGS TAB
        # point width
        OWGUI.hSlider(self.SettingsTab, self, 'graph.pointWidth', box=' Point size ', minValue=1, maxValue=20, step=1, callback = self.replotCurves)
        OWGUI.hSlider(self.SettingsTab, self, 'graph.brushAlpha', box=' Transparancy ', minValue=1, maxValue=255, step=1, callback = self.replotCurves)

        # general graph settings
        box4 = OWGUI.widgetBox(self.SettingsTab, " General graph settings ")
        OWGUI.checkBox(box4, self, 'graph.showXaxisTitle', 'X-axis title', callback = self.updateGraph)
        OWGUI.checkBox(box4, self, 'graph.showYLaxisTitle', 'Y-axis title', callback = self.updateGraph)
##        OWGUI.checkBox(box4, self, 'graph.showAxisScale', 'Show axis scale', callback = self.updateGraph)
        OWGUI.checkBox(box4, self, 'graph.showLegend', 'Show legend', callback = self.updateGraph)
        OWGUI.checkBox(box4, self, 'graph.showFilledSymbols', 'Show filled symbols', callback = self.updateGraph)
        OWGUI.checkBox(box4, self, 'showGridlines', 'Show gridlines', callback = self.setShowGridlines)
##        OWGUI.checkBox(box4, self, 'graph.showClusters', 'Show clusters', callback = self.updateGraph, tooltip = "Show a line boundary around a significant cluster")
        OWGUI.checkBox(box4, self, 'graph.showRowLabels', 'Show row labels', callback = self.updateGraph)
        OWGUI.checkBox(box4, self, 'graph.showColumnLabels', 'Show column labels', callback = self.updateGraph)


        self.colorButtonsBox = OWGUI.widgetBox(self.SettingsTab, " Colors ", orientation = "horizontal")
        OWGUI.button(self.colorButtonsBox, self, "Set Colors", self.setColors, tooltip = "Set the canvas background color, grid color and color palette for coloring continuous variables", debuggingEnabled = 0)

        #browsing radius
        OWGUI.hSlider(self.SettingsTab, self, 'percRadius', box=' Browsing curve size ', minValue = 0, maxValue=100, step=5, callback = self.calcRadius)

        #font size
        OWGUI.hSlider(self.SettingsTab, self, 'graph.labelSize', box=' Set font size for labels ', minValue = 8, maxValue=48, step=1, callback = self.updateGraph)

        OWGUI.hSlider(self.SettingsTab, self, 'graph.maxPoints', box=' Maximum number of points ', minValue = 10, maxValue=40, step=1, callback = None)
        
        OWGUI.rubber(self.SettingsTab)

#        self.resultsTab = QVGroupBox(self, "Results")
#        self.tabsMain.insertTab(self.resultsTab, "Results")
        self.resultsTab = OWGUI.createTabPage(self.tabsMain, "Results", OWGUI.widgetBox(self, "Results", addToLayout=False))
        self.chosenDoc = []
        self.docs = self.graph.docs
        OWGUI.listBox(self.resultsTab, self, "chosenDoc", "docs", box="Documents", callback = None)
        self.chosenFeature = []
        self.features = self.graph.features
        OWGUI.listBox(self.resultsTab, self, "chosenFeature", "features", box="Features", selectionMode = QListWidget.MultiSelection, callback = None)
        OWGUI.button(self.resultsTab, self, "Save selected features", callback = self.saveFeatures)
        OWGUI.button(self.resultsTab, self, "Reconstruct words from letter ngrams", callback = self.reconstruct)
        self.chosenWord = []
        self.words = []
        OWGUI.listBox(self.resultsTab, self, "chosenWord", "words", box="Suggested words", callback = None)

        dlg = self.createColorDialog()
        self.graph.contPalette = dlg.getContinuousPalette("contPalette")
        self.graph.discPalette = dlg.getDiscretePalette("discPalette")
        self.graph.setCanvasBackground(dlg.getColor("Canvas"))
        self.graph.setGridColor(QPen(dlg.getColor("Grid")))

        self.graph.enableGridXB(self.showGridlines)
        self.graph.enableGridYL(self.showGridlines)

#        apply([self.zoomSelectToolbar.actionZooming, self.zoomSelectToolbar.actionRectangleSelection, self.zoomSelectToolbar.actionPolygonSelection, self.zoomSelectToolbar.actionBrowse, self.zoomSelectToolbar.actionBrowseCircle][self.toolbarSelection], [])

        self.resize(700, 800)
Ejemplo n.º 25
0
    def __init__(self,
                 parent=None,
                 signalManager=None,
                 name="Linear Projection",
                 graphClass=None):
        OWVisWidget.__init__(self, parent, signalManager, name, TRUE)

        self.inputs = [("Data", ExampleTable, self.setData, Default),
                       ("Data Subset", ExampleTable, self.setSubsetData),
                       ("Features", AttributeList, self.setShownAttributes),
                       ("Evaluation Results", orngTest.ExperimentResults,
                        self.setTestResults),
                       ("VizRank Learner", orange.Learner,
                        self.setVizRankLearner),
                       ("Distances", orange.SymMatrix, self.setDistances)]
        self.outputs = [("Selected Data", ExampleTable),
                        ("Other Data", ExampleTable),
                        ("Features", AttributeList),
                        ("FreeViz Learner", orange.Learner)]

        # local variables
        self.showAllAttributes = 0
        self.valueScalingType = 0
        self.autoSendSelection = 1
        self.data = None
        self.subsetData = None
        self.distances = None
        self.toolbarSelection = 0
        self.classificationResults = None
        self.outlierValues = None
        self.attributeSelectionList = None
        self.colorSettings = None
        self.selectedSchemaIndex = 0
        self.addProjectedPositions = 0
        self.resetAnchors = 0

        #add a graph widget
        if graphClass:
            self.graph = graphClass(self, self.mainArea, name)
        else:
            self.graph = OWLinProjGraph(self, self.mainArea, name)
        self.mainArea.layout().addWidget(self.graph)

        # graph variables
        self.graph.manualPositioning = 0
        self.graph.hideRadius = 0
        self.graph.showAnchors = 1
        self.graph.jitterContinuous = 0
        self.graph.showProbabilities = 0
        self.graph.useDifferentSymbols = 0
        self.graph.useDifferentColors = 1
        self.graph.tooltipKind = 0
        self.graph.tooltipValue = 0
        self.graph.scaleFactor = 1.0
        self.graph.squareGranularity = 3
        self.graph.spaceBetweenCells = 1
        self.graph.showAxisScale = 0
        self.graph.showValueLines = 0
        self.graph.valueLineLength = 5

        #load settings
        self.loadSettings()

        ##        # cluster dialog
        ##        self.clusterDlg = ClusterOptimization(self, self.signalManager, self.graph, name)
        ##        self.graph.clusterOptimization = self.clusterDlg

        # optimization dialog
        if name.lower() == "radviz":
            self.vizrank = OWVizRank(self, self.signalManager, self.graph,
                                     orngVizRank.RADVIZ, name)
            self.connect(self.graphButton, SIGNAL("clicked()"),
                         self.saveToFile)
        elif name.lower() == "polyviz":
            self.vizrank = OWVizRank(self, self.signalManager, self.graph,
                                     orngVizRank.POLYVIZ, name)
            self.connect(self.graphButton, SIGNAL("clicked()"),
                         self.graph.saveToFile)
        else:
            self.vizrank = OWVizRank(self, self.signalManager, self.graph,
                                     orngVizRank.LINEAR_PROJECTION, name)
            self.connect(self.graphButton, SIGNAL("clicked()"),
                         self.saveToFile)

        self.optimizationDlg = self.vizrank  # for backward compatibility

        self.graph.normalizeExamples = (
            name.lower() == "radviz"
        )  # ignore settings!! if we have radviz then normalize, otherwise not.

        #GUI
        # add a settings dialog and initialize its values

        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main")
        self.SettingsTab = OWGUI.createTabPage(self.tabs,
                                               "Settings",
                                               canScroll=1)

        #add controls to self.controlArea widget
        self.createShowHiddenLists(self.GeneralTab,
                                   callback=self.updateGraphAndAnchors)

        self.optimizationButtons = OWGUI.widgetBox(self.GeneralTab,
                                                   "Optimization Dialogs",
                                                   orientation="horizontal")
        self.vizrankButton = OWGUI.button(
            self.optimizationButtons,
            self,
            "VizRank",
            callback=self.vizrank.reshow,
            tooltip=
            "Opens VizRank dialog, where you can search for interesting projections with different subsets of attributes.",
            debuggingEnabled=0)
        self.wdChildDialogs = [self.vizrank
                               ]  # used when running widget debugging

        # freeviz dialog
        if name.lower() in ["linear projection", "radviz"]:
            self.freeVizDlg = FreeVizOptimization(self, self.signalManager,
                                                  self.graph, name)
            self.wdChildDialogs.append(self.freeVizDlg)
            self.freeVizDlgButton = OWGUI.button(
                self.optimizationButtons,
                self,
                "FreeViz",
                callback=self.freeVizDlg.reshow,
                tooltip=
                "Opens FreeViz dialog, where the position of attribute anchors is optimized so that class separation is improved",
                debuggingEnabled=0)
            if name.lower() == "linear projection":
                self.freeVizLearner = FreeVizLearner(self.freeVizDlg)
                self.send("FreeViz Learner", self.freeVizLearner)

##        self.clusterDetectionDlgButton = OWGUI.button(self.optimizationButtons, self, "Cluster", callback = self.clusterDlg.reshow, debuggingEnabled = 0)
##        self.vizrankButton.setMaximumWidth(63)
##        self.clusterDetectionDlgButton.setMaximumWidth(63)
##        self.freeVizDlgButton.setMaximumWidth(63)
##        self.connect(self.clusterDlg.startOptimizationButton , SIGNAL("clicked()"), self.optimizeClusters)
##        self.connect(self.clusterDlg.resultList, SIGNAL("selectionChanged()"),self.showSelectedCluster)

        self.zoomSelectToolbar = OWToolbars.ZoomSelectToolbar(
            self, self.GeneralTab, self.graph, self.autoSendSelection)
        self.graph.autoSendSelectionCallback = self.selectionChanged
        self.connect(self.zoomSelectToolbar.buttonSendSelections,
                     SIGNAL("clicked()"), self.sendSelections)

        # ####################################
        # SETTINGS TAB
        # #####
        self.extraTopBox = OWGUI.widgetBox(self.SettingsTab,
                                           orientation="vertical")
        self.extraTopBox.hide()

        box = OWGUI.widgetBox(self.SettingsTab, "Point Properties")
        OWGUI.hSlider(box,
                      self,
                      'graph.pointWidth',
                      label="Size: ",
                      minValue=1,
                      maxValue=20,
                      step=1,
                      callback=self.updateGraph)
        OWGUI.hSlider(box,
                      self,
                      'graph.alphaValue',
                      label="Transparency: ",
                      minValue=0,
                      maxValue=255,
                      step=10,
                      callback=self.updateGraph)

        box = OWGUI.widgetBox(self.SettingsTab, "Jittering Options")
        OWGUI.comboBoxWithCaption(box,
                                  self,
                                  "graph.jitterSize",
                                  'Jittering size (% of range):',
                                  callback=self.resetGraphData,
                                  items=self.jitterSizeNums,
                                  sendSelectedValue=1,
                                  valueType=float)
        OWGUI.checkBox(
            box,
            self,
            'graph.jitterContinuous',
            'Jitter continuous attributes',
            callback=self.resetGraphData,
            tooltip="Does jittering apply also on continuous attributes?")

        box = OWGUI.widgetBox(self.SettingsTab, "Scaling Options")
        OWGUI.qwtHSlider(
            box,
            self,
            "graph.scaleFactor",
            label='Inflate points by: ',
            minValue=1.0,
            maxValue=10.0,
            step=0.1,
            callback=self.updateGraph,
            tooltip=
            "If points lie too much together you can expand their position to improve perception",
            maxWidth=90)

        box = OWGUI.widgetBox(self.SettingsTab, "General Graph Settings")
        #OWGUI.checkBox(box, self, 'graph.normalizeExamples', 'Normalize examples', callback = self.updateGraph)
        OWGUI.checkBox(box,
                       self,
                       'graph.showLegend',
                       'Show legend',
                       callback=self.updateGraph)
        bbox = OWGUI.widgetBox(box, orientation="horizontal")
        OWGUI.checkBox(bbox,
                       self,
                       'graph.showValueLines',
                       'Show value lines  ',
                       callback=self.updateGraph)
        OWGUI.qwtHSlider(bbox,
                         self,
                         'graph.valueLineLength',
                         minValue=1,
                         maxValue=10,
                         step=1,
                         callback=self.updateGraph,
                         showValueLabel=0)
        OWGUI.checkBox(
            box,
            self,
            'graph.useDifferentSymbols',
            'Use different symbols',
            callback=self.updateGraph,
            tooltip="Show different class values using different symbols")
        OWGUI.checkBox(
            box,
            self,
            'graph.useDifferentColors',
            'Use different colors',
            callback=self.updateGraph,
            tooltip="Show different class values using different colors")
        OWGUI.checkBox(box,
                       self,
                       'graph.showFilledSymbols',
                       'Show filled symbols',
                       callback=self.updateGraph)
        OWGUI.checkBox(box,
                       self,
                       'graph.useAntialiasing',
                       'Use antialiasing',
                       callback=self.updateGraph)
        wbox = OWGUI.widgetBox(box, orientation="horizontal")
        OWGUI.checkBox(
            wbox,
            self,
            'graph.showProbabilities',
            'Show probabilities' + '  ',
            callback=self.updateGraph,
            tooltip="Show a background image with class probabilities")
        smallWidget = OWGUI.SmallWidgetLabel(wbox,
                                             pixmap=1,
                                             box="Advanced settings",
                                             tooltip="Show advanced settings")
        OWGUI.rubber(wbox)

        box = OWGUI.widgetBox(self.SettingsTab,
                              "Colors",
                              orientation="horizontal")
        OWGUI.button(
            box,
            self,
            "Colors",
            self.setColors,
            tooltip=
            "Set the canvas background color and color palette for coloring variables",
            debuggingEnabled=0)

        box = OWGUI.widgetBox(self.SettingsTab, "Tooltips Settings")
        OWGUI.comboBox(box,
                       self,
                       "graph.tooltipKind",
                       items=[
                           "Show line tooltips", "Show visible attributes",
                           "Show all attributes"
                       ],
                       callback=self.updateGraph)
        OWGUI.comboBox(
            box,
            self,
            "graph.tooltipValue",
            items=["Tooltips show data values", "Tooltips show spring values"],
            callback=self.updateGraph,
            tooltip=
            "Do you wish that tooltips would show you original values of visualized attributes or the 'spring' values (values between 0 and 1). \nSpring values are scaled values that are used for determining the position of shown points. Observing these values will therefore enable you to \nunderstand why the points are placed where they are."
        )

        box = OWGUI.widgetBox(self.SettingsTab,
                              "Auto Send Selected Data When...")
        OWGUI.checkBox(
            box,
            self,
            'autoSendSelection',
            'Adding/Removing selection areas',
            callback=self.selectionChanged,
            tooltip=
            "Send selected data whenever a selection area is added or removed")
        OWGUI.checkBox(
            box,
            self,
            'graph.sendSelectionOnUpdate',
            'Moving/Resizing selection areas',
            tooltip=
            "Send selected data when a user moves or resizes an existing selection area"
        )
        OWGUI.comboBox(box,
                       self,
                       "addProjectedPositions",
                       items=[
                           "Do not modify the domain",
                           "Append projection as attributes",
                           "Append projection as meta attributes"
                       ],
                       callback=self.sendSelections)
        self.selectionChanged()

        box = OWGUI.widgetBox(smallWidget.widget, orientation="horizontal")
        OWGUI.widgetLabel(box, "Granularity:  ")
        OWGUI.hSlider(box,
                      self,
                      'graph.squareGranularity',
                      minValue=1,
                      maxValue=10,
                      step=1,
                      callback=self.updateGraph)

        box = OWGUI.widgetBox(smallWidget.widget, orientation="horizontal")
        OWGUI.checkBox(box,
                       self,
                       'graph.spaceBetweenCells',
                       'Show space between cells',
                       callback=self.updateGraph)

        self.SettingsTab.layout().addStretch(100)

        self.icons = self.createAttributeIconDict()
        self.debugSettings = ["hiddenAttributes", "shownAttributes"]

        dlg = self.createColorDialog()
        self.graph.contPalette = dlg.getContinuousPalette("contPalette")
        self.graph.discPalette = dlg.getDiscretePalette("discPalette")
        self.graph.setCanvasBackground(dlg.getColor("Canvas"))

        apply([
            self.zoomSelectToolbar.actionZooming,
            self.zoomSelectToolbar.actionRectangleSelection,
            self.zoomSelectToolbar.actionPolygonSelection
        ][self.toolbarSelection], [])

        self.cbShowAllAttributes(
        )  # update list boxes based on the check box value

        self.resize(900, 700)
Ejemplo n.º 26
0
    def __init__(self, parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "Time Data Visualizer", TRUE)

        self.inputs =  [("Data", ExampleTable, self.setData, Default), ("Data Subset", ExampleTable, self.setSubsetData), ("Features", AttributeList, self.setShownAttributes)]
        self.outputs = [("Selected Data", ExampleTable), ("Other Data", ExampleTable)]

        # local variables
        self.autoSendSelection = 1
        self.toolbarSelection = 0
        self.colorSettings = None
        self.selectedSchemaIndex = 0

        self.graph = OWTimeDataVisualizerGraph(self, self.mainArea, "Time Data Visualizer")

        self.data = None
        self.subsetData = None

        #load settings
        self.loadSettings()

        #GUI
        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main")
        self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings")

        #add a graph widget
        self.mainArea.layout().addWidget(self.graph)
        self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile)

        #x attribute
        self.attrX = ""
        box = OWGUI.widgetBox(self.GeneralTab, "Time Attribute")
        # add an option to use the index of the example as time stamp
        #OWGUI.checkBox(box, self, 'graph.use', 'X axis title', callback = self.graph.setShowXaxisTitle)
        self.timeCombo = OWGUI.comboBox(box, self, "graph.timeAttr", callback = self.majorUpdateGraph, sendSelectedValue = 1, valueType = str)

        self.colorCombo = OWGUI.comboBox(self.GeneralTab, self, "graph.colorAttr", "Point Color", callback = self.updateGraph, sendSelectedValue = 1, valueType = str)

        # y attributes
        box = OWGUI.widgetBox(self.GeneralTab, "Visualized attributes")
        OWGUI.listBox(box, self, "graph.shownAttributeIndices", "graph.attributes", selectionMode = QListWidget.ExtendedSelection, sizeHint = QSize(150, 250))
        OWGUI.button(box, self, "Update listbox changes", callback = self.majorUpdateGraph)


        # zooming / selection
        self.zoomSelectToolbar = OWToolbars.ZoomSelectToolbar(self, self.GeneralTab, self.graph, self.autoSendSelection)
        self.connect(self.zoomSelectToolbar.buttonSendSelections, SIGNAL("clicked()"), self.sendSelections)

        # ####################################
        # SETTINGS TAB
        # point width
        pointBox = OWGUI.widgetBox(self.SettingsTab, "Point properties")
        OWGUI.hSlider(pointBox, self, 'graph.pointWidth', label = "Symbol size:   ", minValue=1, maxValue=10, step=1, callback = self.pointSizeChange)
        OWGUI.hSlider(pointBox, self, 'graph.alphaValue', label = "Transparency: ", minValue=0, maxValue=255, step=10, callback = self.alphaChange)

        # general graph settings
        box4 = OWGUI.widgetBox(self.SettingsTab, "General graph settings")
        OWGUI.checkBox(box4, self, 'graph.drawLines', 'Draw lines', callback = self.updateGraph)
        OWGUI.checkBox(box4, self, 'graph.drawPoints', 'Draw points (slower)', callback = self.updateGraph)
        OWGUI.checkBox(box4, self, 'graph.trackExamples', 'Track examples', callback = self.updateGraph)
        OWGUI.checkBox(box4, self, 'graph.showGrayRects', 'Show gray rectangles', callback = self.updateGraph)
        OWGUI.checkBox(box4, self, 'graph.showXaxisTitle', 'Show x axis title', callback = self.graph.setShowXaxisTitle)
        OWGUI.checkBox(box4, self, 'graph.showLegend', 'Show legend', callback = self.updateGraph)
        OWGUI.checkBox(box4, self, 'graph.useAntialiasing', 'Use antialiasing', callback = self.antialiasingChange)

        self.colorButtonsBox = OWGUI.widgetBox(self.SettingsTab, "Colors", orientation = "horizontal")
        OWGUI.button(self.colorButtonsBox, self, "Set Colors", self.setColors, tooltip = "Set the canvas background color, grid color and color palette for coloring continuous variables", debuggingEnabled = 0)

        box5 = OWGUI.widgetBox(self.SettingsTab, "Tooltips settings")
        OWGUI.comboBox(box5, self, "graph.tooltipKind", items = ["Don't Show Tooltips", "Show Visible Attributes", "Show All Attributes"], callback = self.updateGraph)

        OWGUI.checkBox(self.SettingsTab, self, 'autoSendSelection', 'Auto send selected data', box = "Data selection", callback = self.setAutoSendSelection, tooltip = "Send signals with selected data whenever the selection changes")
        self.graph.selectionChangedCallback = self.setAutoSendSelection

        OWGUI.rubber(self.GeneralTab)
        OWGUI.rubber(self.SettingsTab)
        self.icons = self.createAttributeIconDict()

        self.activateLoadedSettings()
        self.resize(700, 550)
Ejemplo n.º 27
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, "Time Data Visualizer",
                          TRUE)

        self.inputs = [("Examples", ExampleTable, self.setData, Default),
                       ("Example Subset", ExampleTable, self.setSubsetData),
                       ("Attribute selection", AttributeList,
                        self.setShownAttributes)]
        self.outputs = [("Selected Examples", ExampleTable),
                        ("Unselected Examples", ExampleTable)]

        # local variables
        self.autoSendSelection = 1
        self.toolbarSelection = 0
        self.colorSettings = None
        self.selectedSchemaIndex = 0

        self.graph = OWTimeDataVisualizerGraph(self, self.mainArea,
                                               "Time Data Visualizer")

        self.data = None
        self.subsetData = None

        #load settings
        self.loadSettings()

        #GUI
        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main")
        self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings")

        #add a graph widget
        self.mainArea.layout().addWidget(self.graph)
        self.connect(self.graphButton, SIGNAL("clicked()"),
                     self.graph.saveToFile)

        #x attribute
        self.attrX = ""
        box = OWGUI.widgetBox(self.GeneralTab, "Time Attribute")
        # add an option to use the index of the example as time stamp
        #OWGUI.checkBox(box, self, 'graph.use', 'X axis title', callback = self.graph.setShowXaxisTitle)
        self.timeCombo = OWGUI.comboBox(box,
                                        self,
                                        "graph.timeAttr",
                                        callback=self.majorUpdateGraph,
                                        sendSelectedValue=1,
                                        valueType=str)

        self.colorCombo = OWGUI.comboBox(self.GeneralTab,
                                         self,
                                         "graph.colorAttr",
                                         "Point Color",
                                         callback=self.updateGraph,
                                         sendSelectedValue=1,
                                         valueType=str)

        # y attributes
        box = OWGUI.widgetBox(self.GeneralTab, "Visualized attributes")
        OWGUI.listBox(box,
                      self,
                      "graph.shownAttributeIndices",
                      "graph.attributes",
                      selectionMode=QListWidget.ExtendedSelection,
                      sizeHint=QSize(150, 250))
        OWGUI.button(box,
                     self,
                     "Update listbox changes",
                     callback=self.majorUpdateGraph)

        # zooming / selection
        self.zoomSelectToolbar = OWToolbars.ZoomSelectToolbar(
            self, self.GeneralTab, self.graph, self.autoSendSelection)
        self.connect(self.zoomSelectToolbar.buttonSendSelections,
                     SIGNAL("clicked()"), self.sendSelections)

        # ####################################
        # SETTINGS TAB
        # point width
        pointBox = OWGUI.widgetBox(self.SettingsTab, "Point properties")
        OWGUI.hSlider(pointBox,
                      self,
                      'graph.pointWidth',
                      label="Symbol size:   ",
                      minValue=1,
                      maxValue=10,
                      step=1,
                      callback=self.pointSizeChange)
        OWGUI.hSlider(pointBox,
                      self,
                      'graph.alphaValue',
                      label="Transparency: ",
                      minValue=0,
                      maxValue=255,
                      step=10,
                      callback=self.alphaChange)

        # general graph settings
        box4 = OWGUI.widgetBox(self.SettingsTab, "General graph settings")
        OWGUI.checkBox(box4,
                       self,
                       'graph.drawLines',
                       'Draw lines',
                       callback=self.updateGraph)
        OWGUI.checkBox(box4,
                       self,
                       'graph.drawPoints',
                       'Draw points (slower)',
                       callback=self.updateGraph)
        OWGUI.checkBox(box4,
                       self,
                       'graph.trackExamples',
                       'Track examples',
                       callback=self.updateGraph)
        OWGUI.checkBox(box4,
                       self,
                       'graph.showGrayRects',
                       'Show gray rectangles',
                       callback=self.updateGraph)
        OWGUI.checkBox(box4,
                       self,
                       'graph.showXaxisTitle',
                       'Show x axis title',
                       callback=self.graph.setShowXaxisTitle)
        OWGUI.checkBox(box4,
                       self,
                       'graph.showLegend',
                       'Show legend',
                       callback=self.updateGraph)
        OWGUI.checkBox(box4,
                       self,
                       'graph.useAntialiasing',
                       'Use antialiasing',
                       callback=self.antialiasingChange)

        self.colorButtonsBox = OWGUI.widgetBox(self.SettingsTab,
                                               "Colors",
                                               orientation="horizontal")
        OWGUI.button(
            self.colorButtonsBox,
            self,
            "Set Colors",
            self.setColors,
            tooltip=
            "Set the canvas background color, grid color and color palette for coloring continuous variables",
            debuggingEnabled=0)

        box5 = OWGUI.widgetBox(self.SettingsTab, "Tooltips settings")
        OWGUI.comboBox(box5,
                       self,
                       "graph.tooltipKind",
                       items=[
                           "Don't Show Tooltips", "Show Visible Attributes",
                           "Show All Attributes"
                       ],
                       callback=self.updateGraph)

        OWGUI.checkBox(
            self.SettingsTab,
            self,
            'autoSendSelection',
            'Auto send selected data',
            box="Data selection",
            callback=self.setAutoSendSelection,
            tooltip=
            "Send signals with selected data whenever the selection changes")
        self.graph.selectionChangedCallback = self.setAutoSendSelection

        OWGUI.rubber(self.GeneralTab)
        OWGUI.rubber(self.SettingsTab)
        self.icons = self.createAttributeIconDict()

        self.activateLoadedSettings()
        self.resize(700, 550)
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager,
                          'Hierarchical Clustering', wantGraph=True)

        self.inputs = [("Distances", Orange.misc.SymMatrix, self.set_matrix)]

        self.outputs = [("Selected Data", Orange.data.Table),
                        ("Other Data", Orange.data.Table),
                        ("Centroids", Orange.data.Table)]

        self.linkage = [
            ("Single linkage", hierarchical.HierarchicalClustering.Single),
            ("Average linkage", hierarchical.HierarchicalClustering.Average),
            ("Ward's linkage", hierarchical.HierarchicalClustering.Ward),
            ("Complete linkage", hierarchical.HierarchicalClustering.Complete),
        ]

        self.Linkage = 3
        self.Annotation = 0
        self.PrintDepthCheck = 0
        self.PrintDepth = 10
        # initial horizontal and vertical dendrogram size
        self.HDSize = 500
        self.VDSize = 800
        self.ManualHorSize = 0
        self.AutoResize = 0
        self.TextSize = 8
        self.LineSpacing = 4
        self.SelectionMode = 0
        self.AppendClusters = 0
        self.CommitOnChange = 0
        self.ClassifyName = "HC_class"
        self.addIdAs = 0

        self.loadSettings()

        self.inputMatrix = None
        self.root_cluster = None
        self.selectedExamples = None

        self.selectionChanged = False

        self.linkageMethods = [a[0] for a in self.linkage]

        #################################
        ##GUI
        #################################

        #HC Settings
        OWGUI.comboBox(self.controlArea, self, "Linkage", box="Linkage",
                       items=self.linkageMethods,
                       tooltip="Choose linkage method",
                       callback=self.run_clustering,
                       addSpace=True)
        #Label
        box = OWGUI.widgetBox(self.controlArea, "Annotation", addSpace=True)
        self.labelCombo = OWGUI.comboBox(
            box, self, "Annotation",
            items=["None"],
            tooltip="Choose label attribute",
            callback=self.update_labels
        )

        OWGUI.spin(box, self, "TextSize", label="Text size",
                   min=5, max=15, step=1,
                   callback=self.update_font,
                   controlWidth=40,
                   keyboardTracking=False)

        # Dendrogram graphics settings
        dendrogramBox = OWGUI.widgetBox(self.controlArea, "Limits",
                                        addSpace=True)

        form = QFormLayout()
        form.setLabelAlignment(Qt.AlignLeft)

        # Depth settings
        sw = OWGUI.widgetBox(dendrogramBox, orientation="horizontal",
                             addToLayout=False)
        cw = OWGUI.widgetBox(dendrogramBox, orientation="horizontal",
                             addToLayout=False)

        OWGUI.hSlider(sw, self, "PrintDepth", minValue=1, maxValue=50,
                      callback=self.on_depth_change)

        cblp = OWGUI.checkBox(cw, self, "PrintDepthCheck", "Show to depth",
                              callback=self.on_depth_change,
                              disables=[sw])
        form.addRow(cw, sw)

        checkWidth = OWGUI.checkButtonOffsetHint(cblp)

        # Width settings
        sw = OWGUI.widgetBox(dendrogramBox, orientation="horizontal",
                             addToLayout=False)
        cw = OWGUI.widgetBox(dendrogramBox, orientation="horizontal",
                             addToLayout=False)

        hsb = OWGUI.spin(sw, self, "HDSize", min=200, max=10000, step=10,
                         callback=self.on_width_changed,
                         callbackOnReturn=False,
                         keyboardTracking=False)

        OWGUI.checkBox(cw, self, "ManualHorSize", "Horizontal size",
                       callback=self.on_width_changed,
                       disables=[sw])

        sw.setEnabled(self.ManualHorSize)

        self.hSizeBox = hsb
        form.addRow(cw, sw)
        dendrogramBox.layout().addLayout(form)

        # Selection settings
        box = OWGUI.widgetBox(self.controlArea, "Selection")
        OWGUI.checkBox(box, self, "SelectionMode", "Show cutoff line",
                       callback=self.update_cutoff_line)

        cb = OWGUI.checkBox(box, self, "AppendClusters", "Append cluster IDs",
                            callback=self.commit_data_if)

        self.classificationBox = ib = OWGUI.widgetBox(box, margin=0)

        form = QWidget()
        le = OWGUI.lineEdit(form, self, "ClassifyName", None, callback=None,
                            orientation="horizontal")
        self.connect(le, SIGNAL("editingFinished()"), self.commit_data_if)

        aa = OWGUI.comboBox(form, self, "addIdAs", label=None,
                            orientation="horizontal",
                            items=["Class attribute",
                                   "Attribute",
                                   "Meta attribute"],
                            callback=self.commit_data_if)

        layout = QFormLayout()
        layout.setSpacing(8)
        layout.setContentsMargins(0, 5, 0, 5)
        layout.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow)
        layout.setLabelAlignment(Qt.AlignLeft)
        layout.addRow("Name  ", le)
        layout.addRow("Place  ", aa)

        form.setLayout(layout)

        ib.layout().addWidget(form)
        ib.layout().setContentsMargins(checkWidth, 5, 5, 5)

        cb.disables.append(ib)
        cb.makeConsistent()

        OWGUI.separator(box)
        cbAuto = OWGUI.checkBox(box, self, "CommitOnChange",
                                "Commit on change")
        btCommit = OWGUI.button(box, self, "&Commit", self.commit_data,
                                default=True)
        OWGUI.setStopper(self, btCommit, cbAuto, "selectionChanged",
                         self.commit_data)

        OWGUI.rubber(self.controlArea)
        self.connect(self.graphButton, SIGNAL("clicked()"), self.saveGraph)

        self.scale_scene = scale = ScaleScene(self, self)
        self.headerView = ScaleView(scale, self)
        self.footerView = ScaleView(scale, self)

        self.dendrogram = DendrogramScene(self)
        self.dendrogramView = DendrogramView(self.dendrogram, self.mainArea)

        self.connect(self.dendrogram,
                     SIGNAL("clusterSelectionChanged()"),
                     self.on_selection_change)

        self.connect(self.dendrogram,
                     SIGNAL("sceneRectChanged(QRectF)"),
                     scale.scene_rect_update)

        self.connect(self.dendrogram,
                     SIGNAL("dendrogramGeometryChanged(QRectF)"),
                     self.on_dendrogram_geometry_change)

        self.connect(self.dendrogram,
                     SIGNAL("cutoffValueChanged(float)"),
                     self.on_cuttof_value_changed)

        self.connect(self.dendrogramView,
                     SIGNAL("viewportResized(QSize)"),
                     self.on_width_changed)

        self.connect(self.dendrogramView,
                     SIGNAL("transformChanged(QTransform)"),
                     self.headerView.setTransform)
        self.connect(self.dendrogramView,
                     SIGNAL("transformChanged(QTransform)"),
                     self.footerView.setTransform)

        self.mainArea.layout().addWidget(self.headerView)
        self.mainArea.layout().addWidget(self.dendrogramView)
        self.mainArea.layout().addWidget(self.footerView)

        self.dendrogram.header = self.headerView
        self.dendrogram.footer = self.footerView

        self.connect(self.dendrogramView.horizontalScrollBar(),
                     SIGNAL("valueChanged(int)"),
                     self.footerView.horizontalScrollBar().setValue)

        self.connect(self.dendrogramView.horizontalScrollBar(),
                     SIGNAL("valueChanged(int)"),
                     self.headerView.horizontalScrollBar().setValue)

        self.dendrogram.setSceneRect(0, 0, self.HDSize, self.VDSize)
        self.dendrogram.update()
        self.resize(800, 500)

        self.natural_dendrogram_width = 800
        self.dendrogramView.set_fit_to_width(not self.ManualHorSize)

        self.matrix = None
        self.selectionList = []
        self.selected_clusters = []
Ejemplo n.º 29
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self,
                          parent,
                          signalManager,
                          "Sieve Multigram",
                          wantGraph=True,
                          wantStatusBar=True)

        self.inputs = [("Data", ExampleTable, self.setData),
                       ("Features", AttributeList, self.setShownAttributes)]
        self.outputs = []

        #add a graph widget
        self.graph = OWSieveMultigramGraph(self.mainArea)
        self.graph.useAntialiasing = 1
        self.mainArea.layout().addWidget(self.graph)

        #set default settings
        self.graphCanvasColor = str(QColor(Qt.white).name())
        self.data = None
        self.graph.lineWidth = 3
        self.graph.minPearson = 2
        self.graph.maxPearson = 10
        self.showAllAttributes = 0

        # add a settings dialog and initialize its values
        self.loadSettings()

        #GUI
        # add a settings dialog and initialize its values
        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main")
        self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings")

        #add controls to self.controlArea widget
        self.createShowHiddenLists(self.GeneralTab, callback=self.updateGraph)

        OWGUI.button(self.GeneralTab,
                     self,
                     "Find Interesting Attr.",
                     callback=self.interestingSubsetSelection,
                     debuggingEnabled=0)

        OWGUI.hSlider(self.SettingsTab,
                      self,
                      'graph.lineWidth',
                      box=1,
                      label="Max line width:",
                      minValue=1,
                      maxValue=10,
                      step=1,
                      callback=self.updateGraph)
        residualBox = OWGUI.widgetBox(
            self.SettingsTab, "Attribute independence (Pearson residuals)")
        OWGUI.hSlider(residualBox,
                      self,
                      'graph.maxPearson',
                      label="Max residual:",
                      minValue=4,
                      maxValue=12,
                      step=1,
                      callback=self.updateGraph)
        OWGUI.hSlider(
            residualBox,
            self,
            'graph.minPearson',
            label="Min residual:",
            minValue=0,
            maxValue=4,
            step=1,
            callback=self.updateGraph,
            tooltip=
            "The minimal absolute residual value that will be shown in graph")
        self.SettingsTab.layout().addStretch(100)

        self.connect(self.graphButton, SIGNAL("clicked()"),
                     self.graph.saveToFile)
        self.resize(800, 600)
Ejemplo n.º 30
0
    def __init__(self,parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "Parallel Coordinates (Qt)", TRUE)

        #add a graph widget
        self.graph = OWParallelGraph(self, self.mainArea)
        self.mainArea.layout().addWidget(self.graph)

        self.showAllAttributes = 0

        self.inputs = [("Data", ExampleTable, self.setData, Default), ("Data Subset", ExampleTable, self.setSubsetData), ("Features", AttributeList, self.setShownAttributes)]
        self.outputs = [("Selected Data", ExampleTable), ("Other Data", ExampleTable), ("Features", AttributeList)]

        #set default settings
        self.data = None
        self.subsetData = None
        self.autoSendSelection = 1
        self.attrDiscOrder = "Unordered"
        self.attrContOrder = "Unordered"
        self.projections = None
        self.correlationDict = {}
        self.middleLabels = "Correlations"
        self.attributeSelectionList = None
        self.toolbarSelection = 0
        self.colorSettings = None
        self.selectedSchemaIndex = 0

        self.graph.jitterSize = 10
        self.graph.showDistributions = 1
        self.graph.showStatistics = 0
        self.graph.showAttrValues = 1
        self.graph.useSplines = 0
        self.graph.show_legend = 1

        #load settings
        self.loadSettings()

        #GUI
        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main")
        self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings")

        self.createShowHiddenLists(self.GeneralTab, callback = self.updateGraph)
        self.connect(self.shownAttribsLB, SIGNAL('itemDoubleClicked(QListWidgetItem*)'), self.flipAttribute)

        self.optimizationDlg = ParallelOptimization(self, signalManager = self.signalManager)
        self.optimizationDlgButton = OWGUI.button(self.GeneralTab, self, "Optimization Dialog", callback = self.optimizationDlg.reshow, debuggingEnabled = 0)

        self.zoomSelectToolbar = OWToolbars.ZoomSelectToolbar(self, self.GeneralTab, self.graph, self.autoSendSelection, buttons = (1, 2, 0, 7, 8))
        self.connect(self.zoomSelectToolbar.buttonSendSelections, SIGNAL("clicked()"), self.sendSelections)

        #connect controls to appropriate functions
        self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile)

        # ####################################
        # SETTINGS functionality
        box = OWGUI.widgetBox(self.SettingsTab, "Transparency")
        OWGUI.hSlider(box, self, 'graph.alphaValue', label = "Examples: ", minValue=0, maxValue=255, step=10, callback = self.updateGraph, tooltip = "Alpha value used for drawing example lines")
        OWGUI.hSlider(box, self, 'graph.alphaValue2', label = "Rest:     ", minValue=0, maxValue=255, step=10, callback = self.updateGraph, tooltip = "Alpha value used to draw statistics, example subsets, ...")

        box = OWGUI.widgetBox(self.SettingsTab, "Jittering Options")
        OWGUI.comboBox(box, self, "graph.jitterSize", label = 'Jittering size (% of size):  ', orientation='horizontal', callback = self.setJitteringSize, items = self.jitterSizeNums, sendSelectedValue = 1, valueType = float)

        # visual settings
        box = OWGUI.widgetBox(self.SettingsTab, "Visual Settings")

        OWGUI.checkBox(box, self, 'graph.showAttrValues', 'Show attribute values', callback = self.updateGraph)
        OWGUI.checkBox(box, self, 'graph.useSplines', 'Show splines', callback = self.updateGraph, tooltip  = "Show lines using splines")
        
        self.graph.gui.show_legend_check_box(box)

        box = OWGUI.widgetBox(self.SettingsTab, "Axis Distance")
        resizeColsBox = OWGUI.widgetBox(box, 0, "horizontal", 0)
        OWGUI.label(resizeColsBox, self, "Increase/decrease distance: ")
        b = OWGUI.toolButton(resizeColsBox, self, "+", callback=self.increaseAxesDistance, tooltip = "Increase the distance between the axes", width=30, height = 20)
        b = OWGUI.toolButton(resizeColsBox, self, "-", callback=self.decreaseAxesDistance, tooltip = "Decrease the distance between the axes", width=30, height = 20)
        OWGUI.rubber(resizeColsBox)
        OWGUI.checkBox(box, self, "graph.autoUpdateAxes", "Auto scale X axis", tooltip = "Auto scale X axis to show all visualized attributes", callback = self.updateGraph)

        box = OWGUI.widgetBox(self.SettingsTab, "Statistical Information")
        OWGUI.comboBox(box, self, "graph.showStatistics", label = "Statistics: ", orientation = "horizontal", labelWidth=90, items = ["No statistics", "Means, deviations", "Median, quartiles"], callback = self.updateGraph, sendSelectedValue = 0, valueType = int)
        OWGUI.comboBox(box, self, "middleLabels", label = "Middle labels: ", orientation="horizontal", labelWidth=90, items = ["No labels", "Correlations", "VizRank"], callback = self.updateGraph, tooltip = "The information do you wish to view on top in the middle of coordinate axes", sendSelectedValue = 1, valueType = str)
        OWGUI.checkBox(box, self, 'graph.showDistributions', 'Show distributions', callback = self.updateGraph, tooltip = "Show bars with distribution of class values (only for discrete attributes)")

        box = OWGUI.widgetBox(self.SettingsTab, "Colors", orientation = "horizontal")
        OWGUI.button(box, self, "Set colors", self.setColors, tooltip = "Set the canvas background color and color palette for coloring continuous variables", debuggingEnabled = 0)

        box = OWGUI.widgetBox(self.SettingsTab, "Auto Send Selected Data When...")
        OWGUI.checkBox(box, self, 'autoSendSelection', 'Adding/Removing selection areas', callback = self.selectionChanged, tooltip = "Send selected data whenever a selection area is added or removed")
        OWGUI.checkBox(box, self, 'graph.sendSelectionOnUpdate', 'Moving/Resizing selection areas', tooltip = "Send selected data when a user moves or resizes an existing selection area")
        self.graph.autoSendSelectionCallback = self.selectionChanged

        self.SettingsTab.layout().addStretch(100)
        self.icons = self.createAttributeIconDict()

        dlg = self.createColorDialog()
        self.graph.contPalette = dlg.getContinuousPalette("contPalette")
        self.graph.discPalette = dlg.getDiscretePalette("discPalette")
        self.graph.setCanvasBackground(dlg.getColor("Canvas"))
        apply([self.zoomSelectToolbar.actionZooming, self.zoomSelectToolbar.actionRectangleSelection, self.zoomSelectToolbar.actionPolygonSelection][self.toolbarSelection], [])
        self.cbShowAllAttributes()

        self.resize(900, 700)
Ejemplo n.º 31
0
    def __init__(self, parent=None, signalManager=None):
        #OWWidget.__init__(self, parent, 'Hierarchical Clustering')
        OWWidget.__init__(self, parent, signalManager,
                          'Hierarchical Clustering')
        self.parent = parent
        self.callbackDeposit = []
        self.inputs = [("Distance matrix", orange.SymMatrix, self.dataset)]
        self.outputs = [("Selected Examples", ExampleTable),
                        ("Unselected Examples", ExampleTable),
                        ("Structured Data Files", DataFiles)]
        self.linkage = [
            ("Single linkage", orange.HierarchicalClustering.Single),
            ("Average linkage", orange.HierarchicalClustering.Average),
            ("Ward's linkage", orange.HierarchicalClustering.Ward),
            ("Complete linkage", orange.HierarchicalClustering.Complete),
        ]
        self.Linkage = 0
        self.OverwriteMatrix = 0
        self.Annotation = 0
        self.Brightness = 5
        self.PrintDepthCheck = 0
        self.PrintDepth = 100
        self.HDSize = 500  #initial horizontal and vertical dendrogram size
        self.VDSize = 800
        self.ManualHorSize = 0
        self.AutoResize = 0
        self.TextSize = 8
        self.LineSpacing = 4
        self.SelectionMode = 0
        self.ZeroOffset = 1
        self.DisableHighlights = 0
        self.DisableBubble = 0
        self.ClassifySelected = 0
        self.CommitOnChange = 0
        self.ClassifyName = "HC_class"
        self.loadSettings()
        self.AutoResize = False
        self.inputMatrix = None
        self.matrixSource = "Unknown"
        self.rootCluster = None
        self.selectedExamples = None
        self.ctrlPressed = FALSE
        self.addIdAs = 0
        self.settingsChanged = False

        self.linkageMethods = [a[0] for a in self.linkage]

        #################################
        ##GUI
        #################################

        #Tabs
        ##        self.tabs = OWGUI.tabWidget(self.controlArea)
        ##        self.settingsTab = OWGUI.createTabPage(self.tabs, "Settings")
        ##        self.selectionTab= OWGUI.createTabPage(self.tabs, "Selection")

        #HC Settings
        OWGUI.comboBox(self.controlArea,
                       self,
                       "Linkage",
                       box="Linkage",
                       items=self.linkageMethods,
                       tooltip="Choose linkage method",
                       callback=self.constructTree,
                       addSpace=16)
        #Label
        box = OWGUI.widgetBox(self.controlArea, "Annotation", addSpace=16)
        self.labelCombo = OWGUI.comboBox(box,
                                         self,
                                         "Annotation",
                                         items=["None"],
                                         tooltip="Choose label attribute",
                                         callback=self.updateLabel)

        OWGUI.spin(box,
                   self,
                   "TextSize",
                   label="Text font size",
                   min=5,
                   max=15,
                   step=1,
                   callback=self.applySettings,
                   controlWidth=40)
        OWGUI.spin(box,
                   self,
                   "LineSpacing",
                   label="Line spacing",
                   min=2,
                   max=8,
                   step=1,
                   callback=self.applySettings,
                   controlWidth=40)

        #        OWGUI.checkBox(box, self, "DisableBubble", "Disable bubble info")

        #Dendrogram graphics settings
        dendrogramBox = OWGUI.widgetBox(self.controlArea,
                                        "Dendrogram settings",
                                        addSpace=16)
        #OWGUI.spin(dendrogramBox, self, "Brightness", label="Brigthtness",min=1,max=9,step=1)
        cblp = OWGUI.checkBox(dendrogramBox,
                              self,
                              "PrintDepthCheck",
                              "Limit print depth",
                              callback=self.applySettings)
        ib = OWGUI.indentedBox(dendrogramBox, orientation=0)
        OWGUI.widgetLabel(ib, "Depth" + "  ")
        slpd = OWGUI.hSlider(ib,
                             self,
                             "PrintDepth",
                             minValue=1,
                             maxValue=50,
                             callback=self.applySettings)
        cblp.disables.append(ib)
        cblp.makeConsistent()

        OWGUI.separator(dendrogramBox)
        #OWGUI.spin(dendrogramBox, self, "VDSize", label="Vertical size", min=100,
        #        max=10000, step=10)
        cbhs = OWGUI.checkBox(
            dendrogramBox,
            self,
            "ManualHorSize",
            "Manually set horizontal size",
            callback=[
                lambda: self.hSizeBox.setDisabled(self.ManualHorSize),
                self.applySettings
            ])
        self.hSizeBox = OWGUI.spin(OWGUI.indentedBox(dendrogramBox),
                                   self,
                                   "HDSize",
                                   label="Size" + "  ",
                                   min=200,
                                   max=10000,
                                   step=10,
                                   callback=self.applySettings,
                                   callbackOnReturn=True,
                                   controlWidth=45)
        cbhs.disables.append(self.hSizeBox)
        cbhs.makeConsistent()

        #OWGUI.checkBox(dendrogramBox, self, "ManualHorSize", "Fit horizontal size")
        #OWGUI.checkBox(dendrogramBox, self, "AutoResize", "Auto resize")

        box = OWGUI.widgetBox(self.controlArea, "Selection")
        OWGUI.checkBox(box,
                       self,
                       "SelectionMode",
                       "Show cutoff line",
                       callback=self.updateCutOffLine)
        cb = OWGUI.checkBox(box,
                            self,
                            "ClassifySelected",
                            "Append cluster indices",
                            callback=self.commitDataIf)
        self.classificationBox = ib = OWGUI.indentedBox(box)
        le = OWGUI.lineEdit(ib,
                            self,
                            "ClassifyName",
                            "Name" + "  ",
                            callback=self.commitDataIf,
                            orientation=0,
                            controlWidth=75)
        OWGUI.separator(ib, height=4)
        aa = OWGUI.comboBox(
            ib,
            self,
            "addIdAs",
            label="Place" + "  ",
            orientation=0,
            items=["Class attribute", "Attribute", "Meta attribute"],
            callback=self.commitDataIf)
        cb.disables.append(ib)
        cb.makeConsistent()

        OWGUI.separator(box)
        cbAuto = OWGUI.checkBox(box, self, "CommitOnChange",
                                "Commit on change")
        btCommit = OWGUI.button(box, self, "&Commit", self.commitData)
        OWGUI.setStopper(self, btCommit, cbAuto, "settingsChanged",
                         self.commitData)

        OWGUI.rubber(self.controlArea)
        OWGUI.button(self.controlArea,
                     self,
                     "&Save Graph",
                     self.saveGraph,
                     debuggingEnabled=0)

        scale = QGraphicsScene(self)
        self.headerView = ScaleView(self, scale, self.mainArea)
        self.footerView = ScaleView(self, scale, self.mainArea)
        self.dendrogram = Dendrogram(self)
        self.dendrogramView = DendrogramView(self.dendrogram, self.mainArea)

        self.mainArea.layout().addWidget(self.headerView)
        self.mainArea.layout().addWidget(self.dendrogramView)
        self.mainArea.layout().addWidget(self.footerView)

        self.dendrogram.header = self.headerView
        self.dendrogram.footer = self.footerView

        self.connect(self.dendrogramView.horizontalScrollBar(),
                     SIGNAL("valueChanged(int)"),
                     self.footerView.horizontalScrollBar().setValue)
        self.connect(self.dendrogramView.horizontalScrollBar(),
                     SIGNAL("valueChanged(int)"),
                     self.headerView.horizontalScrollBar().setValue)
        self.dendrogram.setSceneRect(0, 0, self.HDSize, self.VDSize)
        self.dendrogram.update()
        self.resize(800, 500)

        self.matrix = None
Ejemplo n.º 32
0
 def __init__(self, parent=None, signalManager=None, name="Correspondence Analysis"):
     OWWidget.__init__(self, parent, signalManager, name, wantGraph=True)
     
     self.inputs = [("Data", ExampleTable, self.setData)]
     self.outputs = [("Selected Data", ExampleTable), ("Remaining Data", ExampleTable)]
     
     self.colAttr = 0
     self.rowAttr = 1
     self.xPrincipalAxis = 0
     self.yPrincipalAxis = 1
     self.pointSize = 6
     self.alpha = 240
     self.jitter = 0
     self.showGridlines = 0
     self.percCol = 100
     self.percRow = 100
     self.autoSend = 0
     
     self.loadSettings()
     
     # GUI
     self.graph = OWGraph(self)
     self.graph.sendData = self.sendData
     self.mainArea.layout().addWidget(self.graph)
     
     
     self.controlAreaTab = OWGUI.tabWidget(self.controlArea)
     # Graph tab
     self.graphTab = graphTab = OWGUI.createTabPage(self.controlAreaTab, "Graph")
     self.colAttrCB = OWGUI.comboBox(graphTab, self, "colAttr", "Column Attribute", 
                                     tooltip="Column attribute",
                                     callback=self.runCA)
     
     self.rowAttrCB = OWGUI.comboBox(graphTab, self, "rowAttr", "Row Attribute", 
                                     tooltip="Row attribute",
                                     callback=self.runCA)
     
     self.xAxisCB = OWGUI.comboBox(graphTab, self, "xPrincipalAxis", "Principal Axis X",
                                   tooltip="Principal axis X",
                                   callback=self.updateGraph)
     
     self.yAxisCB = OWGUI.comboBox(graphTab, self, "yPrincipalAxis", "Principal Axis Y",
                                   tooltip="Principal axis Y",
                                   callback=self.updateGraph)
     
     box = OWGUI.widgetBox(graphTab, "Contribution to Inertia")
     self.contributionInfo = OWGUI.widgetLabel(box, "NA\nNA")
     
     OWGUI.hSlider(graphTab, self, "percCol", "Percent of Column Points", 1, 100, 1,
                   callback=self.updateGraph,
                   tooltip="The percent of column points with the largest contribution to inertia")
     
     OWGUI.hSlider(graphTab, self, "percRow", "Percent of Row Points", 1, 100, 1,
                   callback=self.updateGraph,
                   tooltip="The percent of row points with the largest contribution to inertia")
     
     self.zoomSelect = ZoomSelectToolbar(self, graphTab, self.graph, self.autoSend)
     OWGUI.rubber(graphTab)
     
     # Settings tab
     self.settingsTab = settingsTab = OWGUI.createTabPage(self.controlAreaTab, "Settings")
     OWGUI.hSlider(settingsTab, self, "pointSize", "Point Size", 3, 20, step=1,
                   callback=self.setPointSize)
     
     OWGUI.hSlider(settingsTab, self, "alpha", "Transparancy", 1, 255, step=1,
                   callback=self.updateAlpha)
     
     OWGUI.hSlider(settingsTab, self, "jitter", "Jitter Points", 0, 20, step=1,
                   callback=self.updateGraph)
     
     box = OWGUI.widgetBox(settingsTab, "General Settings")
     OWGUI.checkBox(box, self, "showGridlines", "Show gridlines",
                    tooltip="Show gridlines in the plot.",
                    callback=self.updateGridlines)
     OWGUI.rubber(settingsTab)
     
     self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile)
     
     self.contingency = None
     self.contColAttr = None
     self.contRowAttr = None
     
     self.resize(800, 600)
Ejemplo n.º 33
0
    def __init__(self,
                 parent=None,
                 signalManager=None,
                 name="Linear Projection (qt)",
                 graphClass=None):
        OWVisWidget.__init__(self, parent, signalManager, name, TRUE)

        self.inputs = [("Data", ExampleTable, self.setData, Default),
                       ("Data Subset", ExampleTable, self.setSubsetData),
                       ("Features", AttributeList, self.setShownAttributes),
                       ("Evaluation Results", orngTest.ExperimentResults,
                        self.setTestResults),
                       ("VizRank Learner", orange.Learner,
                        self.setVizRankLearner),
                       ("Distances", orange.SymMatrix, self.setDistances)]
        self.outputs = [("Selected Data", ExampleTable),
                        ("Other Data", ExampleTable),
                        ("Features", AttributeList),
                        ("FreeViz Learner", orange.Learner)]

        name_lower = name.lower()
        self._name_lower = name_lower

        # local variables
        self.showAllAttributes = 0
        self.valueScalingType = 0
        self.autoSendSelection = 1
        self.data = None
        self.subsetData = None
        self.distances = None
        self.toolbarSelection = 0
        self.classificationResults = None
        self.outlierValues = None
        self.attributeSelectionList = None
        self.colorSettings = None
        self.selectedSchemaIndex = 0
        self.addProjectedPositions = 0
        self.resetAnchors = 0

        #add a graph widget
        if graphClass:
            self.graph = graphClass(self, self.mainArea, name)
        else:
            self.graph = OWLinProjGraph(self, self.mainArea, name)
        self.mainArea.layout().addWidget(self.graph)

        # graph variables
        self.graph.manualPositioning = 0
        self.graph.hideRadius = 0
        self.graph.showAnchors = 1
        self.graph.jitterContinuous = 0
        self.graph.showProbabilities = 0
        self.graph.useDifferentSymbols = 0
        self.graph.useDifferentColors = 1
        self.graph.tooltipKind = 0
        self.graph.tooltipValue = 0
        self.graph.scaleFactor = 1.0
        self.graph.squareGranularity = 3
        self.graph.spaceBetweenCells = 1
        self.graph.showAxisScale = 0
        self.graph.showValueLines = 0
        self.graph.valueLineLength = 5
        self.dark_theme = False

        if "3d" in name_lower:
            self.settingsList.append("graph.use_2d_symbols")
            self.settingsList.append("graph.mouse_sensitivity")
            self.settingsList.append("dark_theme")
            if "sphereviz" in name_lower:
                self.settingsList.append("graph.show_anchor_grid")

        #load settings
        self.loadSettings()

        ##        # cluster dialog
        ##        self.clusterDlg = ClusterOptimization(self, self.signalManager, self.graph, name)
        ##        self.graph.clusterOptimization = self.clusterDlg

        # optimization dialog
        if "radviz" in name_lower:
            self.vizrank = OWVizRank(self, self.signalManager, self.graph,
                                     orngVizRank.RADVIZ, name)
            self.connect(self.graphButton, SIGNAL("clicked()"),
                         self.saveToFile)
        elif "polyviz" in name_lower:
            self.vizrank = OWVizRank(self, self.signalManager, self.graph,
                                     orngVizRank.POLYVIZ, name)
            self.connect(self.graphButton, SIGNAL("clicked()"),
                         self.graph.saveToFile)
        elif "sphereviz" in name_lower:
            self.vizrank = OWVizRank(self, self.signalManager, self.graph,
                                     orngVizRank.SPHEREVIZ3D, name)
            self.connect(self.graphButton, SIGNAL("clicked()"),
                         self.graph.saveToFile)
        elif "3d" in name_lower:
            self.vizrank = OWVizRank(self, self.signalManager, self.graph,
                                     orngVizRank.LINEAR_PROJECTION3D, name)
            self.connect(self.graphButton, SIGNAL("clicked()"),
                         self.graph.saveToFile)
        else:
            self.vizrank = OWVizRank(self, self.signalManager, self.graph,
                                     orngVizRank.LINEAR_PROJECTION, name)
            self.connect(self.graphButton, SIGNAL("clicked()"),
                         self.saveToFile)

        self.optimizationDlg = self.vizrank  # for backward compatibility

        # ignore settings!! if we have radviz then normalize, otherwise not.
        self.graph.normalizeExamples = ("radviz" in name_lower
                                        or "sphereviz" in name_lower)

        #GUI
        # add a settings dialog and initialize its values

        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main")
        self.SettingsTab = OWGUI.createTabPage(self.tabs,
                                               "Settings",
                                               canScroll=1)
        if not "3d" in name_lower:
            self.PerformanceTab = OWGUI.createTabPage(self.tabs, "Performance")

        #add controls to self.controlArea widget
        self.createShowHiddenLists(self.GeneralTab,
                                   callback=self.updateGraphAndAnchors)

        self.optimizationButtons = OWGUI.widgetBox(self.GeneralTab,
                                                   "Optimization Dialogs",
                                                   orientation="horizontal")
        self.vizrankButton = OWGUI.button(
            self.optimizationButtons,
            self,
            "VizRank",
            callback=self.vizrank.reshow,
            tooltip=
            "Opens VizRank dialog, where you can search for interesting projections with different subsets of attributes.",
            debuggingEnabled=0)
        self.wdChildDialogs = [self.vizrank
                               ]  # used when running widget debugging

        # freeviz dialog
        if "radviz" in name_lower or "linear projection" in name_lower or "sphereviz" in name_lower:
            self.freeVizDlg = FreeVizOptimization(self, self.signalManager,
                                                  self.graph, name)
            self.wdChildDialogs.append(self.freeVizDlg)
            self.freeVizDlgButton = OWGUI.button(
                self.optimizationButtons,
                self,
                "FreeViz",
                callback=self.freeVizDlg.reshow,
                tooltip=
                "Opens FreeViz dialog, where the position of attribute anchors is optimized so that class separation is improved",
                debuggingEnabled=0)
            if "linear projection" in name_lower:
                self.freeVizLearner = FreeVizLearner(self.freeVizDlg)
                self.send("FreeViz Learner", self.freeVizLearner)
            if "3d" in name_lower:
                # Patch a method in Freeviz
                get_shown_attribute_list = lambda: [
                    anchor[3] for anchor in self.graph.anchorData
                ]
                self.freeVizDlg.get_shown_attribute_list = get_shown_attribute_list
                self.freeVizDlg.getShownAttributeList = get_shown_attribute_list
                self.freeVizDlg._use_3D = True

##        self.clusterDetectionDlgButton = OWGUI.button(self.optimizationButtons, self, "Cluster", callback = self.clusterDlg.reshow, debuggingEnabled = 0)
##        self.vizrankButton.setMaximumWidth(63)
##        self.clusterDetectionDlgButton.setMaximumWidth(63)
##        self.freeVizDlgButton.setMaximumWidth(63)
##        self.connect(self.clusterDlg.startOptimizationButton , SIGNAL("clicked()"), self.optimizeClusters)
##        self.connect(self.clusterDlg.resultList, SIGNAL("selectionChanged()"),self.showSelectedCluster)

        gui = self.graph.gui

        if "3d" in name_lower:
            toolbar_buttons = [
                gui.StateButtonsBegin,
                (gui.UserButton, 'Rotate', 'state', ROTATING, None,
                 'Dlg_undo'), gui.Select, gui.StateButtonsEnd, gui.Spacing,
                gui.SendSelection, gui.ClearSelection
            ]

            self.zoomSelectToolbar = gui.zoom_select_toolbar(
                self.GeneralTab, buttons=toolbar_buttons)
            self.connect(self.zoomSelectToolbar.buttons[gui.SendSelection],
                         SIGNAL("clicked()"), self.sendSelections)
            self.graph.set_selection_behavior(OWPlot.ReplaceSelection)
        else:
            # zooming / selection
            self.zoomSelectToolbar = gui.zoom_select_toolbar(
                self.GeneralTab,
                buttons=gui.default_zoom_select_buttons +
                [gui.Spacing, gui.ShufflePoints])
            self.connect(self.zoomSelectToolbar.buttons[gui.SendSelection],
                         SIGNAL("clicked()"), self.sendSelections)

        # ####################################
        # SETTINGS TAB
        # #####
        self.extraTopBox = OWGUI.widgetBox(self.SettingsTab,
                                           orientation="vertical")
        self.extraTopBox.hide()

        self.graph.gui.point_properties_box(self.SettingsTab)

        box = OWGUI.widgetBox(self.SettingsTab, "Jittering Options")
        OWGUI.comboBoxWithCaption(box,
                                  self,
                                  "graph.jitterSize",
                                  'Jittering size (% of range):',
                                  callback=self.resetGraphData,
                                  items=self.jitterSizeNums,
                                  sendSelectedValue=1,
                                  valueType=float)
        OWGUI.checkBox(
            box,
            self,
            'graph.jitterContinuous',
            'Jitter continuous attributes',
            callback=self.resetGraphData,
            tooltip="Does jittering apply also on continuous attributes?")

        if not "3d" in name_lower:
            box = OWGUI.widgetBox(self.SettingsTab, "Scaling Options")
            OWGUI.qwtHSlider(
                box,
                self,
                "graph.scaleFactor",
                label='Inflate points by: ',
                minValue=1.0,
                maxValue=10.0,
                step=0.1,
                callback=self.updateGraph,
                tooltip=
                "If points lie too much together you can expand their position to improve perception",
                maxWidth=90)

        box = OWGUI.widgetBox(self.SettingsTab, "General Graph Settings")
        #OWGUI.checkBox(box, self, 'graph.normalizeExamples', 'Normalize examples', callback = self.updateGraph)
        self.graph.gui.show_legend_check_box(box)
        bbox = OWGUI.widgetBox(box, orientation="horizontal")
        if "3d" in name_lower:
            OWGUI.checkBox(bbox,
                           self,
                           'graph.showValueLines',
                           'Show value lines  ',
                           callback=self.graph.update)
            OWGUI.qwtHSlider(bbox,
                             self,
                             'graph.valueLineLength',
                             minValue=1,
                             maxValue=10,
                             step=1,
                             callback=self.graph.update,
                             showValueLabel=0)
        else:
            OWGUI.checkBox(bbox,
                           self,
                           'graph.showValueLines',
                           'Show value lines  ',
                           callback=self.updateGraph)
            OWGUI.qwtHSlider(bbox,
                             self,
                             'graph.valueLineLength',
                             minValue=1,
                             maxValue=10,
                             step=1,
                             callback=self.updateGraph,
                             showValueLabel=0)
        OWGUI.checkBox(
            box,
            self,
            'graph.useDifferentSymbols',
            'Use different symbols',
            callback=self.updateGraph,
            tooltip="Show different class values using different symbols")
        OWGUI.checkBox(
            box,
            self,
            'graph.useDifferentColors',
            'Use different colors',
            callback=self.updateGraph,
            tooltip="Show different class values using different colors")

        if "3d" in name_lower:
            OWGUI.checkBox(box,
                           self,
                           'dark_theme',
                           'Dark theme',
                           callback=self.on_theme_change)
            OWGUI.checkBox(box,
                           self,
                           'graph.use_2d_symbols',
                           '2D symbols',
                           callback=self.updateGraph,
                           tooltip="Use 2D symbols")
            self.on_theme_change()
            if "sphereviz" in name_lower:
                OWGUI.checkBox(box,
                               self,
                               'graph.show_anchor_grid',
                               'Anchor grid',
                               callback=self.on_theme_change)
                box = OWGUI.widgetBox(self.SettingsTab,
                                      'Camery type',
                                      orientation="horizontal")
                c = OWGUI.comboBox(box,
                                   self,
                                   'graph.camera_type',
                                   callback=self.graph.update_camera_type,
                                   sendSelectedValue=0)
                c.addItem('Default')
                c.addItem('Center')
                c.addItem('Random attribute')
                OWGUI.hSlider(box,
                              self,
                              'graph.camera_angle',
                              label='FOV',
                              minValue=45,
                              maxValue=180,
                              step=1,
                              callback=self.graph.update,
                              tooltip='Field of view angle')
            box = OWGUI.widgetBox(self.SettingsTab,
                                  'Mouse',
                                  orientation="horizontal")
            OWGUI.hSlider(box,
                          self,
                          'graph.mouse_sensitivity',
                          label='Sensitivity',
                          minValue=1,
                          maxValue=10,
                          step=1,
                          callback=self.graph.update,
                          tooltip='Change mouse sensitivity')
        else:
            self.graph.gui.filled_symbols_check_box(box)
            wbox = OWGUI.widgetBox(box, orientation="horizontal")
            OWGUI.checkBox(
                wbox,
                self,
                'graph.showProbabilities',
                'Show probabilities' + '  ',
                callback=self.updateGraph,
                tooltip="Show a background image with class probabilities")
            smallWidget = OWGUI.SmallWidgetLabel(
                wbox,
                pixmap=1,
                box="Advanced settings",
                tooltip="Show advanced settings")
            OWGUI.rubber(wbox)

            box = OWGUI.widgetBox(smallWidget.widget, orientation="horizontal")
            OWGUI.widgetLabel(box, "Granularity:  ")
            OWGUI.hSlider(box,
                          self,
                          'graph.squareGranularity',
                          minValue=1,
                          maxValue=10,
                          step=1,
                          callback=self.updateGraph)

            box = OWGUI.widgetBox(smallWidget.widget, orientation="horizontal")
            OWGUI.checkBox(box,
                           self,
                           'graph.spaceBetweenCells',
                           'Show space between cells',
                           callback=self.updateGraph)

        box = OWGUI.widgetBox(self.SettingsTab,
                              "Colors",
                              orientation="horizontal")
        OWGUI.button(
            box,
            self,
            "Colors",
            self.setColors,
            tooltip=
            "Set the canvas background color and color palette for coloring variables",
            debuggingEnabled=0)

        box = OWGUI.widgetBox(self.SettingsTab, "Tooltips Settings")
        callback = self.graph.update if "3d" in name_lower else self.updateGraph
        OWGUI.comboBox(box,
                       self,
                       "graph.tooltipKind",
                       items=[
                           "Show line tooltips", "Show visible attributes",
                           "Show all attributes"
                       ],
                       callback=callback)
        OWGUI.comboBox(
            box,
            self,
            "graph.tooltipValue",
            items=["Tooltips show data values", "Tooltips show spring values"],
            callback=callback,
            tooltip=
            "Do you wish that tooltips would show you original values of visualized attributes or the 'spring' values (values between 0 and 1). \nSpring values are scaled values that are used for determining the position of shown points. Observing these values will therefore enable you to \nunderstand why the points are placed where they are."
        )

        box = OWGUI.widgetBox(self.SettingsTab,
                              "Auto Send Selected Data When...")
        OWGUI.checkBox(
            box,
            self,
            'autoSendSelection',
            'Adding/Removing selection areas',
            callback=self.selectionChanged,
            tooltip=
            "Send selected data whenever a selection area is added or removed")
        OWGUI.checkBox(
            box,
            self,
            'graph.sendSelectionOnUpdate',
            'Moving/Resizing selection areas',
            tooltip=
            "Send selected data when a user moves or resizes an existing selection area"
        )
        OWGUI.comboBox(box,
                       self,
                       "addProjectedPositions",
                       items=[
                           "Do not modify the domain",
                           "Append projection as attributes",
                           "Append projection as meta attributes"
                       ],
                       callback=self.sendSelections)
        self.selectionChanged()

        self.SettingsTab.layout().addStretch(100)

        if not "3d" in name_lower:
            self.graph.gui.effects_box(self.PerformanceTab, )
            self.PerformanceTab.layout().addStretch(100)

        self.icons = self.createAttributeIconDict()
        self.debugSettings = ["hiddenAttributes", "shownAttributes"]

        dlg = self.createColorDialog()
        self.graph.contPalette = dlg.getContinuousPalette("contPalette")
        self.graph.discPalette = dlg.getDiscretePalette("discPalette")

        p = self.graph.palette()
        p.setColor(OWPalette.Canvas, dlg.getColor("Canvas"))
        self.graph.set_palette(p)

        self.cbShowAllAttributes(
        )  # update list boxes based on the check box value

        self.resize(900, 700)
Ejemplo n.º 34
0
    def __init__(self, parent=None, signalManager=None, name='ScatterPlot 3D'):
        OWWidget.__init__(self, parent, signalManager, name, True)

        self.inputs = [('Data', ExampleTable, self.set_data, Default), ('Subset Examples', ExampleTable, self.set_subset_data)]
        self.outputs = [('Selected Data', ExampleTable), ('Other Data', ExampleTable)]

        self.x_attr = ''
        self.y_attr = ''
        self.z_attr = ''

        self.x_attr_discrete = False
        self.y_attr_discrete = False
        self.z_attr_discrete = False

        self.color_attr = ''
        self.size_attr = ''
        self.symbol_attr = ''
        self.label_attr = ''

        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.main_tab = OWGUI.createTabPage(self.tabs, 'Main')
        self.settings_tab = OWGUI.createTabPage(self.tabs, 'Settings', canScroll=True)

        self.x_attr_cb = OWGUI.comboBox(self.main_tab, self, 'x_attr', box='X-axis attribute',
            tooltip='Attribute to plot on X axis.',
            callback=self.on_axis_change,
            sendSelectedValue=1,
            valueType=str)

        self.y_attr_cb = OWGUI.comboBox(self.main_tab, self, 'y_attr', box='Y-axis attribute',
            tooltip='Attribute to plot on Y axis.',
            callback=self.on_axis_change,
            sendSelectedValue=1,
            valueType=str)

        self.z_attr_cb = OWGUI.comboBox(self.main_tab, self, 'z_attr', box='Z-axis attribute',
            tooltip='Attribute to plot on Z axis.',
            callback=self.on_axis_change,
            sendSelectedValue=1,
            valueType=str)

        self.color_attr_cb = OWGUI.comboBox(self.main_tab, self, 'color_attr', box='Point color',
            tooltip='Attribute to use for point color',
            callback=self.on_axis_change,
            sendSelectedValue=1,
            valueType=str)

        # Additional point properties (labels, size, symbol).
        additional_box = OWGUI.widgetBox(self.main_tab, 'Additional Point Properties')
        self.size_attr_cb = OWGUI.comboBox(additional_box, self, 'size_attr', label='Point size:',
            tooltip='Attribute to use for point size',
            callback=self.on_axis_change,
            indent=10,
            emptyString='(Same size)',
            sendSelectedValue=1,
            valueType=str)

        self.symbol_attr_cb = OWGUI.comboBox(additional_box, self, 'symbol_attr', label='Point symbol:',
            tooltip='Attribute to use for point symbol',
            callback=self.on_axis_change,
            indent=10,
            emptyString='(Same symbol)',
            sendSelectedValue=1,
            valueType=str)

        self.label_attr_cb = OWGUI.comboBox(additional_box, self, 'label_attr', label='Point label:',
            tooltip='Attribute to use for pointLabel',
            callback=self.on_axis_change,
            indent=10,
            emptyString='(No labels)',
            sendSelectedValue=1,
            valueType=str)

        self.plot = ScatterPlot(self)
        self.vizrank = OWVizRank(self, self.signalManager, self.plot, orngVizRank.SCATTERPLOT3D, 'ScatterPlot3D')
        self.optimization_dlg = self.vizrank

        self.optimization_buttons = OWGUI.widgetBox(self.main_tab, 'Optimization dialogs', orientation='horizontal')
        OWGUI.button(self.optimization_buttons, self, 'VizRank', callback=self.vizrank.reshow,
            tooltip='Opens VizRank dialog, where you can search for interesting projections with different subsets of attributes',
            debuggingEnabled=0)

        box = OWGUI.widgetBox(self.settings_tab, 'Point properties')
        OWGUI.hSlider(box, self, 'plot.symbol_scale', label='Symbol scale',
            minValue=1, maxValue=20,
            tooltip='Scale symbol size',
            callback=self.on_checkbox_update)

        OWGUI.hSlider(box, self, 'plot.alpha_value', label='Transparency',
            minValue=10, maxValue=255,
            tooltip='Point transparency value',
            callback=self.on_checkbox_update)
        OWGUI.rubber(box)

        box = OWGUI.widgetBox(self.settings_tab, 'Jittering Options')
        self.jitter_size_combo = OWGUI.comboBox(box, self, 'plot.jitter_size', label='Jittering size (% of size)'+'  ',
            orientation='horizontal',
            callback=self.handleNewSignals,
            items=self.jitter_sizes,
            sendSelectedValue=1,
            valueType=float)
        OWGUI.checkBox(box, self, 'plot.jitter_continuous', 'Jitter continuous attributes',
            callback=self.handleNewSignals,
            tooltip='Does jittering apply also on continuous attributes?')

        self.dark_theme = False

        box = OWGUI.widgetBox(self.settings_tab, 'General settings')
        OWGUI.checkBox(box, self, 'plot.show_x_axis_title',   'X axis title',   callback=self.on_checkbox_update)
        OWGUI.checkBox(box, self, 'plot.show_y_axis_title',   'Y axis title',   callback=self.on_checkbox_update)
        OWGUI.checkBox(box, self, 'plot.show_z_axis_title',   'Z axis title',   callback=self.on_checkbox_update)
        OWGUI.checkBox(box, self, 'plot.show_legend',         'Show legend',    callback=self.on_checkbox_update)
        OWGUI.checkBox(box, self, 'plot.use_2d_symbols',      '2D symbols',     callback=self.update_plot)
        OWGUI.checkBox(box, self, 'dark_theme',               'Dark theme',     callback=self.on_theme_change)
        OWGUI.checkBox(box, self, 'plot.show_grid',           'Show grid',      callback=self.on_checkbox_update)
        OWGUI.checkBox(box, self, 'plot.show_axes',           'Show axes',      callback=self.on_checkbox_update)
        OWGUI.checkBox(box, self, 'plot.show_chassis',        'Show chassis',   callback=self.on_checkbox_update)
        OWGUI.checkBox(box, self, 'plot.hide_outside',        'Hide outside',   callback=self.on_checkbox_update)
        OWGUI.rubber(box)

        box = OWGUI.widgetBox(self.settings_tab, 'Mouse', orientation = "horizontal")
        OWGUI.hSlider(box, self, 'plot.mouse_sensitivity', label='Sensitivity', minValue=1, maxValue=10,
                      step=1,
                      callback=self.plot.update,
                      tooltip='Change mouse sensitivity')

        gui = self.plot.gui
        buttons = gui.default_zoom_select_buttons
        buttons.insert(2, (gui.UserButton, 'Rotate', 'state', ROTATING, None, 'Dlg_undo'))
        self.zoom_select_toolbar = gui.zoom_select_toolbar(self.main_tab, buttons=buttons)
        self.connect(self.zoom_select_toolbar.buttons[gui.SendSelection], SIGNAL("clicked()"), self.send_selection)
        self.connect(self.zoom_select_toolbar.buttons[gui.Zoom], SIGNAL("clicked()"), self.plot.unselect_all_points)
        self.plot.set_selection_behavior(OWPlot.ReplaceSelection)

        self.tooltip_kind = TooltipKind.NONE
        box = OWGUI.widgetBox(self.settings_tab, 'Tooltips Settings')
        OWGUI.comboBox(box, self, 'tooltip_kind', items = [
            'Don\'t Show Tooltips', 'Show Visible Attributes', 'Show All Attributes'])

        self.plot.mouseover_callback = self.mouseover_callback

        self.main_tab.layout().addStretch(100)
        self.settings_tab.layout().addStretch(100)

        self.mainArea.layout().addWidget(self.plot)
        self.connect(self.graphButton, SIGNAL('clicked()'), self.plot.save_to_file)

        self.loadSettings()
        self.plot.update_camera()
        self.on_theme_change()

        self.data = None
        self.subset_data = None
        self.resize(1100, 600)
Ejemplo n.º 35
0
    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, name='Classification Tree Viewer'):
        OWWidget.__init__(self, parent, signalManager, name)

        self.dataLabels = (('Majority class', 'Class'), 
                  ('Probability of majority class', 'P(Class)'), 
                  ('Probability of target class', 'P(Target)'), 
                  ('Number of instances', '# Inst'), 
                  ('Relative distribution', 'Distribution (rel)'), 
                  ('Absolute distribution', 'Distribution (abs)'))

#        self.callbackDeposit = []

        self.inputs = [("Classification Tree", orange.TreeClassifier, self.setClassificationTree)]
        self.outputs = [("Data", ExampleTable)]

        # Settings
        for s in self.settingsList[:6]:
            setattr(self, s, 1)
        self.expslider = 5
        self.targetClass = 0
        self.loadSettings()

        self.tree = None
        self.sliderValue = 5
        self.precision = 3
        self.precFrmt = "%%2.%if" % self.precision

        # GUI
        # parameters

        self.dBox = OWGUI.widgetBox(self.controlArea, 'Displayed information')
        for i in range(len(self.dataLabels)):
            checkColumn(self.dBox, self, self.dataLabels[i][0], self.settingsList[i])

        OWGUI.separator(self.controlArea)
                
        self.slider = OWGUI.hSlider(self.controlArea, self, "sliderValue", box = 'Expand/shrink to level', minValue = 1, maxValue = 9, step = 1, callback = self.sliderChanged)

        OWGUI.separator(self.controlArea)
        self.targetCombo=OWGUI.comboBox(self.controlArea, self, "targetClass", items=[], box="Target class", callback=self.setTarget, addSpace=True)

        self.infBox = OWGUI.widgetBox(self.controlArea, 'Tree size')
        self.infoa = OWGUI.widgetLabel(self.infBox, 'No tree.')
        self.infob = OWGUI.widgetLabel(self.infBox, ' ')

        OWGUI.rubber(self.controlArea)

        # list view
        self.splitter = QSplitter(Qt.Vertical, self.mainArea)
        self.mainArea.layout().addWidget(self.splitter)

        self.v = QTreeWidget(self.splitter)
        self.splitter.addWidget(self.v)
        self.v.setAllColumnsShowFocus(1)
        self.v.setHeaderLabels(['Classification Tree'] + [label[1] for label in self.dataLabels])
        self.v.setColumnWidth(0, 250)
        self.connect(self.v, SIGNAL("itemSelectionChanged()"), self.viewSelectionChanged)

        # rule
        self.rule = QTextEdit(self.splitter)
        self.splitter.addWidget(self.rule)
        self.rule.setReadOnly(1)
        self.splitter.setStretchFactor(0, 2)
        self.splitter.setStretchFactor(1, 1)

        self.resize(800,400)

        self.resize(830, 400)
Ejemplo n.º 37
0
    def __init__(self, parent=None, signalManager=None, name='TreeViewer2D'):
        OWWidget.__init__(self, parent, signalManager, name, wantGraph=True)
        self.root = None
        self.selectedNode = None

        self.inputs = [("Classification Tree",
                        Orange.classification.tree.TreeClassifier, self.ctree)]
        self.outputs = [("Examples", ExampleTable)]

        #set default settings
        self.ZoomAutoRefresh = 0
        self.AutoArrange = 0
        self.ToolTipsEnabled = 1
        self.MaxTreeDepth = 5
        self.MaxTreeDepthB = 0
        self.LineWidth = 5
        self.LineWidthMethod = 2
        self.NodeSize = 5
        self.MaxNodeWidth = 150
        self.LimitNodeWidth = True
        self.NodeInfo = [0, 1]

        self.Zoom = 5
        self.VSpacing = 5
        self.HSpacing = 5
        self.TruncateText = 1

        self.loadSettings()
        self.NodeInfo.sort()

        # Changed when the GUI was simplified - added here to override any saved settings
        self.VSpacing = 1
        self.HSpacing = 1
        self.ToolTipsEnabled = 1
        self.LineWidth = 15  # Also reset when the LineWidthMethod is changed!

        # GUI definition
        #        self.tabs = OWGUI.tabWidget(self.controlArea)

        # GENERAL TAB
        # GeneralTab = OWGUI.createTabPage(self.tabs, "General")
        #        GeneralTab = TreeTab = OWGUI.createTabPage(self.tabs, "Tree")
        #        NodeTab = OWGUI.createTabPage(self.tabs, "Node")

        GeneralTab = NodeTab = TreeTab = self.controlArea

        self.infBox = OWGUI.widgetBox(GeneralTab,
                                      'Info',
                                      sizePolicy=QSizePolicy(
                                          QSizePolicy.Minimum,
                                          QSizePolicy.Fixed),
                                      addSpace=True)
        self.infoa = OWGUI.widgetLabel(self.infBox, 'No tree.')
        self.infob = OWGUI.widgetLabel(self.infBox, " ")

        self.sizebox = OWGUI.widgetBox(GeneralTab, "Size", addSpace=True)
        OWGUI.hSlider(self.sizebox,
                      self,
                      'Zoom',
                      label='Zoom',
                      minValue=1,
                      maxValue=10,
                      step=1,
                      callback=self.toggleZoomSlider,
                      ticks=1)
        OWGUI.separator(self.sizebox)

        cb, sb = OWGUI.checkWithSpin(self.sizebox,
                                     self,
                                     "Max node width:",
                                     50,
                                     200,
                                     "LimitNodeWidth",
                                     "MaxNodeWidth",
                                     tooltip="Limit the width of tree nodes",
                                     checkCallback=self.toggleNodeSize,
                                     spinCallback=self.toggleNodeSize,
                                     step=10)
        b = OWGUI.checkBox(OWGUI.indentedBox(
            self.sizebox, sep=OWGUI.checkButtonOffsetHint(cb)),
                           self,
                           "TruncateText",
                           "Truncate text",
                           callback=self.toggleTruncateText)
        cb.disables.append(b)
        cb.makeConsistent()

        OWGUI.checkWithSpin(self.sizebox,
                            self,
                            'Max tree depth:',
                            1,
                            20,
                            'MaxTreeDepthB',
                            "MaxTreeDepth",
                            tooltip='Defines the depth of the tree displayed',
                            checkCallback=self.toggleTreeDepth,
                            spinCallback=self.toggleTreeDepth)

        self.edgebox = OWGUI.widgetBox(GeneralTab,
                                       "Edge Widths",
                                       addSpace=True)
        OWGUI.comboBox(self.edgebox,
                       self,
                       'LineWidthMethod',
                       items=['Equal width', 'Root node', 'Parent node'],
                       callback=self.toggleLineWidth)
        # Node information
        grid = QGridLayout()
        grid.setContentsMargins(
            *self.controlArea.layout().getContentsMargins())

        navButton = OWGUI.button(self.controlArea,
                                 self,
                                 "Navigator",
                                 self.toggleNavigator,
                                 debuggingEnabled=0,
                                 addToLayout=False)
        #        findbox = OWGUI.widgetBox(self.controlArea, orientation = "horizontal")
        self.centerRootButton=OWGUI.button(self.controlArea, self, "Find Root", addToLayout=False,
                                           callback=lambda :self.rootNode and \
                                           self.sceneView.centerOn(self.rootNode.x(), self.rootNode.y()))
        self.centerNodeButton=OWGUI.button(self.controlArea, self, "Find Selected", addToLayout=False,
                                           callback=lambda :self.selectedNode and \
                                           self.sceneView.centerOn(self.selectedNode.scenePos()))
        grid.addWidget(navButton, 0, 0, 1, 2)
        grid.addWidget(self.centerRootButton, 1, 0)
        grid.addWidget(self.centerNodeButton, 1, 1)
        self.leftWidgetPart.layout().insertLayout(1, grid)

        self.NodeTab = NodeTab
        self.TreeTab = TreeTab
        self.GeneralTab = GeneralTab
        #        OWGUI.rubber(NodeTab)
        self.rootNode = None
        self.tree = None
        self.resize(800, 500)

        self.connect(self.graphButton, SIGNAL("clicked()"), self.saveGraph)
Ejemplo n.º 38
0
 def __init__(self, parent=None, signalManager=None, name="Image viewer"):
     OWWidget.__init__(self, parent, signalManager, name, wantGraph=True)
     
     self.inputs = [("Data", ExampleTable, self.setData)]
     self.outputs = [("Data", ExampleTable)]
     
     self.imageAttr = 0
     self.titleAttr = 0
     self.zoom = 25
     self.autoCommit = False
     self.selectionChangedFlag = False
     
     # ###
     # GUI
     # ###
     
     self.loadSettings()
     
     self.imageAttrCB = OWGUI.comboBox(self.controlArea, self, "imageAttr",
                                       box="Image Filename Attribute",
                                       tooltip="Attribute with image filenames",
                                       callback=self.setupScene,
                                       addSpace=True
                                       )
     
     self.titleAttrCB = OWGUI.comboBox(self.controlArea, self, "titleAttr",
                                       box="Title Attribute",
                                       tooltip="Attribute with image title",
                                       callback=self.updateTitles,
                                       addSpace=True
                                       )
     
     OWGUI.hSlider(self.controlArea, self, "zoom",
                   box="Zoom", minValue=1, maxValue=100, step=1,
                   callback=self.updateZoom,
                   createLabel=False
                   )
     
     OWGUI.separator(self.controlArea)
     
     box = OWGUI.widgetBox(self.controlArea, "Selection")
     b = OWGUI.button(box, self, "Commit", callback=self.commit)
     cb = OWGUI.checkBox(box, self, "autoCommit", "Commit on any change",
                         tooltip="Send selections on any change",
                         callback=self.commitIf
                         )
     OWGUI.setStopper(self, b, cb, "selectionChangedFlag", callback=self.commit)
     
     OWGUI.rubber(self.controlArea)
     
     self.scene = GraphicsScene()
     self.sceneView = QGraphicsView(self.scene, self)
     self.sceneView.setAlignment(Qt.AlignTop | Qt.AlignLeft)
     self.sceneView.setRenderHint(QPainter.Antialiasing, True)
     self.sceneView.setRenderHint(QPainter.TextAntialiasing, True)
     self.sceneView.setFocusPolicy(Qt.WheelFocus)
     self.mainArea.layout().addWidget(self.sceneView)
     
     self.connect(self.scene, SIGNAL("selectionChanged()"), self.onSelectionChanged)
     self.connect(self.scene, SIGNAL("selectionRectPointChanged(QPointF)"), self.onSelectionRectPointChanged, Qt.QueuedConnection)
     self.connect(self.graphButton, SIGNAL("clicked()"), self.saveScene)
     self.resize(800, 600)
     
     self.sceneLayout = None
     self.selectedExamples = []
     self.hasTypeImageHint = False
     
     self.updateZoom()
Ejemplo n.º 39
0
    def __init__(self, parent=None, signalManager = None, name='TreeViewer2D'):
        OWWidget.__init__(self, parent, signalManager, name, wantGraph=True)
        self.root = None
        self.selectedNode = None

        self.inputs = [("Classification Tree", orange.TreeClassifier, self.ctree)]
        self.outputs = [("Examples", ExampleTable)]

        #set default settings
        self.ZoomAutoRefresh = 0
        self.AutoArrange = 0
        self.ToolTipsEnabled = 1
        self.MaxTreeDepth = 5; self.MaxTreeDepthB = 0
        self.LineWidth = 5; self.LineWidthMethod = 2
        self.NodeSize = 5
        self.MaxNodeWidth = 150
        self.LimitNodeWidth = True
        self.NodeInfo = [0, 1]

        self.Zoom = 5
        self.VSpacing = 5; self.HSpacing = 5
        self.TruncateText = 1
        
        self.loadSettings()
        self.NodeInfo.sort()

# Changed when the GUI was simplified - added here to override any saved settings
        self.VSpacing = 1; self.HSpacing = 1
        self.ToolTipsEnabled = 1
        self.LineWidth = 15  # Also reset when the LineWidthMethod is changed!
        
        # GUI definition
#        self.tabs = OWGUI.tabWidget(self.controlArea)

        # GENERAL TAB
        # GeneralTab = OWGUI.createTabPage(self.tabs, "General")
#        GeneralTab = TreeTab = OWGUI.createTabPage(self.tabs, "Tree")
#        NodeTab = OWGUI.createTabPage(self.tabs, "Node")

        GeneralTab = NodeTab = TreeTab = self.controlArea
        
        self.infBox = OWGUI.widgetBox(GeneralTab, 'Info', sizePolicy = QSizePolicy(QSizePolicy.Minimum , QSizePolicy.Fixed ), addSpace=True)
        self.infoa = OWGUI.widgetLabel(self.infBox, 'No tree.')
        self.infob = OWGUI.widgetLabel(self.infBox, " ")

        self.sizebox = OWGUI.widgetBox(GeneralTab, "Size", addSpace=True)
        OWGUI.hSlider(self.sizebox, self, 'Zoom', label='Zoom', minValue=1, maxValue=10, step=1,
                      callback=self.toggleZoomSlider, ticks=1)
        OWGUI.separator(self.sizebox)
        
        cb, sb = OWGUI.checkWithSpin(self.sizebox, self, "Max node width:", 50, 200, "LimitNodeWidth", "MaxNodeWidth",
                                     tooltip="Limit the width of tree nodes",
                                     checkCallback=self.toggleNodeSize,
                                     spinCallback=self.toggleNodeSize,
                                     step=10)
        b = OWGUI.checkBox(OWGUI.indentedBox(self.sizebox, sep=OWGUI.checkButtonOffsetHint(cb)), self, "TruncateText", "Truncate text", callback=self.toggleTruncateText)
        cb.disables.append(b)
        cb.makeConsistent() 

        OWGUI.checkWithSpin(self.sizebox, self, 'Max tree depth:', 1, 20, 'MaxTreeDepthB', "MaxTreeDepth",
                            tooltip='Defines the depth of the tree displayed',
                            checkCallback=self.toggleTreeDepth,
                            spinCallback=self.toggleTreeDepth)
        
        
        self.edgebox = OWGUI.widgetBox(GeneralTab, "Edge Widths", addSpace=True)
        OWGUI.comboBox(self.edgebox, self,  'LineWidthMethod',
                                items=['Equal width', 'Root node', 'Parent node'],
                                callback=self.toggleLineWidth)
        # Node information
        grid = QGridLayout()
        grid.setContentsMargins(*self.controlArea.layout().getContentsMargins())
        
        navButton = OWGUI.button(self.controlArea, self, "Navigator", self.toggleNavigator, debuggingEnabled = 0, addToLayout=False)
#        findbox = OWGUI.widgetBox(self.controlArea, orientation = "horizontal")
        self.centerRootButton=OWGUI.button(self.controlArea, self, "Find Root", addToLayout=False,
                                           callback=lambda :self.rootNode and \
                                           self.sceneView.centerOn(self.rootNode.x(), self.rootNode.y()))
        self.centerNodeButton=OWGUI.button(self.controlArea, self, "Find Selected", addToLayout=False,
                                           callback=lambda :self.selectedNode and \
                                           self.sceneView.centerOn(self.selectedNode.scenePos()))
        grid.addWidget(navButton, 0, 0, 1, 2)
        grid.addWidget(self.centerRootButton, 1, 0)
        grid.addWidget(self.centerNodeButton, 1, 1)
        self.leftWidgetPart.layout().insertLayout(1, grid)
        
        self.NodeTab=NodeTab
        self.TreeTab=TreeTab
        self.GeneralTab=GeneralTab
#        OWGUI.rubber(NodeTab)
        self.rootNode=None
        self.tree=None
        self.resize(800, 500)
        
        self.connect(self.graphButton, SIGNAL("clicked()"), self.saveGraph)
Ejemplo n.º 40
0
    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()
Ejemplo n.º 41
0
    def __init__(self,
                 parent=None,
                 signalManager=None,
                 name="Multi Dimensional Scaling"):
        OWWidget.__init__(self, parent, signalManager, name, wantGraph=True)

        self.inputs = [("Distances", orange.SymMatrix, self.cmatrix),
                       ("Data Subset", ExampleTable, self.cselected)]
        self.outputs = [("Data", ExampleTable)]

        self.StressFunc = 3
        self.minStressDelta = 5e-5
        self.maxIterations = 5000
        self.maxImprovment = 10
        self.autoSendSelection = 0
        self.toolbarSelection = 0
        self.selectionOptions = 0
        self.computeStress = 1
        self.ReDraw = 1
        self.NumIter = 1
        self.RefreshMode = 0
        self.applyLSMT = 0

        self.stressFunc = [("Kruskal stress", orngMDS.KruskalStress),
                           ("Sammon stress", orngMDS.SammonStress),
                           ("Signed Sammon stress", orngMDS.SgnSammonStress),
                           ("Signed relative stress", orngMDS.SgnRelStress)]

        self.graph = MDSGraph(self.mainArea)
        self.mainArea.layout().addWidget(self.graph)

        self.loadSettings()

        tabs = OWGUI.tabWidget(self.controlArea)

        mds = OWGUI.createTabPage(tabs, "MDS")
        graph = OWGUI.createTabPage(tabs, "Graph")

        # MDS Tab
        init = OWGUI.widgetBox(mds, "Initialization")
        OWGUI.button(init, self, "Randomize", self.randomize)
        OWGUI.button(init, self, "Jitter", self.jitter)
        OWGUI.button(init, self, "Torgerson", self.torgerson)

        opt = OWGUI.widgetBox(mds, "Optimization")

        self.startButton = OWGUI.button(opt, self, "Optimize", self.testStart)
        OWGUI.button(opt, self, "Single Step", self.smacofStep)
        box = OWGUI.widgetBox(opt, "Stress Function")
        OWGUI.comboBox(box,
                       self,
                       "StressFunc",
                       items=[a[0] for a in self.stressFunc],
                       callback=self.updateStress)

        OWGUI.radioButtonsInBox(
            opt, self, "RefreshMode",
            ["Every step", "Every 10 steps", "Every 100 steps"],
            "Refresh During Optimization")

        self.stopping = OWGUI.widgetBox(opt, "Stopping Conditions")

        OWGUI.hSlider(OWGUI.widgetBox(self.stopping,
                                      "Min. stress change",
                                      flat=True),
                      self,
                      "minStressDelta",
                      minValue=5e-5,
                      maxValue=1e-2,
                      step=5e-5,
                      labelFormat="%.5f",
                      intOnly=0)

        OWGUI.hSlider(OWGUI.widgetBox(self.stopping,
                                      "Max. number of steps",
                                      flat=True),
                      self,
                      "maxIterations",
                      minValue=10,
                      maxValue=5000,
                      step=10,
                      labelFormat="%i")

        # Graph Tab
        OWGUI.hSlider(graph,
                      self,
                      "graph.PointSize",
                      box="Point Size",
                      minValue=1,
                      maxValue=20,
                      callback=self.graph.updateData)

        self.colorCombo = OWGUI.comboBox(graph,
                                         self,
                                         "graph.ColorAttr",
                                         box="Color",
                                         callback=self.graph.updateData)
        self.sizeCombo = OWGUI.comboBox(graph,
                                        self,
                                        "graph.SizeAttr",
                                        box="Size",
                                        callback=self.graph.updateData)
        self.shapeCombo = OWGUI.comboBox(graph,
                                         self,
                                         "graph.ShapeAttr",
                                         box="Shape",
                                         callback=self.graph.updateData)
        self.nameCombo = OWGUI.comboBox(graph,
                                        self,
                                        "graph.NameAttr",
                                        box="Label",
                                        callback=self.graph.updateData)

        box = OWGUI.widgetBox(graph, "Distances & Stress")

        OWGUI.checkBox(box,
                       self,
                       "graph.ShowStress",
                       "Show similar pairs",
                       callback=self.graph.updateLinesRepaint)
        b2 = OWGUI.widgetBox(box)
        OWGUI.widgetLabel(b2, "Proportion of connected pairs")
        OWGUI.separator(b2, height=3)
        OWGUI.hSlider(b2,
                      self,
                      "graph.proportionGraphed",
                      minValue=0,
                      maxValue=20,
                      callback=self.graph.updateLinesRepaint,
                      tooltip=("Proportion of connected pairs (Maximum of "
                               "1000 lines will be drawn"))
        OWGUI.checkBox(box,
                       self,
                       "graph.differentWidths",
                       "Show distance by line width",
                       callback=self.graph.updateLinesRepaint)
        OWGUI.checkBox(box,
                       self,
                       "graph.stressByTransparency",
                       "Show stress by transparency",
                       callback=self.graph.updateData)
        OWGUI.checkBox(box,
                       self,
                       "graph.stressBySize",
                       "Show stress by symbol size",
                       callback=self.updateStressBySize)
        self.updateStressBySize(True)

        OWGUI.checkBox(graph,
                       self,
                       "graph.useAntialiasing",
                       label="Use antialiasing",
                       box="Antialiasing",
                       tooltip="Use antialiasing for beter quality graphics",
                       callback=self.graph.updateData)

        self.zoomToolbar = OWToolbars.ZoomSelectToolbar(
            self, graph, self.graph, self.autoSendSelection)

        self.connect(self.zoomToolbar.buttonSendSelections,
                     SIGNAL("clicked()"), self.sendSelections)
        self.graph.autoSendSelectionCallback = \
            lambda: self.autoSendSelection and self.sendSelections()

        OWGUI.checkBox(graph, self, "autoSendSelection", "Auto send selected")
        OWGUI.radioButtonsInBox(graph,
                                self,
                                "selectionOptions", [
                                    "Don't append", "Append coordinates",
                                    "Append coordinates as meta"
                                ],
                                box="Append coordinates",
                                callback=self.sendIf)

        mds.setSizePolicy(QSizePolicy(QSizePolicy.Maximum,
                                      QSizePolicy.Maximum))
        graph.setSizePolicy(
            QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum))

        self.controlArea.setMinimumWidth(250)

        OWGUI.rubber(mds)
        OWGUI.rubber(graph)

        infoBox = OWGUI.widgetBox(mds, "Info")
        self.infoA = OWGUI.widgetLabel(infoBox, "Avg. stress:")
        self.infoB = OWGUI.widgetLabel(infoBox, "Num. steps")

        self.connect(self.graphButton, SIGNAL("clicked()"),
                     self.graph.saveToFile)

        self.resize(900, 630)

        self.done = True
        self.data = None
        self.selectedInputExamples = []
        self.selectedInput = []
Ejemplo n.º 42
0
    def __init__(self, parent=None, signalManager=None, name='TreeViewer2D'):
        OWWidget.__init__(self, parent, signalManager, name, wantGraph=True)
        self.root = None
        self.selectedNode = None

        self.inputs = [("Classification Tree", orange.TreeClassifier,
                        self.ctree)]
        self.outputs = [("Examples", ExampleTable)]

        #set default settings
        self.ZoomAutoRefresh = 0
        self.AutoArrange = 0
        self.ToolTipsEnabled = 1
        self.MaxTreeDepth = 5
        self.MaxTreeDepthB = 0
        self.LineWidth = 5
        self.LineWidthMethod = 0
        self.NodeSize = 5
        self.MaxNodeWidth = 150
        self.LimitNodeWidth = True
        self.NodeInfo = [0, 1]

        self.NodeColorMethod = 0
        self.Zoom = 5
        self.VSpacing = 5
        self.HSpacing = 5
        self.TruncateText = 1

        self.loadSettings()
        self.NodeInfo.sort()

        # GUI definition
        self.tabs = OWGUI.tabWidget(self.controlArea)

        # GENERAL TAB
        GeneralTab = OWGUI.createTabPage(self.tabs, "General")
        TreeTab = OWGUI.createTabPage(self.tabs, "Tree")
        NodeTab = OWGUI.createTabPage(self.tabs, "Node")

        OWGUI.hSlider(GeneralTab,
                      self,
                      'Zoom',
                      box='Zoom',
                      minValue=1,
                      maxValue=10,
                      step=1,
                      callback=self.toggleZoomSlider,
                      ticks=1)
        OWGUI.hSlider(GeneralTab,
                      self,
                      'VSpacing',
                      box='Vertical spacing',
                      minValue=1,
                      maxValue=10,
                      step=1,
                      callback=self.toggleVSpacing,
                      ticks=1)
        OWGUI.hSlider(GeneralTab,
                      self,
                      'HSpacing',
                      box='Horizontal spacing',
                      minValue=1,
                      maxValue=10,
                      step=1,
                      callback=self.toggleHSpacing,
                      ticks=1)

        OWGUI.checkBox(GeneralTab,
                       self,
                       'ToolTipsEnabled',
                       'Show node tool tips',
                       tooltip='When mouse over the node show tool tip',
                       callback=self.updateNodeToolTips)
        #        OWGUI.checkBox(GeneralTab, self, 'TruncateText', 'Truncate text to fit margins',
        #                       tooltip='Truncate any text to fit the node width',
        #                       callback=self.toggleTruncateText)

        self.infBox = OWGUI.widgetBox(GeneralTab,
                                      'Tree Size',
                                      sizePolicy=QSizePolicy(
                                          QSizePolicy.Minimum,
                                          QSizePolicy.Fixed))
        self.infoa = OWGUI.widgetLabel(self.infBox, 'No tree.')
        self.infob = OWGUI.widgetLabel(self.infBox, " ")

        # TREE TAB
        OWGUI.checkWithSpin(TreeTab,
                            self,
                            'Max tree depth:',
                            1,
                            20,
                            'MaxTreeDepthB',
                            "MaxTreeDepth",
                            tooltip='Defines the depth of the tree displayed',
                            checkCallback=self.toggleTreeDepth,
                            spinCallback=self.toggleTreeDepth)
        OWGUI.spin(
            TreeTab,
            self,
            'LineWidth',
            min=1,
            max=10,
            step=1,
            label='Max line width:',
            tooltip='Defines max width of the edges that connect tree nodes',
            callback=self.toggleLineWidth)
        OWGUI.radioButtonsInBox(
            TreeTab,
            self,
            'LineWidthMethod', ['No dependency', 'Root node', 'Parent node'],
            box='Reference for Line Width',
            tooltips=[
                'All edges are of the same width',
                'Line width is relative to number of cases in root node',
                'Line width is relative to number of cases in parent node'
            ],
            callback=self.toggleLineWidth)

        # NODE TAB
        #        # Node size options

        cb, sb = OWGUI.checkWithSpin(NodeTab,
                                     self,
                                     "Max node width:",
                                     50,
                                     200,
                                     "LimitNodeWidth",
                                     "MaxNodeWidth",
                                     tooltip="Limit the width of tree nodes",
                                     checkCallback=self.toggleNodeSize,
                                     spinCallback=self.toggleNodeSize,
                                     step=10)
        b = OWGUI.checkBox(OWGUI.indentedBox(
            NodeTab, sep=OWGUI.checkButtonOffsetHint(cb)),
                           self,
                           "TruncateText",
                           "Truncate text",
                           callback=self.toggleTruncateText)
        cb.disables.append(b)
        cb.makeConsistent()
        #        w = OWGUI.widgetBox(NodeTab, orientation="horizontal")
        #        cb = OWGUI.checkBox(w, self, "LimitNodeWidth", "Max node width", callback=self.toggleNodeSize)
        #        sl = OWGUI.hSlider(w, self, 'MaxNodeWidth', #box='Max node width',
        #                      minValue=50, maxValue=200, step=10,
        #                      callback=self.toggleNodeSize, ticks=50)
        #        cb.disables.append(sl)
        #        cb.makeConsistent()

        # Node information
        grid = QGridLayout()
        grid.setContentsMargins(
            *self.controlArea.layout().getContentsMargins())

        navButton = OWGUI.button(self.controlArea,
                                 self,
                                 "Navigator",
                                 self.toggleNavigator,
                                 debuggingEnabled=0,
                                 addToLayout=False)
        #        findbox = OWGUI.widgetBox(self.controlArea, orientation = "horizontal")
        self.centerRootButton=OWGUI.button(self.controlArea, self, "Find Root", addToLayout=False,
                                           callback=lambda :self.rootNode and \
                                           self.sceneView.centerOn(self.rootNode.x(), self.rootNode.y()))
        self.centerNodeButton=OWGUI.button(self.controlArea, self, "Find Selected", addToLayout=False,
                                           callback=lambda :self.selectedNode and \
                                           self.sceneView.centerOn(self.selectedNode.scenePos()))
        grid.addWidget(navButton, 0, 0, 1, 2)
        grid.addWidget(self.centerRootButton, 1, 0)
        grid.addWidget(self.centerNodeButton, 1, 1)
        self.leftWidgetPart.layout().insertLayout(1, grid)

        self.NodeTab = NodeTab
        self.TreeTab = TreeTab
        self.GeneralTab = GeneralTab
        OWGUI.rubber(GeneralTab)
        OWGUI.rubber(TreeTab)
        #        OWGUI.rubber(NodeTab)
        self.rootNode = None
        self.tree = None
        self.resize(800, 500)

        self.connect(self.graphButton, SIGNAL("clicked()"), self.saveGraph)
Ejemplo n.º 43
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self,
                          parent,
                          signalManager,
                          'Hierarchical Clustering',
                          wantGraph=True)

        self.inputs = [("Distances", Orange.misc.SymMatrix, self.set_matrix)]

        self.outputs = [("Selected Data", Orange.data.Table),
                        ("Other Data", Orange.data.Table),
                        ("Centroids", Orange.data.Table)]

        self.linkage = [
            ("Single linkage", hierarchical.HierarchicalClustering.Single),
            ("Average linkage", hierarchical.HierarchicalClustering.Average),
            ("Ward's linkage", hierarchical.HierarchicalClustering.Ward),
            ("Complete linkage", hierarchical.HierarchicalClustering.Complete),
        ]

        self.Linkage = 3
        self.Annotation = 0
        self.PrintDepthCheck = 0
        self.PrintDepth = 10
        # initial horizontal and vertical dendrogram size
        self.HDSize = 500
        self.VDSize = 800
        self.ManualHorSize = 0
        self.AutoResize = 0
        self.TextSize = 8
        self.LineSpacing = 4
        self.SelectionMode = 0
        self.AppendClusters = 0
        self.CommitOnChange = 0
        self.ClassifyName = "HC_class"
        self.addIdAs = 0

        self.loadSettings()

        self.inputMatrix = None
        self.root_cluster = None
        self.selectedExamples = None

        self.selectionChanged = False

        self.linkageMethods = [a[0] for a in self.linkage]

        #################################
        ##GUI
        #################################

        #HC Settings
        OWGUI.comboBox(self.controlArea,
                       self,
                       "Linkage",
                       box="Linkage",
                       items=self.linkageMethods,
                       tooltip="Choose linkage method",
                       callback=self.run_clustering,
                       addSpace=True)
        #Label
        box = OWGUI.widgetBox(self.controlArea, "Annotation", addSpace=True)
        self.labelCombo = OWGUI.comboBox(box,
                                         self,
                                         "Annotation",
                                         items=["None"],
                                         tooltip="Choose label attribute",
                                         callback=self.update_labels)

        OWGUI.spin(box,
                   self,
                   "TextSize",
                   label="Text size",
                   min=5,
                   max=15,
                   step=1,
                   callback=self.update_font,
                   controlWidth=40,
                   keyboardTracking=False)

        # Dendrogram graphics settings
        dendrogramBox = OWGUI.widgetBox(self.controlArea,
                                        "Limits",
                                        addSpace=True)

        form = QFormLayout()
        form.setLabelAlignment(Qt.AlignLeft)

        # Depth settings
        sw = OWGUI.widgetBox(dendrogramBox,
                             orientation="horizontal",
                             addToLayout=False)
        cw = OWGUI.widgetBox(dendrogramBox,
                             orientation="horizontal",
                             addToLayout=False)

        OWGUI.hSlider(sw,
                      self,
                      "PrintDepth",
                      minValue=1,
                      maxValue=50,
                      callback=self.on_depth_change)

        cblp = OWGUI.checkBox(cw,
                              self,
                              "PrintDepthCheck",
                              "Show to depth",
                              callback=self.on_depth_change,
                              disables=[sw])
        form.addRow(cw, sw)

        checkWidth = OWGUI.checkButtonOffsetHint(cblp)

        # Width settings
        sw = OWGUI.widgetBox(dendrogramBox,
                             orientation="horizontal",
                             addToLayout=False)
        cw = OWGUI.widgetBox(dendrogramBox,
                             orientation="horizontal",
                             addToLayout=False)

        hsb = OWGUI.spin(sw,
                         self,
                         "HDSize",
                         min=200,
                         max=10000,
                         step=10,
                         callback=self.on_width_changed,
                         callbackOnReturn=False,
                         keyboardTracking=False)

        OWGUI.checkBox(cw,
                       self,
                       "ManualHorSize",
                       "Horizontal size",
                       callback=self.on_width_changed,
                       disables=[sw])

        sw.setEnabled(self.ManualHorSize)

        self.hSizeBox = hsb
        form.addRow(cw, sw)
        dendrogramBox.layout().addLayout(form)

        # Selection settings
        box = OWGUI.widgetBox(self.controlArea, "Selection")
        OWGUI.checkBox(box,
                       self,
                       "SelectionMode",
                       "Show cutoff line",
                       callback=self.update_cutoff_line)

        cb = OWGUI.checkBox(box,
                            self,
                            "AppendClusters",
                            "Append cluster IDs",
                            callback=self.commit_data_if)

        self.classificationBox = ib = OWGUI.widgetBox(box, margin=0)

        form = QWidget()
        le = OWGUI.lineEdit(form,
                            self,
                            "ClassifyName",
                            None,
                            callback=None,
                            orientation="horizontal")
        self.connect(le, SIGNAL("editingFinished()"), self.commit_data_if)

        aa = OWGUI.comboBox(
            form,
            self,
            "addIdAs",
            label=None,
            orientation="horizontal",
            items=["Class attribute", "Attribute", "Meta attribute"],
            callback=self.commit_data_if)

        layout = QFormLayout()
        layout.setSpacing(8)
        layout.setContentsMargins(0, 5, 0, 5)
        layout.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow)
        layout.setLabelAlignment(Qt.AlignLeft)
        layout.addRow("Name  ", le)
        layout.addRow("Place  ", aa)

        form.setLayout(layout)

        ib.layout().addWidget(form)
        ib.layout().setContentsMargins(checkWidth, 5, 5, 5)

        cb.disables.append(ib)
        cb.makeConsistent()

        OWGUI.separator(box)
        cbAuto = OWGUI.checkBox(box, self, "CommitOnChange",
                                "Commit on change")
        btCommit = OWGUI.button(box,
                                self,
                                "&Commit",
                                self.commit_data,
                                default=True)
        OWGUI.setStopper(self, btCommit, cbAuto, "selectionChanged",
                         self.commit_data)

        OWGUI.rubber(self.controlArea)
        self.connect(self.graphButton, SIGNAL("clicked()"), self.saveGraph)

        self.scale_scene = scale = ScaleScene(self, self)
        self.headerView = ScaleView(scale, self)
        self.footerView = ScaleView(scale, self)

        self.dendrogram = DendrogramScene(self)
        self.dendrogramView = DendrogramView(self.dendrogram, self.mainArea)

        self.connect(self.dendrogram, SIGNAL("clusterSelectionChanged()"),
                     self.on_selection_change)

        self.connect(self.dendrogram, SIGNAL("sceneRectChanged(QRectF)"),
                     scale.scene_rect_update)

        self.connect(self.dendrogram,
                     SIGNAL("dendrogramGeometryChanged(QRectF)"),
                     self.on_dendrogram_geometry_change)

        self.connect(self.dendrogram, SIGNAL("cutoffValueChanged(float)"),
                     self.on_cuttof_value_changed)

        self.connect(self.dendrogramView, SIGNAL("viewportResized(QSize)"),
                     self.on_width_changed)

        self.connect(self.dendrogramView,
                     SIGNAL("transformChanged(QTransform)"),
                     self.headerView.setTransform)
        self.connect(self.dendrogramView,
                     SIGNAL("transformChanged(QTransform)"),
                     self.footerView.setTransform)

        self.mainArea.layout().addWidget(self.headerView)
        self.mainArea.layout().addWidget(self.dendrogramView)
        self.mainArea.layout().addWidget(self.footerView)

        self.dendrogram.header = self.headerView
        self.dendrogram.footer = self.footerView

        self.connect(self.dendrogramView.horizontalScrollBar(),
                     SIGNAL("valueChanged(int)"),
                     self.footerView.horizontalScrollBar().setValue)

        self.connect(self.dendrogramView.horizontalScrollBar(),
                     SIGNAL("valueChanged(int)"),
                     self.headerView.horizontalScrollBar().setValue)

        self.dendrogram.setSceneRect(0, 0, self.HDSize, self.VDSize)
        self.dendrogram.update()
        self.resize(800, 500)

        self.natural_dendrogram_width = 800
        self.dendrogramView.set_fit_to_width(not self.ManualHorSize)

        self.matrix = None
        self.selectionList = []
        self.selected_clusters = []
Ejemplo n.º 44
0
    def __init__(self, parent=None, signalManager=None, name="Image viewer"):
        OWWidget.__init__(self, parent, signalManager, name, wantGraph=True)

        self.inputs = [("Data", ExampleTable, self.setData)]
        self.outputs = [("Data", ExampleTable)]

        self.imageAttr = 0
        self.titleAttr = 0
        self.zoom = 25
        self.autoCommit = False
        self.selectionChangedFlag = False

        #
        # GUI
        #

        self.loadSettings()

        self.info = OWGUI.widgetLabel(
            OWGUI.widgetBox(self.controlArea, "Info"),
            "Waiting for input\n"
        )

        self.imageAttrCB = OWGUI.comboBox(
            self.controlArea, self, "imageAttr",
            box="Image Filename Attribute",
            tooltip="Attribute with image filenames",
            callback=[self.clearScene, self.setupScene],
            addSpace=True
        )

        self.titleAttrCB = OWGUI.comboBox(
            self.controlArea, self, "titleAttr",
            box="Title Attribute",
            tooltip="Attribute with image title",
            callback=self.updateTitles,
            addSpace=True
        )

        OWGUI.hSlider(
            self.controlArea, self, "zoom",
            box="Zoom", minValue=1, maxValue=100, step=1,
            callback=self.updateZoom,
            createLabel=False
        )

        OWGUI.separator(self.controlArea)

        box = OWGUI.widgetBox(self.controlArea, "Selection")
        b = OWGUI.button(box, self, "Commit", callback=self.commit)
        cb = OWGUI.checkBox(
            box, self, "autoCommit", "Commit on any change",
            tooltip="Send selections on any change",
            callback=self.commitIf
        )

        OWGUI.setStopper(self, b, cb, "selectionChangedFlag",
                         callback=self.commit)

        OWGUI.rubber(self.controlArea)

        self.scene = GraphicsScene()
        self.sceneView = QGraphicsView(self.scene, self)
        self.sceneView.setAlignment(Qt.AlignTop | Qt.AlignLeft)
        self.sceneView.setRenderHint(QPainter.Antialiasing, True)
        self.sceneView.setRenderHint(QPainter.TextAntialiasing, True)
        self.sceneView.setFocusPolicy(Qt.WheelFocus)
        self.sceneView.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self.sceneView.installEventFilter(self)
        self.mainArea.layout().addWidget(self.sceneView)

        self.scene.selectionChanged.connect(self.onSelectionChanged)
        self.scene.selectionRectPointChanged.connect(
            self.onSelectionRectPointChanged, Qt.QueuedConnection
        )
        self.graphButton.clicked.connect(self.saveScene)
        self.resize(800, 600)

        self.thumbnailWidget = None
        self.sceneLayout = None
        self.selectedExamples = []

        #: List of _ImageItems
        self.items = []

        self._errcount = 0
        self._successcount = 0

        self.loader = ImageLoader(self)

        # Add the "orange-sf" path prefix for locating files
        # distributed using `serverfiles`.
        sfdir = serverfiles.localpath()
        if sfdir not in [unicode(p) for p in QDir.searchPaths("orange-sf")]:
            QDir.addSearchPath("orange-sf", sfdir)
Ejemplo n.º 45
0
    def __init__(self,parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "Mosaic display", True, True)

        #set default settings
        self.data = None
        self.unprocessedSubsetData = None
        self.subsetData = None
        self.names = []     # class values

        self.inputs = [("Data", ExampleTable, self.setData, Default), ("Data Subset", ExampleTable, self.setSubsetData)]
        self.outputs = [("Selected Data", ExampleTable), ("Learner", orange.Learner)]

        #load settings
        self.colorSettings = None
        self.selectedSchemaIndex = 0
        self.interiorColoring = 0
        self.cellspace = 4
        self.showAprioriDistributionBoxes = 1
        self.useBoxes = 1
        self.showSubsetDataBoxes = 1
        self.horizontalDistribution = 0
        self.showAprioriDistributionLines = 0
        self.boxSize = 5
        self.exploreAttrPermutations = 0
        self.attr1 = ""
        self.attr2 = ""
        self.attr3 = ""
        self.attr4 = ""

        self.attributeNameOffset = 30
        self.attributeValueOffset = 15
        self.residuals = [] # residual values if the residuals are visualized
        self.aprioriDistributions = []
        self.colorPalette = None
        self.permutationDict = {}
        self.manualAttributeValuesDict = {}
        self.conditionalDict = None
        self.conditionalSubsetDict = None
        self.activeRule = None
        self.removeUnusedValues = 0

        self.selectionRectangle = None
        self.selectionConditionsHistorically = []
        self.selectionConditions = []

        # color paletes for visualizing pearsons residuals
        #self.blueColors = [QColor(255, 255, 255), QColor(117, 149, 255), QColor(38, 43, 232), QColor(1,5,173)]
        self.blueColors = [QColor(255, 255, 255), QColor(210, 210, 255), QColor(110, 110, 255), QColor(0,0,255)]
        self.redColors = [QColor(255, 255, 255), QColor(255, 200, 200), QColor(255, 100, 100), QColor(255, 0, 0)]

        self.loadSettings()

        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main")
        self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings")

        self.canvas = QGraphicsScene()
        self.canvasView = MosaicSceneView(self, self.canvas, self.mainArea)
        self.mainArea.layout().addWidget(self.canvasView)
        self.canvasView.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.canvasView.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.canvasView.setRenderHint(QPainter.Antialiasing)
        #self.canvasView.setAlignment(Qt.AlignLeft | Qt.AlignTop)

        #GUI
        #add controls to self.controlArea widget
        #self.controlArea.setMinimumWidth(235)

        texts = ["1st Attribute", "2nd Attribute", "3rd Attribute", "4th Attribute"]
        for i in range(1,5):
            box = OWGUI.widgetBox(self.GeneralTab, texts[i-1], orientation = "horizontal")
            combo = OWGUI.comboBox(box, self, "attr" + str(i), None, callback = self.updateGraphAndPermList, sendSelectedValue = 1, valueType = str)

            butt = OWGUI.button(box, self, "", callback = self.orderAttributeValues, tooltip = "Change the order of attribute values", debuggingEnabled = 0)
            butt.setFixedSize(26, 24)
            butt.setCheckable(1)
            butt.setIcon(QIcon(os.path.join(self.widgetDir, "icons/Dlg_sort.png")))

            setattr(self, "sort"+str(i), butt)
            setattr(self, "attr" + str(i)+ "Combo", combo)

        self.optimizationDlg = OWMosaicOptimization(self, self.signalManager)

        optimizationButtons = OWGUI.widgetBox(self.GeneralTab, "Dialogs", orientation = "horizontal")
        OWGUI.button(optimizationButtons, self, "VizRank", callback = self.optimizationDlg.reshow, debuggingEnabled = 0, tooltip = "Find attribute combinations that will separate different classes as clearly as possible.")

        self.collapsableWBox = OWGUI.collapsableWidgetBox(self.GeneralTab, "Explore Attribute Permutations", self, "exploreAttrPermutations", callback = self.permutationListToggle)
        self.permutationList = OWGUI.listBox(self.collapsableWBox, self, callback = self.setSelectedPermutation)
        #self.permutationList.hide()
        self.GeneralTab.layout().addStretch(100)

        # ######################
        # SETTINGS TAB
        # ######################
        box5 = OWGUI.widgetBox(self.SettingsTab, "Colors in Cells Represent...", addSpace = 1)
        OWGUI.comboBox(box5, self, "interiorColoring", None, items = self.interiorColoringOpts, callback = self.updateGraph)
        #box5.setSizePolicy(QSizePolicy(QSizePolicy.Minimum , QSizePolicy.Fixed ))

        box = OWGUI.widgetBox(self.SettingsTab, "Visual Settings", addSpace = 1)
        
        OWGUI.hSlider(box, self, 'cellspace', label = "Cell distance: ", minValue=1, maxValue=15, step=1, callback = self.updateGraph, tooltip = "What is the minimum distance between two rectangles in the plot?")
        OWGUI.checkBox(box, self, "removeUnusedValues", "Remove unused attribute values", tooltip = "Do you want to remove unused attribute values?\nThis setting will not be considered until new data is received.")

        self.box6 = OWGUI.widgetBox(self.SettingsTab, "Cell Distribution Settings", addSpace = 1)
        OWGUI.comboBox(self.box6, self, 'horizontalDistribution', items = ["Show Distribution Vertically", "Show Distribution Horizontally"], tooltip = "Do you wish to see class distribution drawn horizontally or vertically?", callback = self.updateGraph)
        OWGUI.checkBox(self.box6, self, 'showAprioriDistributionLines', 'Show apriori distribution with lines', callback = self.updateGraph, tooltip = "Show the lines that represent the apriori class distribution")

        self.box8 = OWGUI.widgetBox(self.SettingsTab, "Boxes in Cells", addSpace = 1)
        OWGUI.hSlider(self.box8, self, 'boxSize', label = "Size: ", minValue=1, maxValue=15, step=1, callback = self.updateGraph, tooltip = "What is the size of the boxes on the left and right edge of each cell?")
        OWGUI.checkBox(self.box8, self, 'showSubsetDataBoxes', 'Show class distribution of subset data', callback = self.updateGraph, tooltip = "Show small boxes at right (or bottom) edge of cells to represent class distribution of examples from example subset input.")
        cb = OWGUI.checkBox(self.box8, self, 'useBoxes', 'Use boxes on left to show...', callback = self.updateGraph, tooltip = "Show small boxes at left (or top) edge of cells to represent additional information.")
        indBox = OWGUI.indentedBox(self.box8, sep=OWGUI.checkButtonOffsetHint(cb))
        OWGUI.comboBox(indBox, self, 'showAprioriDistributionBoxes', items = self.subboxesOpts, tooltip = "Show additional boxes for each mosaic cell representing:\n - expected class distribution (assuming independence between attributes)\n - apriori class distribution (based on all examples).", callback = self.updateGraph)

        hbox = OWGUI.widgetBox(self.SettingsTab, "Colors", addSpace = 1)
        OWGUI.button(hbox, self, "Set Colors", self.setColors, tooltip = "Set the color palette for class values", debuggingEnabled = 0)

        #self.box6.setSizePolicy(QSizePolicy(QSizePolicy.Minimum , QSizePolicy.Fixed ))
        self.SettingsTab.layout().addStretch(1)

        self.connect(self.graphButton, SIGNAL("clicked()"), self.saveToFileCanvas)
        self.icons = self.createAttributeIconDict()
        self.resize(830, 550)

        self.VizRankLearner = MosaicTreeLearner(self.optimizationDlg)
        self.send("Learner", self.VizRankLearner)

        self.wdChildDialogs = [self.optimizationDlg]        # used when running widget debugging

        self.collapsableWBox.updateControls()
        dlg = self.createColorDialog()
        self.colorPalette = dlg.getDiscretePalette("discPalette")
        self.selectionColorPalette = [QColor(*col) for col in OWColorPalette.defaultRGBColors]
Ejemplo n.º 46
0
    def __init__(self, parent=None, signalManager=None, name="Linear Projection (qt)", graphClass=None):
        OWVisWidget.__init__(self, parent, signalManager, name, TRUE)

        self.inputs = [
            ("Data", ExampleTable, self.setData, Default),
            ("Data Subset", ExampleTable, self.setSubsetData),
            ("Features", AttributeList, self.setShownAttributes),
            ("Evaluation Results", orngTest.ExperimentResults, self.setTestResults),
            ("VizRank Learner", orange.Learner, self.setVizRankLearner),
            ("Distances", orange.SymMatrix, self.setDistances),
        ]
        self.outputs = [
            ("Selected Data", ExampleTable),
            ("Other Data", ExampleTable),
            ("Features", AttributeList),
            ("FreeViz Learner", orange.Learner),
        ]

        name_lower = name.lower()
        self._name_lower = name_lower

        # local variables
        self.showAllAttributes = 0
        self.valueScalingType = 0
        self.autoSendSelection = 1
        self.data = None
        self.subsetData = None
        self.distances = None
        self.toolbarSelection = 0
        self.classificationResults = None
        self.outlierValues = None
        self.attributeSelectionList = None
        self.colorSettings = None
        self.selectedSchemaIndex = 0
        self.addProjectedPositions = 0
        self.resetAnchors = 0

        # add a graph widget
        if graphClass:
            self.graph = graphClass(self, self.mainArea, name)
        else:
            self.graph = OWLinProjGraph(self, self.mainArea, name)
        self.mainArea.layout().addWidget(self.graph)

        # graph variables
        self.graph.manualPositioning = 0
        self.graph.hideRadius = 0
        self.graph.showAnchors = 1
        self.graph.jitterContinuous = 0
        self.graph.showProbabilities = 0
        self.graph.useDifferentSymbols = 0
        self.graph.useDifferentColors = 1
        self.graph.tooltipKind = 0
        self.graph.tooltipValue = 0
        self.graph.scaleFactor = 1.0
        self.graph.squareGranularity = 3
        self.graph.spaceBetweenCells = 1
        self.graph.showAxisScale = 0
        self.graph.showValueLines = 0
        self.graph.valueLineLength = 5
        self.dark_theme = False

        if "3d" in name_lower:
            self.settingsList.append("graph.use_2d_symbols")
            self.settingsList.append("graph.mouse_sensitivity")
            self.settingsList.append("dark_theme")
            if "sphereviz" in name_lower:
                self.settingsList.append("graph.show_anchor_grid")

        # load settings
        self.loadSettings()

        ##        # cluster dialog
        ##        self.clusterDlg = ClusterOptimization(self, self.signalManager, self.graph, name)
        ##        self.graph.clusterOptimization = self.clusterDlg

        # optimization dialog
        if "radviz" in name_lower:
            self.vizrank = OWVizRank(self, self.signalManager, self.graph, orngVizRank.RADVIZ, name)
            self.connect(self.graphButton, SIGNAL("clicked()"), self.saveToFile)
        elif "polyviz" in name_lower:
            self.vizrank = OWVizRank(self, self.signalManager, self.graph, orngVizRank.POLYVIZ, name)
            self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile)
        elif "sphereviz" in name_lower:
            self.vizrank = OWVizRank(self, self.signalManager, self.graph, orngVizRank.SPHEREVIZ3D, name)
            self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile)
        elif "3d" in name_lower:
            self.vizrank = OWVizRank(self, self.signalManager, self.graph, orngVizRank.LINEAR_PROJECTION3D, name)
            self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile)
        else:
            self.vizrank = OWVizRank(self, self.signalManager, self.graph, orngVizRank.LINEAR_PROJECTION, name)
            self.connect(self.graphButton, SIGNAL("clicked()"), self.saveToFile)

        self.optimizationDlg = self.vizrank  # for backward compatibility

        # ignore settings!! if we have radviz then normalize, otherwise not.
        self.graph.normalizeExamples = "radviz" in name_lower or "sphereviz" in name_lower

        # GUI
        # add a settings dialog and initialize its values

        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main")
        self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings", canScroll=1)
        if not "3d" in name_lower:
            self.PerformanceTab = OWGUI.createTabPage(self.tabs, "Performance")

        # add controls to self.controlArea widget
        self.createShowHiddenLists(self.GeneralTab, callback=self.updateGraphAndAnchors)

        self.optimizationButtons = OWGUI.widgetBox(self.GeneralTab, "Optimization Dialogs", orientation="horizontal")
        self.vizrankButton = OWGUI.button(
            self.optimizationButtons,
            self,
            "VizRank",
            callback=self.vizrank.reshow,
            tooltip="Opens VizRank dialog, where you can search for interesting projections with different subsets of attributes.",
            debuggingEnabled=0,
        )
        self.wdChildDialogs = [self.vizrank]  # used when running widget debugging

        # freeviz dialog
        if "radviz" in name_lower or "linear projection" in name_lower or "sphereviz" in name_lower:
            self.freeVizDlg = FreeVizOptimization(self, self.signalManager, self.graph, name)
            self.wdChildDialogs.append(self.freeVizDlg)
            self.freeVizDlgButton = OWGUI.button(
                self.optimizationButtons,
                self,
                "FreeViz",
                callback=self.freeVizDlg.reshow,
                tooltip="Opens FreeViz dialog, where the position of attribute anchors is optimized so that class separation is improved",
                debuggingEnabled=0,
            )
            if "linear projection" in name_lower:
                self.freeVizLearner = FreeVizLearner(self.freeVizDlg)
                self.send("FreeViz Learner", self.freeVizLearner)
            if "3d" in name_lower:
                # Patch a method in Freeviz
                get_shown_attribute_list = lambda: [anchor[3] for anchor in self.graph.anchorData]
                self.freeVizDlg.get_shown_attribute_list = get_shown_attribute_list
                self.freeVizDlg.getShownAttributeList = get_shown_attribute_list
                self.freeVizDlg._use_3D = True

        ##        self.clusterDetectionDlgButton = OWGUI.button(self.optimizationButtons, self, "Cluster", callback = self.clusterDlg.reshow, debuggingEnabled = 0)
        ##        self.vizrankButton.setMaximumWidth(63)
        ##        self.clusterDetectionDlgButton.setMaximumWidth(63)
        ##        self.freeVizDlgButton.setMaximumWidth(63)
        ##        self.connect(self.clusterDlg.startOptimizationButton , SIGNAL("clicked()"), self.optimizeClusters)
        ##        self.connect(self.clusterDlg.resultList, SIGNAL("selectionChanged()"),self.showSelectedCluster)

        gui = self.graph.gui

        if "3d" in name_lower:
            toolbar_buttons = [
                gui.StateButtonsBegin,
                (gui.UserButton, "Rotate", "state", ROTATING, None, "Dlg_undo"),
                gui.Select,
                gui.StateButtonsEnd,
                gui.Spacing,
                gui.SendSelection,
                gui.ClearSelection,
            ]

            self.zoomSelectToolbar = gui.zoom_select_toolbar(self.GeneralTab, buttons=toolbar_buttons)
            self.connect(self.zoomSelectToolbar.buttons[gui.SendSelection], SIGNAL("clicked()"), self.sendSelections)
            self.graph.set_selection_behavior(OWPlot.ReplaceSelection)
        else:
            # zooming / selection
            self.zoomSelectToolbar = gui.zoom_select_toolbar(
                self.GeneralTab, buttons=gui.default_zoom_select_buttons + [gui.Spacing, gui.ShufflePoints]
            )
            self.connect(self.zoomSelectToolbar.buttons[gui.SendSelection], SIGNAL("clicked()"), self.sendSelections)

        # ####################################
        # SETTINGS TAB
        # #####
        self.extraTopBox = OWGUI.widgetBox(self.SettingsTab, orientation="vertical")
        self.extraTopBox.hide()

        self.graph.gui.point_properties_box(self.SettingsTab)

        box = OWGUI.widgetBox(self.SettingsTab, "Jittering Options")
        OWGUI.comboBoxWithCaption(
            box,
            self,
            "graph.jitterSize",
            "Jittering size (% of range):",
            callback=self.resetGraphData,
            items=self.jitterSizeNums,
            sendSelectedValue=1,
            valueType=float,
        )
        OWGUI.checkBox(
            box,
            self,
            "graph.jitterContinuous",
            "Jitter continuous attributes",
            callback=self.resetGraphData,
            tooltip="Does jittering apply also on continuous attributes?",
        )

        if not "3d" in name_lower:
            box = OWGUI.widgetBox(self.SettingsTab, "Scaling Options")
            OWGUI.qwtHSlider(
                box,
                self,
                "graph.scaleFactor",
                label="Inflate points by: ",
                minValue=1.0,
                maxValue=10.0,
                step=0.1,
                callback=self.updateGraph,
                tooltip="If points lie too much together you can expand their position to improve perception",
                maxWidth=90,
            )

        box = OWGUI.widgetBox(self.SettingsTab, "General Graph Settings")
        # OWGUI.checkBox(box, self, 'graph.normalizeExamples', 'Normalize examples', callback = self.updateGraph)
        self.graph.gui.show_legend_check_box(box)
        bbox = OWGUI.widgetBox(box, orientation="horizontal")
        if "3d" in name_lower:
            OWGUI.checkBox(bbox, self, "graph.showValueLines", "Show value lines  ", callback=self.graph.update)
            OWGUI.qwtHSlider(
                bbox,
                self,
                "graph.valueLineLength",
                minValue=1,
                maxValue=10,
                step=1,
                callback=self.graph.update,
                showValueLabel=0,
            )
        else:
            OWGUI.checkBox(bbox, self, "graph.showValueLines", "Show value lines  ", callback=self.updateGraph)
            OWGUI.qwtHSlider(
                bbox,
                self,
                "graph.valueLineLength",
                minValue=1,
                maxValue=10,
                step=1,
                callback=self.updateGraph,
                showValueLabel=0,
            )
        OWGUI.checkBox(
            box,
            self,
            "graph.useDifferentSymbols",
            "Use different symbols",
            callback=self.updateGraph,
            tooltip="Show different class values using different symbols",
        )
        OWGUI.checkBox(
            box,
            self,
            "graph.useDifferentColors",
            "Use different colors",
            callback=self.updateGraph,
            tooltip="Show different class values using different colors",
        )

        if "3d" in name_lower:
            OWGUI.checkBox(box, self, "dark_theme", "Dark theme", callback=self.on_theme_change)
            OWGUI.checkBox(
                box, self, "graph.use_2d_symbols", "2D symbols", callback=self.updateGraph, tooltip="Use 2D symbols"
            )
            self.on_theme_change()
            if "sphereviz" in name_lower:
                OWGUI.checkBox(box, self, "graph.show_anchor_grid", "Anchor grid", callback=self.on_theme_change)
                box = OWGUI.widgetBox(self.SettingsTab, "Camery type", orientation="horizontal")
                c = OWGUI.comboBox(
                    box, self, "graph.camera_type", callback=self.graph.update_camera_type, sendSelectedValue=0
                )
                c.addItem("Default")
                c.addItem("Center")
                c.addItem("Random attribute")
                OWGUI.hSlider(
                    box,
                    self,
                    "graph.camera_angle",
                    label="FOV",
                    minValue=45,
                    maxValue=180,
                    step=1,
                    callback=self.graph.update,
                    tooltip="Field of view angle",
                )
            box = OWGUI.widgetBox(self.SettingsTab, "Mouse", orientation="horizontal")
            OWGUI.hSlider(
                box,
                self,
                "graph.mouse_sensitivity",
                label="Sensitivity",
                minValue=1,
                maxValue=10,
                step=1,
                callback=self.graph.update,
                tooltip="Change mouse sensitivity",
            )
        else:
            self.graph.gui.filled_symbols_check_box(box)
            wbox = OWGUI.widgetBox(box, orientation="horizontal")
            OWGUI.checkBox(
                wbox,
                self,
                "graph.showProbabilities",
                "Show probabilities" + "  ",
                callback=self.updateGraph,
                tooltip="Show a background image with class probabilities",
            )
            smallWidget = OWGUI.SmallWidgetLabel(
                wbox, pixmap=1, box="Advanced settings", tooltip="Show advanced settings"
            )
            OWGUI.rubber(wbox)

            box = OWGUI.widgetBox(smallWidget.widget, orientation="horizontal")
            OWGUI.widgetLabel(box, "Granularity:  ")
            OWGUI.hSlider(
                box, self, "graph.squareGranularity", minValue=1, maxValue=10, step=1, callback=self.updateGraph
            )

            box = OWGUI.widgetBox(smallWidget.widget, orientation="horizontal")
            OWGUI.checkBox(box, self, "graph.spaceBetweenCells", "Show space between cells", callback=self.updateGraph)

        box = OWGUI.widgetBox(self.SettingsTab, "Colors", orientation="horizontal")
        OWGUI.button(
            box,
            self,
            "Colors",
            self.setColors,
            tooltip="Set the canvas background color and color palette for coloring variables",
            debuggingEnabled=0,
        )

        box = OWGUI.widgetBox(self.SettingsTab, "Tooltips Settings")
        callback = self.graph.update if "3d" in name_lower else self.updateGraph
        OWGUI.comboBox(
            box,
            self,
            "graph.tooltipKind",
            items=["Show line tooltips", "Show visible attributes", "Show all attributes"],
            callback=callback,
        )
        OWGUI.comboBox(
            box,
            self,
            "graph.tooltipValue",
            items=["Tooltips show data values", "Tooltips show spring values"],
            callback=callback,
            tooltip="Do you wish that tooltips would show you original values of visualized attributes or the 'spring' values (values between 0 and 1). \nSpring values are scaled values that are used for determining the position of shown points. Observing these values will therefore enable you to \nunderstand why the points are placed where they are.",
        )

        box = OWGUI.widgetBox(self.SettingsTab, "Auto Send Selected Data When...")
        OWGUI.checkBox(
            box,
            self,
            "autoSendSelection",
            "Adding/Removing selection areas",
            callback=self.selectionChanged,
            tooltip="Send selected data whenever a selection area is added or removed",
        )
        OWGUI.checkBox(
            box,
            self,
            "graph.sendSelectionOnUpdate",
            "Moving/Resizing selection areas",
            tooltip="Send selected data when a user moves or resizes an existing selection area",
        )
        OWGUI.comboBox(
            box,
            self,
            "addProjectedPositions",
            items=[
                "Do not modify the domain",
                "Append projection as attributes",
                "Append projection as meta attributes",
            ],
            callback=self.sendSelections,
        )
        self.selectionChanged()

        self.SettingsTab.layout().addStretch(100)

        if not "3d" in name_lower:
            self.graph.gui.effects_box(self.PerformanceTab)
            self.PerformanceTab.layout().addStretch(100)

        self.icons = self.createAttributeIconDict()
        self.debugSettings = ["hiddenAttributes", "shownAttributes"]

        dlg = self.createColorDialog()
        self.graph.contPalette = dlg.getContinuousPalette("contPalette")
        self.graph.discPalette = dlg.getDiscretePalette("discPalette")

        p = self.graph.palette()
        p.setColor(OWPalette.Canvas, dlg.getColor("Canvas"))
        self.graph.set_palette(p)

        self.cbShowAllAttributes()  # update list boxes based on the check box value

        self.resize(900, 700)
Ejemplo n.º 47
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, "Parallel Coordinates",
                          TRUE)

        #add a graph widget
        self.graph = OWParallelGraph(self, self.mainArea)
        self.mainArea.layout().addWidget(self.graph)

        self.showAllAttributes = 0

        self.inputs = [("Data", ExampleTable, self.setData, Default),
                       ("Data Subset", ExampleTable, self.setSubsetData),
                       ("Features", AttributeList, self.setShownAttributes)]
        self.outputs = [("Selected Data", ExampleTable),
                        ("Other Data", ExampleTable),
                        ("Features", AttributeList)]

        #set default settings
        self.data = None
        self.subsetData = None
        self.autoSendSelection = 1
        self.attrDiscOrder = "Unordered"
        self.attrContOrder = "Unordered"
        self.projections = None
        self.correlationDict = {}
        self.middleLabels = "Correlations"
        self.attributeSelectionList = None
        self.toolbarSelection = 0
        self.colorSettings = None
        self.selectedSchemaIndex = 0

        self.graph.jitterSize = 10
        self.graph.showDistributions = 1
        self.graph.showStatistics = 0
        self.graph.showAttrValues = 1
        self.graph.useSplines = 0
        self.graph.enabledLegend = 1

        #load settings
        self.loadSettings()

        #GUI
        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main")
        self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings")

        self.createShowHiddenLists(self.GeneralTab, callback=self.updateGraph)
        self.connect(self.shownAttribsLB,
                     SIGNAL('itemDoubleClicked(QListWidgetItem*)'),
                     self.flipAttribute)

        self.optimizationDlg = ParallelOptimization(
            self, signalManager=self.signalManager)
        self.optimizationDlgButton = OWGUI.button(
            self.GeneralTab,
            self,
            "Optimization Dialog",
            callback=self.optimizationDlg.reshow,
            debuggingEnabled=0)

        self.zoomSelectToolbar = OWToolbars.ZoomSelectToolbar(
            self,
            self.GeneralTab,
            self.graph,
            self.autoSendSelection,
            buttons=(1, 2, 0, 7, 8))
        self.connect(self.zoomSelectToolbar.buttonSendSelections,
                     SIGNAL("clicked()"), self.sendSelections)

        #connect controls to appropriate functions
        self.connect(self.graphButton, SIGNAL("clicked()"),
                     self.graph.saveToFile)

        # ####################################
        # SETTINGS functionality
        box = OWGUI.widgetBox(self.SettingsTab, "Transparency")
        OWGUI.hSlider(box,
                      self,
                      'graph.alphaValue',
                      label="Examples: ",
                      minValue=0,
                      maxValue=255,
                      step=10,
                      callback=self.updateGraph,
                      tooltip="Alpha value used for drawing example lines")
        OWGUI.hSlider(
            box,
            self,
            'graph.alphaValue2',
            label="Rest:     ",
            minValue=0,
            maxValue=255,
            step=10,
            callback=self.updateGraph,
            tooltip="Alpha value used to draw statistics, example subsets, ..."
        )

        box = OWGUI.widgetBox(self.SettingsTab, "Jittering Options")
        OWGUI.comboBox(box,
                       self,
                       "graph.jitterSize",
                       label='Jittering size (% of size):  ',
                       orientation='horizontal',
                       callback=self.setJitteringSize,
                       items=self.jitterSizeNums,
                       sendSelectedValue=1,
                       valueType=float)

        # visual settings
        box = OWGUI.widgetBox(self.SettingsTab, "Visual Settings")

        OWGUI.checkBox(box,
                       self,
                       'graph.showAttrValues',
                       'Show attribute values',
                       callback=self.updateGraph)
        OWGUI.checkBox(box,
                       self,
                       'graph.useAntialiasing',
                       'Use antialiasing',
                       callback=self.updateGraph)
        OWGUI.checkBox(box,
                       self,
                       'graph.useSplines',
                       'Show splines',
                       callback=self.updateGraph,
                       tooltip="Show lines using splines")
        OWGUI.checkBox(box,
                       self,
                       'graph.enabledLegend',
                       'Show legend',
                       callback=self.updateGraph)

        box = OWGUI.widgetBox(self.SettingsTab, "Axis Distance")
        resizeColsBox = OWGUI.widgetBox(box, 0, "horizontal", 0)
        OWGUI.label(resizeColsBox, self, "Increase/decrease distance: ")
        b = OWGUI.toolButton(resizeColsBox,
                             self,
                             "+",
                             callback=self.increaseAxesDistance,
                             tooltip="Increase the distance between the axes",
                             width=30,
                             height=20)
        b = OWGUI.toolButton(resizeColsBox,
                             self,
                             "-",
                             callback=self.decreaseAxesDistance,
                             tooltip="Decrease the distance between the axes",
                             width=30,
                             height=20)
        OWGUI.rubber(resizeColsBox)
        OWGUI.checkBox(
            box,
            self,
            "graph.autoUpdateAxes",
            "Auto scale X axis",
            tooltip="Auto scale X axis to show all visualized attributes",
            callback=self.updateGraph)

        box = OWGUI.widgetBox(self.SettingsTab, "Statistical Information")
        OWGUI.comboBox(
            box,
            self,
            "graph.showStatistics",
            label="Statistics: ",
            orientation="horizontal",
            labelWidth=90,
            items=["No statistics", "Means, deviations", "Median, quartiles"],
            callback=self.updateGraph,
            sendSelectedValue=0,
            valueType=int)
        OWGUI.comboBox(
            box,
            self,
            "middleLabels",
            label="Middle labels: ",
            orientation="horizontal",
            labelWidth=90,
            items=["No labels", "Correlations", "VizRank"],
            callback=self.updateGraph,
            tooltip=
            "The information do you wish to view on top in the middle of coordinate axes",
            sendSelectedValue=1,
            valueType=str)
        OWGUI.checkBox(
            box,
            self,
            'graph.showDistributions',
            'Show distributions',
            callback=self.updateGraph,
            tooltip=
            "Show bars with distribution of class values (only for discrete attributes)"
        )

        box = OWGUI.widgetBox(self.SettingsTab,
                              "Colors",
                              orientation="horizontal")
        OWGUI.button(
            box,
            self,
            "Set colors",
            self.setColors,
            tooltip=
            "Set the canvas background color and color palette for coloring continuous variables",
            debuggingEnabled=0)

        box = OWGUI.widgetBox(self.SettingsTab,
                              "Auto Send Selected Data When...")
        OWGUI.checkBox(
            box,
            self,
            'autoSendSelection',
            'Adding/Removing selection areas',
            callback=self.selectionChanged,
            tooltip=
            "Send selected data whenever a selection area is added or removed")
        OWGUI.checkBox(
            box,
            self,
            'graph.sendSelectionOnUpdate',
            'Moving/Resizing selection areas',
            tooltip=
            "Send selected data when a user moves or resizes an existing selection area"
        )
        self.graph.autoSendSelectionCallback = self.selectionChanged

        self.SettingsTab.layout().addStretch(100)
        self.icons = self.createAttributeIconDict()

        dlg = self.createColorDialog()
        self.graph.contPalette = dlg.getContinuousPalette("contPalette")
        self.graph.discPalette = dlg.getDiscretePalette("discPalette")
        self.graph.setCanvasBackground(dlg.getColor("Canvas"))
        apply([
            self.zoomSelectToolbar.actionZooming,
            self.zoomSelectToolbar.actionRectangleSelection,
            self.zoomSelectToolbar.actionPolygonSelection
        ][self.toolbarSelection], [])
        self.cbShowAllAttributes()

        self.resize(900, 700)
    def __init__(self, parent=None, signalManager=None,
                 name="Multi Dimensional Scaling"):
        OWWidget.__init__(self, parent, signalManager, name, wantGraph=True)

        self.inputs = [("Distances", orange.SymMatrix, self.cmatrix),
                       ("Data Subset", ExampleTable, self.cselected)]
        self.outputs = [("Data", ExampleTable)]

        self.StressFunc = 3
        self.minStressDelta = 5e-5
        self.maxIterations = 5000
        self.maxImprovment = 10
        self.autoSendSelection = 0
        self.toolbarSelection = 0
        self.selectionOptions = 0
        self.computeStress = 1
        self.ReDraw = 1
        self.NumIter = 1
        self.RefreshMode = 0
        self.applyLSMT = 0

        self.stressFunc = [("Kruskal stress", orngMDS.KruskalStress),
                           ("Sammon stress", orngMDS.SammonStress),
                           ("Signed Sammon stress", orngMDS.SgnSammonStress),
                           ("Signed relative stress", orngMDS.SgnRelStress)]

        self.graph = MDSGraph(self.mainArea)
        self.mainArea.layout().addWidget(self.graph)

        self.loadSettings()

        tabs = OWGUI.tabWidget(self.controlArea)

        mds = OWGUI.createTabPage(tabs, "MDS")
        graph = OWGUI.createTabPage(tabs, "Graph")

        # MDS Tab
        init = OWGUI.widgetBox(mds, "Initialization")
        OWGUI.button(init, self, "Randomize", self.randomize)
        OWGUI.button(init, self, "Jitter", self.jitter)
        OWGUI.button(init, self, "Torgerson", self.torgerson)

        opt = OWGUI.widgetBox(mds, "Optimization")

        self.startButton = OWGUI.button(opt, self, "Optimize", self.testStart)
        OWGUI.button(opt, self, "Single Step", self.smacofStep)
        box = OWGUI.widgetBox(opt, "Stress Function")
        OWGUI.comboBox(box, self, "StressFunc",
                       items=[a[0] for a in self.stressFunc],
                       callback=self.updateStress)

        OWGUI.radioButtonsInBox(opt, self, "RefreshMode",
                                ["Every step", "Every 10 steps",
                                 "Every 100 steps"],
                                "Refresh During Optimization")

        self.stopping = OWGUI.widgetBox(opt, "Stopping Conditions")

        OWGUI.hSlider(OWGUI.widgetBox(self.stopping, "Min. stress change",
                                      flat=True),
                      self, "minStressDelta", minValue=5e-5, maxValue=1e-2,
                      step=5e-5, labelFormat="%.5f", intOnly=0)

        OWGUI.hSlider(OWGUI.widgetBox(self.stopping, "Max. number of steps",
                                    flat=True),
                      self, "maxIterations", minValue=10, maxValue=5000,
                      step=10, labelFormat="%i")

        # Graph Tab
        OWGUI.hSlider(graph, self, "graph.PointSize", box="Point Size",
                      minValue=1, maxValue=20, callback=self.graph.updateData)

        self.colorCombo = OWGUI.comboBox(graph, self, "graph.ColorAttr",
                                         box="Color",
                                         callback=self.graph.updateData)
        self.sizeCombo = OWGUI.comboBox(graph, self, "graph.SizeAttr",
                                        box="Size",
                                        callback=self.graph.updateData)
        self.shapeCombo = OWGUI.comboBox(graph, self, "graph.ShapeAttr",
                                         box="Shape",
                                         callback=self.graph.updateData)
        self.nameCombo = OWGUI.comboBox(graph, self, "graph.NameAttr",
                                        box="Label",
                                        callback=self.graph.updateData)

        box = OWGUI.widgetBox(graph, "Distances & Stress")

        OWGUI.checkBox(box, self, "graph.ShowStress", "Show similar pairs",
                       callback=self.graph.updateLinesRepaint)
        b2 = OWGUI.widgetBox(box)
        OWGUI.widgetLabel(b2, "Proportion of connected pairs")
        OWGUI.separator(b2, height=3)
        OWGUI.hSlider(b2, self, "graph.proportionGraphed", minValue=0,
                      maxValue=20,
                      callback=self.graph.updateLinesRepaint,
                      tooltip=("Proportion of connected pairs (Maximum of "
                               "1000 lines will be drawn"))
        OWGUI.checkBox(box, self, "graph.differentWidths",
                       "Show distance by line width",
                       callback=self.graph.updateLinesRepaint)
        OWGUI.checkBox(box, self, "graph.stressByTransparency",
                       "Show stress by transparency",
                       callback=self.graph.updateData)
        OWGUI.checkBox(box, self, "graph.stressBySize",
                       "Show stress by symbol size",
                       callback=self.updateStressBySize)
        self.updateStressBySize(True)

        OWGUI.checkBox(graph, self, "graph.useAntialiasing",
                       label="Use antialiasing",
                       box="Antialiasing",
                       tooltip="Use antialiasing for beter quality graphics",
                       callback=self.graph.updateData)

        self.zoomToolbar = OWToolbars.ZoomSelectToolbar(
            self, graph, self.graph, self.autoSendSelection
        )

        self.connect(self.zoomToolbar.buttonSendSelections,
                     SIGNAL("clicked()"),
                     self.sendSelections)
        self.graph.autoSendSelectionCallback = \
            lambda: self.autoSendSelection and self.sendSelections()

        OWGUI.checkBox(graph, self, "autoSendSelection", "Auto send selected")
        OWGUI.radioButtonsInBox(graph, self, "selectionOptions",
                                ["Don't append", "Append coordinates",
                                 "Append coordinates as meta"],
                                box="Append coordinates",
                                callback=self.sendIf)

        mds.setSizePolicy(
            QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
        )
        graph.setSizePolicy(
            QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
        )

        self.controlArea.setMinimumWidth(250)

        OWGUI.rubber(mds)
        OWGUI.rubber(graph)

        infoBox = OWGUI.widgetBox(mds, "Info")
        self.infoA = OWGUI.widgetLabel(infoBox, "Avg. stress:")
        self.infoB = OWGUI.widgetLabel(infoBox, "Num. steps")

        self.connect(self.graphButton,
                     SIGNAL("clicked()"),
                     self.graph.saveToFile)

        self.resize(900, 630)

        self.done = True
        self.data = None
        self.selectedInputExamples = []
        self.selectedInput = []
Ejemplo n.º 49
0
    def __init__(self, parent=None, signalManager=None):
        "Constructor"
        OWWidget.__init__(self, parent, signalManager, "&Distributions", TRUE)
        # settings
        self.numberOfBars = 5
        self.barSize = 50
        self.showContinuousClassGraph = 1
        self.showProbabilities = 1
        self.showConfidenceIntervals = 0
        self.smoothLines = 0
        self.lineWidth = 1
        self.showMainTitle = 0
        self.showXaxisTitle = 1
        self.showYaxisTitle = 1
        self.showYPaxisTitle = 1

        self.attribute = ""
        self.targetValue = 0
        self.visibleOutcomes = []
        self.outcomes = []

        # tmp values
        self.mainTitle = ""
        self.xaxisTitle = ""
        self.yaxisTitle = "frequency"
        self.yPaxisTitle = ""

        # GUI
        self.tabs = OWGUI.tabWidget(self.controlArea)
        self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main")
        self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings")

        self.graph = OWDistributionGraph(self, self.mainArea)
        self.mainArea.layout().addWidget(self.graph)
        self.graph.setYRlabels(None)
        self.graph.setAxisScale(QwtPlot.yRight, 0.0, 1.0, 0.1)
        self.connect(self.graphButton, SIGNAL("clicked()"),
                     self.graph.saveToFile)

        self.loadSettings()

        # inputs
        # data and graph temp variables
        self.inputs = [("Examples", ExampleTable, self.setData, Default)]

        self.data = None
        self.outcomenames = []
        self.probGraphValues = []

        # GUI connections
        # options dialog connections
        self.numberOfBarsSlider = OWGUI.hSlider(self.SettingsTab,
                                                self,
                                                'numberOfBars',
                                                box='Number of bars',
                                                minValue=5,
                                                maxValue=60,
                                                step=5,
                                                callback=self.setNumberOfBars,
                                                ticks=5)
        self.numberOfBarsSlider.setTracking(
            0)  # no change until the user stop dragging the slider

        self.barSizeSlider = OWGUI.hSlider(self.SettingsTab,
                                           self,
                                           'barSize',
                                           box="Bar size",
                                           minValue=30,
                                           maxValue=100,
                                           step=5,
                                           callback=self.setBarSize,
                                           ticks=10)

        box = OWGUI.widgetBox(self.SettingsTab, "General graph settings")
        box.setMinimumWidth(180)
        box2 = OWGUI.widgetBox(box, orientation="horizontal")
        OWGUI.checkBox(box2,
                       self,
                       'showMainTitle',
                       'Show main title',
                       callback=self.setShowMainTitle)
        OWGUI.lineEdit(box2, self, 'mainTitle', callback=self.setMainTitle)

        box3 = OWGUI.widgetBox(box, orientation="horizontal")
        OWGUI.checkBox(box3,
                       self,
                       'showXaxisTitle',
                       'Show X axis title',
                       callback=self.setShowXaxisTitle)
        OWGUI.lineEdit(box3, self, 'xaxisTitle', callback=self.setXaxisTitle)

        box4 = OWGUI.widgetBox(box, orientation="horizontal")
        OWGUI.checkBox(box4,
                       self,
                       'showYaxisTitle',
                       'Show Y axis title',
                       callback=self.setShowYaxisTitle)
        OWGUI.lineEdit(box4, self, 'yaxisTitle', callback=self.setYaxisTitle)

        OWGUI.checkBox(box,
                       self,
                       'graph.showContinuousClassGraph',
                       'Show continuous class graph',
                       callback=self.setShowContinuousClassGraph)

        box5 = OWGUI.widgetBox(self.SettingsTab, "Probability plot")
        self.showProb = OWGUI.checkBox(box5,
                                       self,
                                       'showProbabilities',
                                       'Show probabilities',
                                       callback=self.setShowProbabilities)

        box6 = OWGUI.widgetBox(box5, orientation="horizontal")

        self.showYPaxisCheck = OWGUI.checkBox(box6,
                                              self,
                                              'showYPaxisTitle',
                                              'Show axis title',
                                              callback=self.setShowYPaxisTitle)
        self.yPaxisEdit = OWGUI.lineEdit(box6,
                                         self,
                                         'yPaxisTitle',
                                         callback=self.setYPaxisTitle)
        self.confIntCheck = OWGUI.checkBox(
            box5,
            self,
            'showConfidenceIntervals',
            'Show confidence intervals',
            callback=self.setShowConfidenceIntervals)
        self.showProb.disables = [
            self.showYPaxisCheck, self.yPaxisEdit, self.confIntCheck
        ]
        self.showProb.makeConsistent()

        OWGUI.checkBox(box5,
                       self,
                       'smoothLines',
                       'Smooth probability lines',
                       callback=self.setSmoothLines)

        self.barSizeSlider = OWGUI.hSlider(box5,
                                           self,
                                           'lineWidth',
                                           box='Line width',
                                           minValue=1,
                                           maxValue=9,
                                           step=1,
                                           callback=self.setLineWidth,
                                           ticks=1)

        #add controls to self.controlArea widget
        self.variablesQCB = OWGUI.comboBox(self.GeneralTab,
                                           self,
                                           "attribute",
                                           box="Variable",
                                           valueType=str,
                                           sendSelectedValue=True,
                                           callback=self.setVariable)
        self.targetQCB = OWGUI.comboBox(self.GeneralTab,
                                        self,
                                        "targetValue",
                                        box="Target value",
                                        valueType=int,
                                        callback=self.setTarget)
        self.outcomesQLB = OWGUI.listBox(
            self.GeneralTab,
            self,
            "visibleOutcomes",
            "outcomes",
            "Outcomes",
            selectionMode=QListWidget.MultiSelection,
            callback=self.outcomeSelectionChange)

        self.icons = self.createAttributeIconDict()

        self.graph.numberOfBars = self.numberOfBars
        self.graph.barSize = self.barSize
        self.graph.setShowMainTitle(self.showMainTitle)
        self.graph.setShowXaxisTitle(self.showXaxisTitle)
        self.graph.setShowYLaxisTitle(self.showYaxisTitle)
        self.graph.setShowYRaxisTitle(self.showYPaxisTitle)
        self.graph.setMainTitle(self.mainTitle)
        self.graph.setXaxisTitle(self.xaxisTitle)
        self.graph.setYLaxisTitle(self.yaxisTitle)
        self.graph.setYRaxisTitle(self.yPaxisTitle)
        self.graph.showProbabilities = self.showProbabilities
        self.graph.showConfidenceIntervals = self.showConfidenceIntervals
        self.graph.smoothLines = self.smoothLines
        self.graph.lineWidth = self.lineWidth
        #self.graph.variableContinuous = self.VariableContinuous
        self.graph.targetValue = self.targetValue
Ejemplo n.º 50
0
    def __init__(self,
                 parent=None,
                 signalManager=None,
                 name='Correspondence Analysis',
                 **kwargs):
        OWWidget.__init__(self, parent, signalManager, name, *kwargs)
        self.callbackDeposit = []

        self.inputs = [("Data", ExampleTable, self.dataset)]
        self.outputs = [("Selected data", ExampleTable)]
        self.recentFiles = []

        self.data = None
        self.CA = None
        self.CAloaded = False
        self.colors = ColorPaletteHSV(2)

        #Locals
        self.showGridlines = 0
        self.autoSendSelection = 0
        self.toolbarSelection = 0
        self.percRadius = 5

        self.colorSettings = None

        # GUI
        self.tabs = OWGUI.tabWidget(
            self.controlArea)  #QTabWidget(self.controlArea, 'tabWidget')
        self.GeneralTab = OWGUI.createTabPage(self.tabs,
                                              "General")  #QVGroupBox(self)
        self.SettingsTab = OWGUI.createTabPage(self.tabs,
                                               "Settings")  #QVGroupBox(self)
        #        self.tabs.insertTab(self.GeneralTab, "General")
        #        self.tabs.insertTab(self.SettingsTab, "Settings")

        #        layout = QVBoxLayout(self.mainArea)
        self.tabsMain = OWGUI.tabWidget(
            self.mainArea)  #QTabWidget(self.mainArea, 'tabWidgetMain')

        #        layout.addWidget(self.tabsMain)

        # ScatterPlot
        self.graph = OWCorrAnalysisGraph(None, "ScatterPlot")
        #        self.tabsMain.insertTab(self.graph, "Scatter Plot")
        OWGUI.createTabPage(self.tabsMain, "Scatter Plot", self.graph)

        self.icons = self.createAttributeIconDict()

        self.textData = False
        if textCorpusModul:
            OWGUI.checkBox(self.GeneralTab,
                           self,
                           'textData',
                           'Textual data',
                           callback=self.initAttrValues)

        #col attribute
        self.attrCol = ""
        self.attrColCombo = OWGUI.comboBox(self.GeneralTab,
                                           self,
                                           "attrCol",
                                           " Column table attribute ",
                                           callback=self.updateTables,
                                           sendSelectedValue=1,
                                           valueType=str)

        # row attribute
        self.attrRow = ""
        self.attrRowCombo = OWGUI.comboBox(self.GeneralTab,
                                           self,
                                           "attrRow",
                                           "Row table attribute ",
                                           callback=self.updateTables,
                                           sendSelectedValue=1,
                                           valueType=str)

        #x principal axis
        self.attrX = 0
        self.attrXCombo = OWGUI.comboBox(self.GeneralTab,
                                         self,
                                         "attrX",
                                         " Principal axis X ",
                                         callback=self.contributionBox,
                                         sendSelectedValue=1,
                                         valueType=str)

        #y principal axis
        self.attrY = 0
        self.attrYCombo = OWGUI.comboBox(self.GeneralTab,
                                         self,
                                         "attrY",
                                         " Principal axis Y ",
                                         callback=self.contributionBox,
                                         sendSelectedValue=1,
                                         valueType=str)

        contribution = OWGUI.widgetBox(
            self.GeneralTab, 'Contribution to inertia'
        )  #QVGroupBox('Contribution to inertia', self.GeneralTab)
        self.firstAxis = OWGUI.widgetLabel(contribution,
                                           'Axis %d: %f%%' % (1, 10))
        self.secondAxis = OWGUI.widgetLabel(contribution,
                                            'Axis %d: %f%%' % (2, 10))

        sliders = OWGUI.widgetBox(
            self.GeneralTab, 'Percentage of points'
        )  #QVGroupBox('Percentage of points', self.GeneralTab)
        OWGUI.widgetLabel(sliders, 'Row points')
        self.percRow = 100
        self.rowSlider = OWGUI.hSlider(sliders,
                                       self,
                                       'percRow',
                                       minValue=1,
                                       maxValue=100,
                                       step=10,
                                       callback=self.updateGraph)
        OWGUI.widgetLabel(sliders, 'Column points')
        self.percCol = 100
        self.colSlider = OWGUI.hSlider(sliders,
                                       self,
                                       'percCol',
                                       minValue=1,
                                       maxValue=100,
                                       step=10,
                                       callback=self.updateGraph)

        #zooming
        #        self.zoomSelectToolbar = ZoomBrowseSelectToolbar(self, self.GeneralTab, self.graph, self.autoSendSelection)
        self.zoomSelectToolbar = OWToolbars.ZoomSelectToolbar(
            self, self.GeneralTab, self.graph, self.autoSendSelection)

        self.connect(self.zoomSelectToolbar.buttonSendSelections,
                     SIGNAL("clicked()"), self.sendSelections)
        #        self.connect(self.graph, SIGNAL('plotMousePressed(const QMouseEvent&)'), self.sendSelections)

        OWGUI.button(self.GeneralTab, self, 'Update Graph', self.buttonUpdate)

        OWGUI.button(self.GeneralTab, self, 'Save graph',
                     self.graph.saveToFile)
        OWGUI.button(self.GeneralTab, self, 'Save CA', self.saveCA)
        OWGUI.button(self.GeneralTab, self, 'Load CA', self.loadCA)
        self.chosenSelection = []
        self.selections = []
        OWGUI.listBox(self.GeneralTab,
                      self,
                      "chosenSelection",
                      "selections",
                      box="Feature selection used",
                      selectionMode=QListWidget.MultiSelection,
                      callback=None)
        # ####################################
        # SETTINGS TAB
        # point width
        OWGUI.hSlider(self.SettingsTab,
                      self,
                      'graph.pointWidth',
                      box=' Point size ',
                      minValue=1,
                      maxValue=20,
                      step=1,
                      callback=self.replotCurves)
        OWGUI.hSlider(self.SettingsTab,
                      self,
                      'graph.brushAlpha',
                      box=' Transparancy ',
                      minValue=1,
                      maxValue=255,
                      step=1,
                      callback=self.replotCurves)

        # general graph settings
        box4 = OWGUI.widgetBox(self.SettingsTab, " General graph settings ")
        OWGUI.checkBox(box4,
                       self,
                       'graph.showXaxisTitle',
                       'X-axis title',
                       callback=self.updateGraph)
        OWGUI.checkBox(box4,
                       self,
                       'graph.showYLaxisTitle',
                       'Y-axis title',
                       callback=self.updateGraph)
        ##        OWGUI.checkBox(box4, self, 'graph.showAxisScale', 'Show axis scale', callback = self.updateGraph)
        OWGUI.checkBox(box4,
                       self,
                       'graph.showLegend',
                       'Show legend',
                       callback=self.updateGraph)
        OWGUI.checkBox(box4,
                       self,
                       'graph.showFilledSymbols',
                       'Show filled symbols',
                       callback=self.updateGraph)
        OWGUI.checkBox(box4,
                       self,
                       'showGridlines',
                       'Show gridlines',
                       callback=self.setShowGridlines)
        ##        OWGUI.checkBox(box4, self, 'graph.showClusters', 'Show clusters', callback = self.updateGraph, tooltip = "Show a line boundary around a significant cluster")
        OWGUI.checkBox(box4,
                       self,
                       'graph.showRowLabels',
                       'Show row labels',
                       callback=self.updateGraph)
        OWGUI.checkBox(box4,
                       self,
                       'graph.showColumnLabels',
                       'Show column labels',
                       callback=self.updateGraph)

        self.colorButtonsBox = OWGUI.widgetBox(self.SettingsTab,
                                               " Colors ",
                                               orientation="horizontal")
        OWGUI.button(
            self.colorButtonsBox,
            self,
            "Set Colors",
            self.setColors,
            tooltip=
            "Set the canvas background color, grid color and color palette for coloring continuous variables",
            debuggingEnabled=0)

        #browsing radius
        OWGUI.hSlider(self.SettingsTab,
                      self,
                      'percRadius',
                      box=' Browsing curve size ',
                      minValue=0,
                      maxValue=100,
                      step=5,
                      callback=self.calcRadius)

        #font size
        OWGUI.hSlider(self.SettingsTab,
                      self,
                      'graph.labelSize',
                      box=' Set font size for labels ',
                      minValue=8,
                      maxValue=48,
                      step=1,
                      callback=self.updateGraph)

        OWGUI.hSlider(self.SettingsTab,
                      self,
                      'graph.maxPoints',
                      box=' Maximum number of points ',
                      minValue=10,
                      maxValue=40,
                      step=1,
                      callback=None)

        OWGUI.rubber(self.SettingsTab)

        #        self.resultsTab = QVGroupBox(self, "Results")
        #        self.tabsMain.insertTab(self.resultsTab, "Results")
        self.resultsTab = OWGUI.createTabPage(
            self.tabsMain, "Results",
            OWGUI.widgetBox(self, "Results", addToLayout=False))
        self.chosenDoc = []
        self.docs = self.graph.docs
        OWGUI.listBox(self.resultsTab,
                      self,
                      "chosenDoc",
                      "docs",
                      box="Documents",
                      callback=None)
        self.chosenFeature = []
        self.features = self.graph.features
        OWGUI.listBox(self.resultsTab,
                      self,
                      "chosenFeature",
                      "features",
                      box="Features",
                      selectionMode=QListWidget.MultiSelection,
                      callback=None)
        OWGUI.button(self.resultsTab,
                     self,
                     "Save selected features",
                     callback=self.saveFeatures)
        OWGUI.button(self.resultsTab,
                     self,
                     "Reconstruct words from letter ngrams",
                     callback=self.reconstruct)
        self.chosenWord = []
        self.words = []
        OWGUI.listBox(self.resultsTab,
                      self,
                      "chosenWord",
                      "words",
                      box="Suggested words",
                      callback=None)

        dlg = self.createColorDialog()
        self.graph.contPalette = dlg.getContinuousPalette("contPalette")
        self.graph.discPalette = dlg.getDiscretePalette("discPalette")
        self.graph.setCanvasBackground(dlg.getColor("Canvas"))
        self.graph.setGridColor(QPen(dlg.getColor("Grid")))

        self.graph.enableGridXB(self.showGridlines)
        self.graph.enableGridYL(self.showGridlines)

        #        apply([self.zoomSelectToolbar.actionZooming, self.zoomSelectToolbar.actionRectangleSelection, self.zoomSelectToolbar.actionPolygonSelection, self.zoomSelectToolbar.actionBrowse, self.zoomSelectToolbar.actionBrowseCircle][self.toolbarSelection], [])

        self.resize(700, 800)
Ejemplo n.º 51
0
 def _slider(self, widget, value, label, min_value, max_value, step, cb_name):
     OWGUI.hSlider(widget, self._plot, value, label=label, minValue=min_value, maxValue=max_value, step=step, callback=self._get_callback(cb_name))
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, 'SampleData', wantMainArea = 0)

        self.inputs = [("Data", ExampleTable, self.setData)]
        self.outputs = [("Data Sample", ExampleTable), ("Remaining Data", ExampleTable)]

        # initialization of variables
        self.data = None                        # dataset (incoming stream)
        self.indices = None                     # indices that control sampling
        self.ind = None                         # indices that control sampling

        self.Stratified = 1                     # use stratified sampling if possible?
        self.Repeat = 0                         # can elements repeat in a sample?
        self.UseSpecificSeed = 0                # use a specific random seed?
        self.RandomSeed = 1                     # specific seed used
        self.GroupSeed = 1                      # current seed for multiple group selection
        self.outFold = 1                        # folder/group to output
        self.Folds = 1                          # total number of folds/groups

        self.SelectType = 0                     # sampling type (LOO, CV, ...)
        self.useCases = 0                       # use a specific number of cases?
        self.nCases = 25                        # number of cases to use
        self.selPercentage = 30                 # sample size in %
        self.LOO = 1                            # use LOO?
        self.CVFolds = 10                       # number of CV folds
        self.CVFoldsInternal = 10               # number of CV folds (for internal use)
        self.nGroups = 3                        # number of groups
        self.pGroups = [0.1,0.25,0.5]           # sizes of groups
        self.GroupText = '0.1,0.25,0.5'         # assigned to Groups Control (for internal use)

        self.loadSettings()
        # GUI
        
        # Info Box
        box1 = OWGUI.widgetBox(self.controlArea, "Information", addSpace=True)
        self.infoa = OWGUI.widgetLabel(box1, 'No data on input.')
        self.infob = OWGUI.widgetLabel(box1, ' ')
        self.infoc = OWGUI.widgetLabel(box1, ' ')
        
        # Options Box
        box2 = OWGUI.widgetBox(self.controlArea, 'Options', addSpace=True)
        OWGUI.checkBox(box2, self, 'Stratified', 'Stratified (if possible)', callback=self.settingsChanged)
        OWGUI.checkWithSpin(box2, self, 'Set random seed:', 0, 32767, 'UseSpecificSeed', 'RandomSeed', checkCallback=self.settingsChanged, spinCallback=self.settingsChanged)

        # Sampling Type Box
        self.s = [None, None, None, None]
        self.sBox = OWGUI.widgetBox(self.controlArea, "Sampling type", addSpace=True)
        self.sBox.buttons = []

        # Random Sampling
        self.s[0] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", 'Random sampling')
        
        # indent 
        indent = sep=OWGUI.checkButtonOffsetHint(self.s[0])
        # repeat checkbox
        self.h1Box = OWGUI.indentedBox(self.sBox, sep=indent, orientation = "horizontal")
        OWGUI.checkBox(self.h1Box, self, 'Repeat', 'With replacement', callback=self.settingsChanged)

        # specified number of elements checkbox
        self.h2Box = OWGUI.indentedBox(self.sBox, sep=indent, orientation = "horizontal")
        OWGUI.checkWithSpin(self.h2Box, self, 'Sample size (instances):', 1, 1000000000, 'useCases', 'nCases', checkCallback=[self.uCases, self.settingsChanged], spinCallback=self.settingsChanged)
        OWGUI.rubber(self.h2Box)
        
        # percentage slider
        self.h3Box = OWGUI.indentedBox(self.sBox, sep=indent, orientation = "horizontal")
        OWGUI.widgetLabel(self.h3Box, "Sample size:")
        self.slidebox = OWGUI.indentedBox(self.sBox, sep=indent, orientation = "horizontal")
        OWGUI.hSlider(self.slidebox, self, 'selPercentage', minValue=1, maxValue=100, step=1, ticks=10, labelFormat="   %d%%", callback=self.settingsChanged)

        # Cross Validation
        self.s[1] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", 'Cross validation')
        
        box = OWGUI.indentedBox(self.sBox, sep=indent, orientation = "horizontal")
        OWGUI.spin(box, self, 'CVFolds', 2, 100, step=1, label='Number of folds:  ', callback=[self.changeCombo, self.settingsChanged])
        OWGUI.rubber(box)

        # Leave-One-Out
        self.s[2] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", 'Leave-one-out')

        # Multiple Groups
        self.s[3] = OWGUI.appendRadioButton(self.sBox, self, "SelectType", 'Multiple subsets')
        gbox = OWGUI.indentedBox(self.sBox, sep=indent, orientation = "horizontal")
        OWGUI.lineEdit(gbox, self, 'GroupText', label='Subset sizes (e.g. "0.1, 0.2, 0.5"):', callback=self.multipleChanged)

        # Output Group Box
        self.foldcombo = OWGUI.comboBox(self.controlArea, self, "outFold", 'Output Data for Fold / Group', 'Fold / group:', orientation = "horizontal", items = range(1,101), callback = self.foldChanged, sendSelectedValue = 1, valueType = int)
        self.foldcombo.setEnabled(False)

        # Select Data Button
        OWGUI.rubber(self.controlArea)
        self.sampleButton = OWGUI.button(self.controlArea, self, 'Sample &Data', callback = self.process, addToLayout=False, default=True)
        self.buttonBackground.layout().setDirection(QBoxLayout.TopToBottom)
        self.buttonBackground.layout().insertWidget(0, self.sampleButton)
        self.buttonBackground.show()
        self.s[self.SelectType].setChecked(True)    # set initial radio button on (default sample type)

        # CONNECTIONS
        # set connections for RadioButton (SelectType)
        self.dummy1 = [None]*len(self.s)
        for i in range(len(self.s)):
            self.dummy1[i] = lambda x, v=i: self.sChanged(x, v)
            self.connect(self.s[i], SIGNAL("toggled(bool)"), self.dummy1[i])

        # final touch
        self.resize(200, 275)