Ejemplo n.º 1
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, 'SampleDataC')
        
        self.inputs = [("Data", Orange.data.Table, self.set_data)]
# [start-snippet-1]
        self.outputs = [("Sampled Data", Orange.data.Table),
                        ("Other Data", Orange.data.Table)]
# [end-snippet-1]
        self.proportion = 50
        self.commitOnChange = 0
        self.loadSettings()

        # GUI
        box = OWGUI.widgetBox(self.controlArea, "Info")
        self.infoa = OWGUI.widgetLabel(box, 'No data on input yet, waiting to get something.')
        self.infob = OWGUI.widgetLabel(box, '')

        OWGUI.separator(self.controlArea)
        self.optionsBox = OWGUI.widgetBox(self.controlArea, "Options")
        OWGUI.spin(self.optionsBox, self, 'proportion', min=10, max=90, step=10,
                   label='Sample Size [%]:', callback=[self.selection, self.checkCommit])
        OWGUI.checkBox(self.optionsBox, self, 'commitOnChange', 'Commit data on selection change')
        OWGUI.button(self.optionsBox, self, "Commit", callback=self.commit)
        self.optionsBox.setDisabled(1)

        self.resize(100,50)
Ejemplo n.º 2
0
 def __init__(self, parent=None, signalManager=None, title="Gaussin Mixture"):
     OWWidget.__init__(self, parent, signalManager, title)
     
     self.inputs = [("Data", Orange.data.Table, self.set_data)]
     self.outputs = [("Data with Indicator Matrix", Orange.data.Table)]
     
     self.init_method = 0
     self.n = 3
     self.auto_commit = True
     
     self.loadSettings()
     
     #####
     # GUI
     #####
     
     OWGUI.spin(self.controlArea, self, "n", min=1, max=10, step=1,
                box="Settings",
                label="Number of gaussians", 
                tooltip="The number of gaussians in the mixture ",
                callback=self.on_params_changed)
     
     OWGUI.comboBox(self.controlArea, self, "init_method",
                    box="Initialization",
                    items=["K-means", "Random"],
                    tooltip="Method used to initialize the mixture", callback=self.on_params_changed)
     
     OWGUI.button(self.controlArea, self, "Apply", callback=self.commit)
Ejemplo n.º 3
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, 'SampleDataB')

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

        self.proportion = 50
        self.commitOnChange = 0
        self.loadSettings()

        # GUI
        box = OWGUI.widgetBox(self.controlArea, "Info")
        self.infoa = OWGUI.widgetLabel(
            box, 'No data on input yet, waiting to get something.')
        self.infob = OWGUI.widgetLabel(box, '')

        OWGUI.separator(self.controlArea)
        self.optionsBox = OWGUI.widgetBox(self.controlArea, "Options")
        OWGUI.spin(self.optionsBox,
                   self,
                   'proportion',
                   min=10,
                   max=90,
                   step=10,
                   label='Sample Size [%]:',
                   callback=[self.selection, self.checkCommit])
        OWGUI.checkBox(self.optionsBox, self, 'commitOnChange',
                       'Commit data on selection change')
        OWGUI.button(self.optionsBox, self, "Commit", callback=self.commit)
        self.optionsBox.setDisabled(1)

        self.resize(100, 50)
Ejemplo n.º 4
0
 def __init__(self, parent=None, signalManager=None, name="Ensemble"):
     OWWidget.__init__(self, parent, signalManager, name, wantMainArea=False)
     
     self.inputs = [("Learner", orange.Learner, self.setLearner), ("Data", ExampleTable, self.setData)]
     self.outputs = [("Learner", orange.Learner), ("Classifier", orange.Classifier)]
     
     self.method = 0
     self.t = 10
     
     self.loadSettings()
     
     box = OWGUI.radioButtonsInBox(self.controlArea, self, "method",
                                   [name for name, _ in self.METHODS], 
                                   box="Ensemble",
                                   callback=self.onChange)
     
     i_box = OWGUI.indentedBox(box, sep=OWGUI.checkButtonOffsetHint(box.buttons[0]))
     
     OWGUI.spin(i_box, self, "t", min=1, max=100, step=1, label="Number of created classifiers:")
     OWGUI.rubber(self.controlArea)
     OWGUI.button(self.controlArea, self, "&Apply", callback=self.commit)
     
     self.data = None
     self.learner = None
     
     self.resize(100, 100)
    def __init__(self, parent=None, signalManager=None, title="PLS Regression"):
        OWWidget.__init__(self, parent, signalManager, title, wantMainArea=False)
        
        self.inputs = [("Data", Orange.data.Table, self.set_data),
                       ("Preprocessor", PreprocessedLearner, self.set_preprocessor)]
        
        self.outputs = [("Learner", Orange.core.Learner), 
                        ("Predictor", Orange.core.Classifier)]
        
        
        ##########
        # Settings
        ##########
         
        self.name = "PLS Regression"
        self.n_comp = 2
        self.deflation_mode = "Regression"
        self.mode = "PLS"
        self.algorithm = "svd"
        
        self.loadSettings()
        #####
        # GUI
        #####
        
        box = OWGUI.widgetBox(self.controlArea, "Learner/Predictor Name",  
                              addSpace=True)
        
        OWGUI.lineEdit(box, self, "name",
                       tooltip="Name to use for the learner/predictor.")
        
        box = OWGUI.widgetBox(self.controlArea, "Settings", addSpace=True)
        
        OWGUI.spin(box, self, "n_comp", 2, 15, 1, 
                   label="Number of components:", 
                   tooltip="Number of components to keep.")
        
        OWGUI.comboBox(box, self, "deflation_mode", 
                       label="Deflation mode", 
                       items=["Regression", "Canonical"],
#                       tooltip="",
                       sendSelectedValue=True)
        
        OWGUI.comboBox(box, self, "mode", 
                       label="Mode", 
                       items=["PLS", "CCA"],
#                       tooltip="", 
                       sendSelectedValue=True)
        
        OWGUI.rubber(self.controlArea)
        
        OWGUI.button(self.controlArea, self, "&Apply",
                     callback=self.apply,
                     tooltip="Send the learner on",
                     autoDefault=True)
        
        self.data = None
        self.preprocessor = None
        
        self.apply()
Ejemplo n.º 6
0
    def __init__(self, parent=None, signalManager = None, name='Histogram'):
        OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0)

        self.callbackDeposit = []

        self.inputs = [("Data", Clusters, self.setData)]
        self.outputs = [("Histogram", Histograms)] # , ("Histograms", ExampleTable)]

        self.useLazyEvaluation = pynopticon.useLazyEvaluation
        
        # Settings
        self.name = name
	self.histogram = None
	self.bins = 200
        self.loadSettings()        

        self.data = None                    # input data set

        wbN = OWGUI.widgetBox(self.controlArea, "Histogram Settings")
        OWGUI.spin(wbN, self, "bins", 1, 100000, 100, None, "Number of bins  ", orientation="horizontal")

        OWGUI.separator(self.controlArea)
	wbS = OWGUI.widgetBox(self.controlArea, "Widget Settings")
        OWGUI.checkBox(wbS, self, "useLazyEvaluation", "Use lazy evaluation")
        OWGUI.button(self.controlArea, self, "&Apply Settings", callback = self.applySettings, disabled=0)

        self.resize(100,150)
Ejemplo n.º 7
0
    def addHistogramControls(self, parent=None):
        # set default settings
        self.spinLowerThreshold = 0
        self.spinLowerChecked = False
        self.spinUpperThreshold = 0
        self.spinUpperChecked = False
        self.netOption = 0
        self.dstWeight = 0
        self.kNN = 0
        self.andor = 0
        self.matrix = None
        self.excludeLimit = 2
        self.percentil = 0

        self.graph = None
        self.graph_matrix = None

        if parent is None:
            parent = self.controlArea

        boxGeneral = OWGUI.widgetBox(parent, box="Distance boundaries")

        ribg = OWGUI.widgetBox(boxGeneral, None, orientation="horizontal", addSpace=False)
        OWGUI.lineEdit(ribg, self, "spinLowerThreshold", "Lower", orientation='horizontal', callback=self.changeLowerSpin, valueType=float, enterPlaceholder=True, controlWidth=100)
        OWGUI.lineEdit(ribg, self, "spinUpperThreshold", "Upper    ", orientation='horizontal', callback=self.changeUpperSpin, valueType=float, enterPlaceholder=True, controlWidth=100)
        ribg.layout().addStretch(1)
        #ribg = OWGUI.radioButtonsInBox(boxGeneral, self, "andor", [], orientation='horizontal', callback = self.generateGraph)
        #OWGUI.appendRadioButton(ribg, self, "andor", "OR", callback = self.generateGraph)
        #b = OWGUI.appendRadioButton(ribg, self, "andor", "AND", callback = self.generateGraph)
        #b.setEnabled(False)
        #ribg.hide(False)

        ribg = OWGUI.widgetBox(boxGeneral, None, orientation="horizontal", addSpace=False)
        OWGUI.spin(ribg, self, "kNN", 0, 1000, 1, label="kNN   ", orientation='horizontal', callback=self.generateGraph, callbackOnReturn=1, controlWidth=100)
        OWGUI.doubleSpin(ribg, self, "percentil", 0, 100, 0.1, label="Percentile", orientation='horizontal', callback=self.setPercentil, callbackOnReturn=1, controlWidth=100)
        ribg.layout().addStretch(1)
        # Options
        self.attrColor = ""
        ribg = OWGUI.radioButtonsInBox(parent, self, "netOption", [], "Options", callback=self.generateGraph)
        OWGUI.appendRadioButton(ribg, self, "netOption", "All vertices", callback=self.generateGraph)
        hb = OWGUI.widgetBox(ribg, None, orientation="horizontal", addSpace=False)
        OWGUI.appendRadioButton(ribg, self, "netOption", "Large components only. Min nodes:", insertInto=hb, callback=self.generateGraph)
        OWGUI.spin(hb, self, "excludeLimit", 2, 100, 1, callback=(lambda h=True: self.generateGraph(h)))
        OWGUI.appendRadioButton(ribg, self, "netOption", "Largest connected component only", callback=self.generateGraph)
        OWGUI.appendRadioButton(ribg, self, "netOption", "Connected component with vertex")
        self.attribute = None
        self.attributeCombo = OWGUI.comboBox(parent, self, "attribute", box="Filter attribute", orientation='horizontal')#, callback=self.setVertexColor)

        ribg = OWGUI.radioButtonsInBox(parent, self, "dstWeight", [], "Distance -> Weight", callback=self.generateGraph)
        hb = OWGUI.widgetBox(ribg, None, orientation="horizontal", addSpace=False)
        OWGUI.appendRadioButton(ribg, self, "dstWeight", "Weight := distance", insertInto=hb, callback=self.generateGraph)
        OWGUI.appendRadioButton(ribg, self, "dstWeight", "Weight := 1 - distance", insertInto=hb, callback=self.generateGraph)

        self.label = ''
        self.searchString = OWGUI.lineEdit(self.attributeCombo.box, self, "label", callback=self.setSearchStringTimer, callbackOnType=True)
        self.searchStringTimer = QTimer(self)
        self.connect(self.searchStringTimer, SIGNAL("timeout()"), self.generateGraph)

        if str(self.netOption) != '3':
            self.attributeCombo.box.setEnabled(False)
Ejemplo n.º 8
0
    def __init__(self, parent=None, signalManager = None, name='Random Forests'):
        OWWidget.__init__(self, parent, signalManager, name)

        self.inputs = [("Examples", ExampleTable, self.setData)]
        self.outputs = [("Learner", orange.Learner),("Random Forests Classifier", orange.Classifier),("Choosen Tree", orange.TreeClassifier) ]

        self.name = 'Random Forests'
	self.trees = 10
	self.attributes = 0
	self.attributesP = 5
	self.preNodeInst = 1
	self.preNodeInstP = 5
	self.limitDepth = 0
	self.limitDepthP = 3
	self.rseed = 0
	self.outtree = 0


	self.maxTrees = 10000

        self.loadSettings()

        self.data = None
        self.preprocessor = None

        OWGUI.lineEdit(self.controlArea, self, 'name', box='Learner/Classifier Name', tooltip='Name to be used by other widgets to identify your learner/classifier.')

        OWGUI.separator(self.controlArea)

        self.bBox = QVGroupBox(self.controlArea)
        self.bBox.setTitle('Basic Properties')

        self.treesBox = OWGUI.spin(self.bBox, self, "trees", 1, self.maxTrees, orientation="horizontal", label="Number of trees in forest  ")
	self.attributesBox, self.attributesPBox = OWGUI.checkWithSpin(self.bBox, self, "Consider exactly", 1, 10000, "attributes", "attributesP", " random attributes at each split.")
        self.rseedBox = OWGUI.spin(self.bBox, self, "rseed", 0, 100000, orientation="horizontal", label="Seed for random generator ")

        OWGUI.separator(self.controlArea)

        self.pBox = QVGroupBox(self.controlArea)
        self.pBox.setTitle('Growth Control')

	self.limitDepthBox, self.limitDepthPBox = OWGUI.checkWithSpin(self.pBox, self, "Maximum depth of individual trees  ", 1, 1000, "limitDepth", "limitDepthP", "")
        self.preNodeInstBox, self.preNodeInstPBox = OWGUI.checkWithSpin(self.pBox, self, "Stop splitting nodes with ", 1, 1000, "preNodeInst", "preNodeInstP", " or fewer instances")

        OWGUI.separator(self.controlArea)

        #self.sBox = QVGroupBox(self.controlArea)
        #self.sBox.setTitle('Single Tree Output')

	self.streesBox = OWGUI.spin(self.controlArea, self, "outtree", -1, self.maxTrees, orientation="horizontal", label="Index of tree on the output ", callback=[self.period, self.extree])
	#self.streesBox.setDisabled(True)
	self.streeEnabled(False)

	OWGUI.separator(self.controlArea)

	self.btnApply = OWGUI.button(self.controlArea, self, "&Apply Changes", callback = self.setLearner, disabled=0)

        self.resize(100,200)

	self.setLearner()
Ejemplo n.º 9
0
    def __init__(self, parent=None):
        BaseEditor.__init__(self, parent)

        self.measureInd = 0
        self.selectBy = 0
        self.bestN = 10
        self.bestP = 10

        box = OWGUI.radioButtonsInBox(self,
                                      self,
                                      "selectBy", [],
                                      "Feature selection",
                                      callback=self.onChange)

        OWGUI.comboBox(box,
                       self,
                       "measureInd",
                       items=[name for (name, _) in self.MEASURES],
                       label="Measure",
                       callback=self.onChange)

        hbox1 = OWGUI.widgetBox(box, orientation="horizontal", margin=0)
        rb1 = OWGUI.appendRadioButton(box,
                                      self,
                                      "selectBy",
                                      "Best",
                                      insertInto=hbox1,
                                      callback=self.onChange)
        self.spin1 = OWGUI.spin(OWGUI.widgetBox(hbox1),
                                self,
                                "bestN",
                                1,
                                10000,
                                step=1,
                                controlWidth=75,
                                callback=self.onChange,
                                posttext="features")
        OWGUI.rubber(hbox1)

        hbox2 = OWGUI.widgetBox(box, orientation="horizontal", margin=0)
        rb2 = OWGUI.appendRadioButton(box,
                                      self,
                                      "selectBy",
                                      "Best",
                                      insertInto=hbox2,
                                      callback=self.onChange)
        self.spin2 = OWGUI.spin(OWGUI.widgetBox(hbox2),
                                self,
                                "bestP",
                                1,
                                100,
                                step=1,
                                controlWidth=75,
                                callback=self.onChange,
                                posttext="% features")
        OWGUI.rubber(hbox2)

        self.updateSpinStates()

        OWGUI.rubber(box)
Ejemplo n.º 10
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, 'LearningCurveA')
# [start-snippet-1]
        self.inputs = [("Data", Orange.data.Table, self.set_dataset),
                       ("Learner", Orange.classification.Learner, self.set_learner,
                        Multiple + Default)]
# [end-snippet-1]
        self.folds = 5     # cross validation folds
        self.steps = 10    # points in the learning curve
        self.scoringF = 0  # scoring function
        self.commitOnChange = 1 # compute curve on any change of parameters
        self.loadSettings()
        self.updateCurvePoints() # sets self.curvePoints, self.steps equidistant points from 1/self.steps to 1
# [start-snippet-2]
        self.scoring = [("Classification Accuracy", Orange.evaluation.scoring.CA),
                        ("AUC", Orange.evaluation.scoring.AUC),
                        ("BrierScore", Orange.evaluation.scoring.Brier_score),
                        ("Information Score", Orange.evaluation.scoring.IS),
                        ("Sensitivity", Orange.evaluation.scoring.Sensitivity),
                        ("Specificity", Orange.evaluation.scoring.Specificity)]
# [end-snippet-2]
        self.learners = [] # list of current learners from input channel, tuples (id, learner)
        self.data = None   # data on which to construct the learning curve
        self.curves = []   # list of evaluation results (one per learning curve point)
        self.scores = []   # list of current scores, learnerID:[learner scores]

        # GUI
        box = OWGUI.widgetBox(self.controlArea, "Info")
        self.infoa = OWGUI.widgetLabel(box, 'No data on input.')
        self.infob = OWGUI.widgetLabel(box, 'No learners.')

        OWGUI.separator(self.controlArea)

        box = OWGUI.widgetBox(self.controlArea, "Evaluation Scores")
        scoringNames = [x[0] for x in self.scoring]
        OWGUI.comboBox(box, self, "scoringF", items=scoringNames,
                       callback=self.computeScores)

        OWGUI.separator(self.controlArea)

        box = OWGUI.widgetBox(self.controlArea, "Options")
        OWGUI.spin(box, self, 'folds', 2, 100, step=1,
                   label='Cross validation folds:  ',
                   callback=lambda: self.computeCurve() if self.commitOnChange else None)
        OWGUI.spin(box, self, 'steps', 2, 100, step=1,
                   label='Learning curve points:  ',
                   callback=[self.updateCurvePoints,
                             lambda: self.computeCurve() if self.commitOnChange else None])
        OWGUI.checkBox(box, self, 'commitOnChange', 'Apply setting on any change')
        self.commitBtn = OWGUI.button(box, self, "Apply Setting",
                                      callback=self.computeCurve, disabled=1)

        OWGUI.rubber(self.controlArea)

        # table widget
        self.table = OWGUI.table(self.mainArea,
                                 selectionMode=QTableWidget.NoSelection)

        self.resize(500,200)
Ejemplo n.º 11
0
    def __init__(self, parent=None, signalManager=None, name='BR-kNN'):
        OWWidget.__init__(self,
                          parent,
                          signalManager,
                          name,
                          wantMainArea=0,
                          resizingEnabled=0)

        self.callbackDeposit = []

        self.inputs = [("Examples", ExampleTable, self.set_data),
                       ("Preprocess", PreprocessedLearner,
                        self.set_preprocessor)]
        self.outputs = [("Learner", orange.Learner),
                        ("BR-kNN Classifier",
                         Orange.multilabel.BRkNNClassifier)]

        # Settings
        self.name = 'BR-kNN'
        self.k = 1

        self.loadSettings()

        self.data = None  # input data set
        self.preprocessor = None  # no preprocessing as default
        self.set_learner()  # this just sets the learner, no data
        # has come to the input yet

        OWGUI.lineEdit(self.controlArea, self, 'name', box='Learner/Classifier Name', \
                 tooltip='Name to be used by other widgets to identify your learner/classifier.')

        OWGUI.separator(self.controlArea)

        wbN = OWGUI.widgetBox(self.controlArea, "Neighbours")
        OWGUI.spin(wbN,
                   self,
                   "k",
                   1,
                   100,
                   1,
                   None,
                   "Number of neighbours",
                   orientation="horizontal")

        OWGUI.separator(self.controlArea)

        OWGUI.button(self.controlArea,
                     self,
                     "&Apply",
                     callback=self.set_learner,
                     disabled=0,
                     default=True)

        OWGUI.rubber(self.controlArea)

        self.resize(100, 250)
Ejemplo n.º 12
0
    def __init__(self, parent=None):
        OWWidget.__init__(self, parent, title='Labels')

        self.val = 5
        self.line = "a parrot"

        OWGUI.spin(self.controlArea, self, "val", 1, 10, label="Value")
        OWGUI.lineEdit(self.controlArea, self, "line", label="Line: ", orientation="horizontal")

        OWGUI.label(self.controlArea, self, "Value is %(val)i and line edit contains %(line)s")        

        self.resize(100,100)
    def __init__ (self, parent=None, signalManager = None, name = "Logistic regression"):
        OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0, resizingEnabled = 0)

        self.inputs = [("Data", ExampleTable, self.setData), ("Preprocess", PreprocessedLearner, self.setPreprocessor)]
        self.outputs = [("Learner", orange.Learner), ("Classifier", orange.Classifier), ("Features", list)]

        from orngTree import TreeLearner
        imputeByModel = orange.ImputerConstructor_model()
        imputeByModel.learnerDiscrete = TreeLearner(measure = "infoGain", minSubset = 50)
        imputeByModel.learnerContinuous = TreeLearner(measure = "retis", minSubset = 50)
        self.imputationMethods = [imputeByModel, orange.ImputerConstructor_average(), orange.ImputerConstructor_minimal(), orange.ImputerConstructor_maximal(), None]
        self.imputationMethodsStr = ["Classification/Regression trees", "Average values", "Minimal value", "Maximal value", "None (skip examples)"]

        self.name = "Logistic regression"
        self.univariate = 0
        self.stepwiseLR = 0
        self.addCrit = 10
        self.removeCrit = 10
        self.numAttr = 10
        self.limitNumAttr = False
        self.zeroPoint = 0
        self.imputation = 1

        self.data = None
        self.preprocessor = None

        self.loadSettings()

        OWGUI.lineEdit(self.controlArea, self, 'name', box='Learner/Classifier Name', tooltip='Name to be used by other widgets to identify your learner/classifier.')
        OWGUI.separator(self.controlArea)

        box = OWGUI.widgetBox(self.controlArea, "Attribute selection")

        stepwiseCb = OWGUI.checkBox(box, self, "stepwiseLR", "Stepwise attribute selection")
        ibox = OWGUI.indentedBox(box, sep=OWGUI.checkButtonOffsetHint(stepwiseCb))
        addCritSpin = OWGUI.spin(ibox, self, "addCrit", 1, 50, label="Add threshold [%]", labelWidth=155, tooltip="Requested significance for adding an attribute")
        remCritSpin = OWGUI.spin(ibox, self, "removeCrit", 1, 50, label="Remove threshold [%]", labelWidth=155, tooltip="Requested significance for removing an attribute")
        limitAttSpin = OWGUI.checkWithSpin(ibox, self, "Limit number of attributes to ", 1, 100, "limitNumAttr", "numAttr", step=1, labelWidth=155, tooltip="Maximum number of attributes. Algorithm stops when it selects specified number of attributes.")
        stepwiseCb.disables += [addCritSpin, remCritSpin, limitAttSpin]
        stepwiseCb.makeConsistent()
        
        OWGUI.separator(self.controlArea)

        self.imputationCombo = OWGUI.comboBox(self.controlArea, self, "imputation", box="Imputation of unknown values", items=self.imputationMethodsStr)
        OWGUI.separator(self.controlArea)

        applyButton = OWGUI.button(self.controlArea, self, "&Apply", callback=self.applyLearner, default=True)

        OWGUI.rubber(self.controlArea)
        #self.adjustSize()

        self.applyLearner()
Ejemplo n.º 14
0
    def __init__(self, parent=None, signalManager = None, name='Random Forest'):
        OWWidget.__init__(self, parent, signalManager, name, wantMainArea=False, resizingEnabled=False)

        self.inputs = [("Data", ExampleTable, self.setData),
                       ("Preprocess", PreprocessedLearner, self.setPreprocessor)]
        
        self.outputs = [("Learner", orange.Learner),
                        ("Random Forest Classifier", orange.Classifier)]

        self.name = 'Random Forest'
        self.trees = 10
        self.attributes = 0
        self.attributesP = 5
        self.preNodeInst = 1
        self.preNodeInstP = 5
        self.limitDepth = 0
        self.limitDepthP = 3
        self.rseed = 0

        self.maxTrees = 10000

        self.loadSettings()

        self.data = None
        self.preprocessor = None

        OWGUI.lineEdit(self.controlArea, self, 'name', box='Learner/Classifier Name', tooltip='Name to be used by other widgets to identify your learner/classifier.')

        OWGUI.separator(self.controlArea)

        self.bBox = OWGUI.widgetBox(self.controlArea, 'Basic Properties')

        self.treesBox = OWGUI.spin(self.bBox, self, "trees", 1, self.maxTrees, orientation="horizontal", label="Number of trees in forest")
        self.attributesBox, self.attributesPBox = OWGUI.checkWithSpin(self.bBox, self, "Consider exactly", 1, 10000, "attributes", "attributesP", " "+"random attributes at each split.")
        self.rseedBox = OWGUI.spin(self.bBox, self, "rseed", 0, 100000, orientation="horizontal", label="Seed for random generator ")

        OWGUI.separator(self.controlArea)

        self.pBox = OWGUI.widgetBox(self.controlArea, 'Growth Control')

        self.limitDepthBox, self.limitDepthPBox = OWGUI.checkWithSpin(self.pBox, self, "Maximal depth of individual trees", 1, 1000, "limitDepth", "limitDepthP", "")
        self.preNodeInstBox, self.preNodeInstPBox = OWGUI.checkWithSpin(self.pBox, self, "Stop splitting nodes with ", 1, 1000, "preNodeInst", "preNodeInstP", " or fewer instances")

        OWGUI.separator(self.controlArea)

        OWGUI.separator(self.controlArea)

        self.btnApply = OWGUI.button(self.controlArea, self, "&Apply Changes", callback = self.doBoth, disabled=0, default=True)

        self.resize(100,200)

        self.setLearner()
    def __init__(self, parent=None, signalManager=None,
                 title="Earth"):
        OWWidget.__init__(self, parent, signalManager, title,
                          wantMainArea=False)

        self.inputs = [("Data", Orange.data.Table, self.set_data),
                       ("Preprocessor", PreprocessedLearner,
                        self.set_preprocessor)]

        self.outputs = [("Learner", earth.EarthLearner, Default),
                        ("Predictor", earth.EarthClassifier, Default),
                        ("Basis Matrix", Orange.data.Table)]

        self.name = "Earth Learner"
        self.degree = 1
        self.terms = 21
        self.penalty = 2

        self.loadSettings()

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

        OWGUI.lineEdit(self.controlArea, self, "name",
                       box="Learner/Classifier Name",
                       tooltip="Name for the learner/predictor")

        box = OWGUI.widgetBox(self.controlArea, "Forward Pass", addSpace=True)
        OWGUI.spin(box, self, "degree", 1, 3, step=1,
                   label="Max. term degree",
                   tooltip="Maximum degree of the terms derived "
                           "(number of hinge functions).")
        s = OWGUI.spin(box, self, "terms", 1, 200, step=1,
                       label="Max. terms",
                       tooltip="Maximum number of terms derived in the "
                               "forward pass.")
        s.control.setSpecialValueText("Automatic")

        box = OWGUI.widgetBox(self.controlArea, "Pruning Pass", addSpace=True)
        OWGUI.doubleSpin(box, self, "penalty", min=0.0, max=10.0, step=0.25,
                   label="Knot penalty")

        OWGUI.button(self.controlArea, self, "&Apply",
                     callback=self.apply)

        self.data = None
        self.preprocessor = None
        self.resize(300, 200)

        self.apply()
Ejemplo n.º 16
0
    def __init__(self, parent=None, signalManager = None, name='kNN'):
        OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0, resizingEnabled = 0)

        self.callbackDeposit = []

        self.inputs = [("Examples", ExampleTable, self.setData), ("Preprocess", PreprocessedLearner, self.setPreprocessor)]
        self.outputs = [("Learner", orange.Learner),("KNN Classifier", orange.kNNClassifier)]

        self.metricsList = [("Euclidean", orange.ExamplesDistanceConstructor_Euclidean),
                       ("Hamming", orange.ExamplesDistanceConstructor_Hamming),
                       ("Manhattan", orange.ExamplesDistanceConstructor_Manhattan),
                       ("Maximal", orange.ExamplesDistanceConstructor_Maximal),
#                       ("Dynamic time warp", orange.ExamplesDistanceConstructor_DTW)
                            ]

        # Settings
        self.name = 'kNN'
        self.k = 5;  self.metrics = 0; self.ranks = 0
        self.ignoreUnknowns = 0
        self.normalize = self.oldNormalize = 1
        self.loadSettings()

        self.data = None                    # input data set
        self.preprocessor = None            # no preprocessing as default
        self.setLearner()                   # this just sets the learner, no data
                                            # has come to the input yet

        OWGUI.lineEdit(self.controlArea, self, 'name', box='Learner/Classifier Name', \
                 tooltip='Name to be used by other widgets to identify your learner/classifier.')

        OWGUI.separator(self.controlArea)

        wbN = OWGUI.widgetBox(self.controlArea, "Neighbours")
        OWGUI.spin(wbN, self, "k", 1, 100, 1, None, "Number of neighbours   ", orientation="horizontal")
        OWGUI.checkBox(wbN, self, "ranks", "Weighting by ranks, not distances")

        OWGUI.separator(self.controlArea)

        wbM = OWGUI.widgetBox(self.controlArea, "Metrics")
        OWGUI.comboBox(wbM, self, "metrics", items = [x[0] for x in self.metricsList], valueType = int, callback = self.metricsChanged)
        self.cbNormalize = OWGUI.checkBox(wbM, self, "normalize", "Normalize continuous attributes")
        OWGUI.checkBox(wbM, self, "ignoreUnknowns", "Ignore unknown values")
        self.metricsChanged()

        OWGUI.separator(self.controlArea)

        OWGUI.button(self.controlArea, self, "&Apply", callback = self.setLearner, disabled=0)
        
        OWGUI.rubber(self.controlArea)

        self.resize(100,250)
Ejemplo n.º 17
0
    def __init__(self, parent=None, signalManager = None, name='kNN'):
        OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0, resizingEnabled = 0)

        self.callbackDeposit = []

        self.inputs = [("Data", ExampleTable, self.setData), ("Preprocess", PreprocessedLearner, self.setPreprocessor)]
        self.outputs = [("Learner", orange.Learner),("kNN Classifier", orange.kNNClassifier)]

        self.metricsList = [("Euclidean", orange.ExamplesDistanceConstructor_Euclidean),
                       ("Hamming", orange.ExamplesDistanceConstructor_Hamming),
                       ("Manhattan", orange.ExamplesDistanceConstructor_Manhattan),
                       ("Maximal", orange.ExamplesDistanceConstructor_Maximal),
#                       ("Dynamic time warp", orange.ExamplesDistanceConstructor_DTW)
                            ]

        # Settings
        self.name = 'kNN'
        self.k = 5;  self.metrics = 0; self.ranks = 0
        self.ignoreUnknowns = 0
        self.normalize = self.oldNormalize = 1
        self.loadSettings()

        self.data = None                    # input data set
        self.preprocessor = None            # no preprocessing as default
        self.setLearner()                   # this just sets the learner, no data
                                            # has come to the input yet

        OWGUI.lineEdit(self.controlArea, self, 'name', box='Learner/Classifier Name', \
                 tooltip='Name to be used by other widgets to identify your learner/classifier.')

        OWGUI.separator(self.controlArea)

        wbN = OWGUI.widgetBox(self.controlArea, "Neighbours")
        OWGUI.spin(wbN, self, "k", 1, 100, 1, None, "Number of neighbours   ", orientation="horizontal")
        OWGUI.checkBox(wbN, self, "ranks", "Weighting by ranks, not distances")

        OWGUI.separator(self.controlArea)

        wbM = OWGUI.widgetBox(self.controlArea, "Metrics")
        OWGUI.comboBox(wbM, self, "metrics", items = [x[0] for x in self.metricsList], valueType = int, callback = self.metricsChanged)
        self.cbNormalize = OWGUI.checkBox(wbM, self, "normalize", "Normalize continuous attributes")
        OWGUI.checkBox(wbM, self, "ignoreUnknowns", "Ignore unknown values")
        self.metricsChanged()

        OWGUI.separator(self.controlArea)

        OWGUI.button(self.controlArea, self, "&Apply", callback=self.setLearner, disabled=0, default=True)
        
        OWGUI.rubber(self.controlArea)

        self.resize(100,250)
Ejemplo n.º 18
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, "Pubmed Network View", wantMainArea=0)

        self.inputs = []
        self.outputs = [("Nx View", Orange.network.NxView)]

        self._nhops = 2
        self._edge_threshold = 0.5
        self._n_max_neighbors = 20
        self.selected_titles = []
        self.titles = []
        self.filter = ""
        self.ids = []
        self._selected_nodes = []
        self._algorithm = 0
        self._k_algorithm = 0.3

        self.loadSettings()

        box = OWGUI.widgetBox(self.controlArea, "Paper Selection", orientation="vertical")
        OWGUI.lineEdit(box, self, "filter", callback=self.filter_list, callbackOnType=True)
        self.list_titles = OWGUI.listBox(
            box, self, "selected_titles", "titles", selectionMode=QListWidget.MultiSelection, callback=self.update_view
        )
        OWGUI.separator(self.controlArea)
        box_pref = OWGUI.widgetBox(self.controlArea, "Preferences", orientation="vertical")
        OWGUI.spin(box_pref, self, "_nhops", 1, 6, 1, label="Number of hops: ", callback=self.update_view)
        OWGUI.spin(
            box_pref, self, "_n_max_neighbors", 1, 100, 1, label="Max number of neighbors: ", callback=self.update_view
        )
        OWGUI.doubleSpin(
            box_pref, self, "_edge_threshold", 0, 1, step=0.01, label="Edge threshold: ", callback=self.update_view
        )
        OWGUI.separator(self.controlArea)
        box_alg = OWGUI.widgetBox(self.controlArea, "Interest Propagation Algorithm", orientation="vertical")
        radio_box = OWGUI.radioButtonsInBox(box_alg, self, "_algorithm", [], callback=self.update_view)
        OWGUI.appendRadioButton(radio_box, self, "_algorithm", "Without Clustering", callback=self.update_view)
        OWGUI.doubleSpin(
            OWGUI.indentedBox(radio_box),
            self,
            "_k_algorithm",
            0,
            1,
            step=0.01,
            label="Parameter k: ",
            callback=self.update_view,
        )
        OWGUI.appendRadioButton(radio_box, self, "_algorithm", "With Clustering", callback=self.update_view)

        self.inside_view = PubmedNetworkView(self)
        self.send("Nx View", self.inside_view)
Ejemplo n.º 19
0
 def addHistogramControls(self, parent=None):
     # set default settings
     self.spinLowerThreshold = 0
     self.spinLowerChecked = False
     self.spinUpperThreshold = 0
     self.spinUpperChecked = False
     self.netOption = 0
     self.dstWeight = 0
     self.kNN = 0
     self.andor = 0
     self.matrix = None
     self.excludeLimit = 1
     self.percentil = 0
     
     if parent is None:
         parent = self.controlArea
         
     boxGeneral = OWGUI.widgetBox(parent, box = "Distance boundaries")
     
     OWGUI.lineEdit(boxGeneral, self, "spinLowerThreshold", "Lower:", orientation='horizontal', callback=self.changeLowerSpin, valueType=float)
     OWGUI.lineEdit(boxGeneral, self, "spinUpperThreshold", "Upper:", orientation='horizontal', callback=self.changeUpperSpin, valueType=float)
     ribg = OWGUI.radioButtonsInBox(boxGeneral, self, "andor", [], orientation='horizontal', callback = self.generateGraph)
     OWGUI.appendRadioButton(ribg, self, "andor", "OR", callback = self.generateGraph)
     b = OWGUI.appendRadioButton(ribg, self, "andor", "AND", callback = self.generateGraph)
     b.setEnabled(False)
     OWGUI.spin(boxGeneral, self, "kNN", 0, 1000, 1, label="kNN:", orientation='horizontal', callback=self.generateGraph)
     OWGUI.doubleSpin(boxGeneral, self, "percentil", 0, 100, 0.1, label="Percentil:", orientation='horizontal', callback=self.setPercentil, callbackOnReturn=1)
     
     # Options
     self.attrColor = ""
     ribg = OWGUI.radioButtonsInBox(parent, self, "netOption", [], "Options", callback = self.generateGraph)
     OWGUI.appendRadioButton(ribg, self, "netOption", "All vertices", callback = self.generateGraph)
     OWGUI.appendRadioButton(ribg, self, "netOption", "Exclude small components", callback = self.generateGraph)
     OWGUI.spin(OWGUI.indentedBox(ribg), self, "excludeLimit", 1, 100, 1, label="Less vertices than: ", callback = (lambda h=True: self.generateGraph(h)))
     OWGUI.appendRadioButton(ribg, self, "netOption", "Largest connected component only", callback = self.generateGraph)
     OWGUI.appendRadioButton(ribg, self, "netOption", "Connected component with vertex")
     self.attribute = None
     self.attributeCombo = OWGUI.comboBox(ribg, self, "attribute", box = "Filter attribute")#, callback=self.setVertexColor)
     
     ribg = OWGUI.radioButtonsInBox(parent, self, "dstWeight", [], "Distance -> Weight", callback = self.generateGraph)
     OWGUI.appendRadioButton(ribg, self, "dstWeight", "Weight := distance", callback = self.generateGraph)
     OWGUI.appendRadioButton(ribg, self, "dstWeight", "Weight := 1 - distance", callback = self.generateGraph)
     
     self.label = ''
     self.searchString = OWGUI.lineEdit(self.attributeCombo.box, self, "label", callback=self.setSearchStringTimer, callbackOnType=True)
     self.searchStringTimer = QTimer(self)
     self.connect(self.searchStringTimer, SIGNAL("timeout()"), self.generateGraph)
     
     if str(self.netOption) != '3':
         self.attributeCombo.box.setEnabled(False)
Ejemplo n.º 20
0
 def addHistogramControls(self, parent=None):
     # set default settings
     self.spinLowerThreshold = 0
     self.spinLowerChecked = False
     self.spinUpperThreshold = 0
     self.spinUpperChecked = False
     self.netOption = 0
     self.dstWeight = 0
     self.kNN = 0
     self.andor = 0
     self.matrix = None
     self.excludeLimit = 1
     self.percentil = 0
     
     if parent is None:
         parent = self.controlArea
         
     boxGeneral = OWGUI.widgetBox(parent, box = "Distance boundaries")
     
     OWGUI.lineEdit(boxGeneral, self, "spinLowerThreshold", "Lower:", orientation='horizontal', callback=self.changeLowerSpin, valueType=float)
     OWGUI.lineEdit(boxGeneral, self, "spinUpperThreshold", "Upper:", orientation='horizontal', callback=self.changeUpperSpin, valueType=float)
     ribg = OWGUI.radioButtonsInBox(boxGeneral, self, "andor", [], orientation='horizontal', callback = self.generateGraph)
     OWGUI.appendRadioButton(ribg, self, "andor", "OR", callback = self.generateGraph)
     b = OWGUI.appendRadioButton(ribg, self, "andor", "AND", callback = self.generateGraph)
     b.setEnabled(False)
     OWGUI.spin(boxGeneral, self, "kNN", 0, 1000, 1, label="kNN:", orientation='horizontal', callback=self.generateGraph)
     OWGUI.doubleSpin(boxGeneral, self, "percentil", 0, 100, 0.1, label="Percentil:", orientation='horizontal', callback=self.setPercentil, callbackOnReturn=1)
     
     # Options
     self.attrColor = ""
     ribg = OWGUI.radioButtonsInBox(parent, self, "netOption", [], "Options", callback = self.generateGraph)
     OWGUI.appendRadioButton(ribg, self, "netOption", "All vertices", callback = self.generateGraph)
     OWGUI.appendRadioButton(ribg, self, "netOption", "Exclude small components", callback = self.generateGraph)
     OWGUI.spin(OWGUI.indentedBox(ribg), self, "excludeLimit", 1, 100, 1, label="Less vertices than: ", callback = (lambda h=True: self.generateGraph(h)))
     OWGUI.appendRadioButton(ribg, self, "netOption", "Largest connected component only", callback = self.generateGraph)
     OWGUI.appendRadioButton(ribg, self, "netOption", "Connected component with vertex")
     self.attribute = None
     self.attributeCombo = OWGUI.comboBox(ribg, self, "attribute", box = "Filter attribute")#, callback=self.setVertexColor)
     
     ribg = OWGUI.radioButtonsInBox(parent, self, "dstWeight", [], "Distance -> Weight", callback = self.generateGraph)
     OWGUI.appendRadioButton(ribg, self, "dstWeight", "Weight := distance", callback = self.generateGraph)
     OWGUI.appendRadioButton(ribg, self, "dstWeight", "Weight := 1 - distance", callback = self.generateGraph)
     
     self.label = ''
     self.searchString = OWGUI.lineEdit(self.attributeCombo.box, self, "label", callback=self.setSearchStringTimer, callbackOnType=True)
     self.searchStringTimer = QTimer(self)
     self.connect(self.searchStringTimer, SIGNAL("timeout()"), self.generateGraph)
     
     if str(self.netOption) != '3':
         self.attributeCombo.box.setEnabled(False)
Ejemplo n.º 21
0
    def __init__(self,parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "Itemsets explorer")

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

        self.showWholeItemsets = 1
        self.treeDepth = 2
        self.autoSend = True
        self.dataChanged = False
        self.purgeAttributes = True
        self.purgeClasses = True

        self.nItemsets = self.nSelectedItemsets = self.nSelectedExamples = ""
        self.loadSettings()

        self.treeItemsets = QTreeWidget(self.mainArea)
        self.mainArea.layout().addWidget(self.treeItemsets)
        self.treeItemsets.setSelectionMode (QTreeWidget.ExtendedSelection)
        self.treeItemsets.setHeaderLabels(["Itemsets", "Examples"])
        self.treeItemsets.setAllColumnsShowFocus ( 1)
        self.treeItemsets.setAlternatingRowColors(1) 
        self.treeItemsets.setColumnCount(2) 
        self.connect(self.treeItemsets,SIGNAL("itemSelectionChanged()"),self. selectionChanged)

        box = OWGUI.widgetBox(self.controlArea, "Info", addSpace = True)
        OWGUI.label(box, self, "Number of itemsets: %(nItemsets)s")
        OWGUI.label(box, self, "Selected itemsets: %(nSelectedItemsets)s")
        OWGUI.label(box, self, "Selected examples: %(nSelectedExamples)s")

        box = OWGUI.widgetBox(self.controlArea, "Tree", addSpace = True)
        OWGUI.spin(box, self, "treeDepth", label = "Tree depth", min = 1, max = 10, step = 1, callback = self.populateTree, callbackOnReturn = True)
        OWGUI.checkBox(box, self, "showWholeItemsets", "Display whole itemsets", callback = self.setWholeItemsets)
        OWGUI.button(box, self, "Expand All", callback = lambda: self.treeItemsets.expandAll())
        OWGUI.button(box, self, "Collapse", callback = lambda: self.treeItemsets.collapseAll())

        OWGUI.rubber(self.controlArea)

        boxSettings = OWGUI.widgetBox(self.controlArea, 'Send selection')
        OWGUI.checkBox(boxSettings, self, "purgeAttributes", "Purge attribute values/attributes", box=None, callback=self.purgeChanged)
        self.purgeClassesCB = OWGUI.checkBox(OWGUI.indentedBox(boxSettings), self, "purgeClasses", "Purge class attribute", callback=self.purgeChanged)
        if not self.purgeAttributes:
            self.purgeClassesCB.setEnabled(False)
            self.oldPurgeClasses = False

        cbSendAuto = OWGUI.checkBox(boxSettings, self, "autoSend", "Send immediately", box=None)
        btnUpdate = OWGUI.button(boxSettings, self, "Send", self.sendData, default=True)
        OWGUI.setStopper(self, btnUpdate, cbSendAuto, "dataChanged", self.sendData)

        self.itemsets= None
Ejemplo n.º 22
0
    def __init__(self, parent=None):
        BaseEditor.__init__(self, parent)
        self.methodInd = 0
        self.sampleN = 100
        self.sampleP = 25

        box = OWGUI.radioButtonsInBox(self,
                                      self,
                                      "methodInd", [],
                                      box="Sample",
                                      callback=self.onChange)

        w1 = OWGUI.widgetBox(box, orientation="horizontal", margin=0)
        rb1 = OWGUI.appendRadioButton(box,
                                      self,
                                      "methodInd",
                                      "Sample",
                                      insertInto=w1)
        self.sb1 = OWGUI.spin(OWGUI.widgetBox(w1),
                              self,
                              "sampleN",
                              min=1,
                              max=100000,
                              step=1,
                              controlWidth=75,
                              callback=self.onChange,
                              posttext="data instances")
        OWGUI.rubber(w1)

        w2 = OWGUI.widgetBox(box, orientation="horizontal", margin=0)
        rb2 = OWGUI.appendRadioButton(box,
                                      self,
                                      "methodInd",
                                      "Sample",
                                      insertInto=w2)
        self.sb2 = OWGUI.spin(OWGUI.widgetBox(w2),
                              self,
                              "sampleP",
                              min=1,
                              max=100,
                              step=1,
                              controlWidth=75,
                              callback=self.onChange,
                              posttext="% data instances")
        OWGUI.rubber(w2)

        self.updateSpinStates()

        OWGUI.rubber(box)
Ejemplo n.º 23
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, 'Net Inside View')
        
        self.inputs = []
        self.outputs = [("Nx View", Orange.network.NxView)]
        
        self._nhops = 2
        
        self.loadSettings()
        
        ib = OWGUI.widgetBox(self.controlArea, "Preferences", orientation="vertical")
        OWGUI.spin(ib, self, "_nhops", 1, 6, 1, label="Number of hops: ", callback=self.update_view)

        self.inside_view = NxInsideView(self._nhops)
        self.send("Nx View", self.inside_view)
Ejemplo n.º 24
0
    def __init__(self, parent=None, signalManager = None, name='C4.5'):
        OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0, resizingEnabled = 0)

        self.callbackDeposit = []

        self.inputs = [("Data", ExampleTable, self.setData),
                       ("Preprocess", PreprocessedLearner, self.setPreprocessor)]
        
        self.outputs = [("Learner", orange.Learner),
                        ("Classification Tree", Orange.classification.tree.TreeClassifier)]#, ("C45 Tree", orange.C45Classifier)]

        # Settings
        self.name = 'C4.5'
        self.infoGain = 0;  self.subset = 0;       self.probThresh = 0;
        self.useMinObjs = 1; self.minObjs = 2;   self.prune = 1;       self.cf = 25
        self.iterative = 0; self.manualWindow = 0; self.window = 50;     self.manualIncrement = 0;  self.increment = 10;   self.trials = 10

        self.convertToOrange = 1

        self.loadSettings()

        self.data = None                    # input data set
        self.preprocessor = None            # no preprocessing as default

        OWGUI.lineEdit(self.controlArea, self, 'name', box='Learner/Classifier Name',
                 tooltip='Name to be used by other widgets to identify your learner/classifier.')
        OWGUI.separator(self.controlArea)

        self.wbSplit = OWGUI.widgetBox(self.controlArea, "Splitting")
        OWGUI.checkBox(self.wbSplit, self, 'infoGain', 'Use information gain instead of ratio (-g)')
        OWGUI.checkBox(self.wbSplit, self, 'subset', 'Subsetting (-s)')
        OWGUI.checkBox(self.wbSplit, self, 'probThresh', 'Probabilistic threshold for continuous attributes (-p)')

        OWGUI.separator(self.controlArea)

        self.wbPruning = OWGUI.widgetBox(self.controlArea, "Pruning")
        OWGUI.checkWithSpin(self.wbPruning, self, 'Minimal examples in leaves (-m)', 1, 1000, 'useMinObjs', 'minObjs', '', 1, labelWidth = 225)
        OWGUI.checkWithSpin(self.wbPruning, self, 'Post pruning with confidence level (-cf) of ', 0, 100, 'prune', 'cf', '', 5, labelWidth = 225)

        OWGUI.separator(self.controlArea)

        self.wbIterative = OWGUI.widgetBox(self.controlArea, "Iterative generation")
        self.cbIterative = OWGUI.checkBox(self.wbIterative, self, 'iterative', 'Generate the tree iteratively (-i, -t, -w)')
        self.spTrial = OWGUI.spin(self.wbIterative, self, 'trials', 1, 30, 1, '', "       Number of trials (-t)", orientation = "horizontal", labelWidth = 225)
        self.csWindow = OWGUI.checkWithSpin(self.wbIterative, self, "Manually set initial window size (-w) to ", 10, 1000, 'manualWindow', 'window', '', 10, labelWidth = 225)
        self.csIncrement = OWGUI.checkWithSpin(self.wbIterative, self, "Manually set window increment (-i) to ", 10, 1000, 'manualIncrement', 'increment', '', 10, labelWidth = 225)

        self.cbIterative.disables = [self.spTrial, self.csWindow, self.csIncrement]
        self.cbIterative.makeConsistent()

#        OWGUI.separator(self.controlArea)

#        OWGUI.checkBox(self.controlArea, self, 'convertToOrange', 'Convert to orange tree structure', box = 1)

        OWGUI.separator(self.controlArea)

        OWGUI.button(self.controlArea, self, "&Apply", callback = self.setLearner, disabled=0, default=True)

        OWGUI.rubber(self.controlArea)
        self.setLearner()
Ejemplo n.º 25
0
    def __init__(self, parent=None, signalManager=None, name='Classification Tree'):
        OWWidget.__init__(self, parent, signalManager, name, wantMainArea=0, resizingEnabled=0)

        self.inputs = [("Data", ExampleTable, self.setData),
                       ("Preprocess", PreprocessedLearner, self.setPreprocessor)]

        self.outputs = [("Learner", Orange.classification.tree.TreeLearner),
                        ("Classification Tree", Orange.classification.tree.TreeClassifier), ]

        self.name = 'Classification Tree'
        self.estim = 0; self.relK = 5; self.relM = 100; self.limitRef = True
        self.bin = 0; self.subset = 0
        self.preLeafInstP = 2; self.preNodeInstP = 5; self.preNodeMajP = 95
        self.preLeafInst = 1; self.preNodeInst = 0; self.preNodeMaj = 0
        self.postMaj = 1; self.postMPruning = 1; self.postM = 2.0
        self.limitDepth = False; self.maxDepth = 100
        self.loadSettings()

        self.data = None
        self.preprocessor = None
        self.setLearner()

        OWGUI.lineEdit(self.controlArea, self, 'name', box='Learner/Classifier Name', tooltip='Name to be used by other widgets to identify your learner/classifier.')
        OWGUI.separator(self.controlArea)

        qBox = OWGUI.widgetBox(self.controlArea, 'Attribute selection criterion')

        self.qMea = OWGUI.comboBox(qBox, self, "estim", items=[m[0] for m in self.measures], callback=self.measureChanged)

        b1 = OWGUI.widgetBox(qBox, orientation="horizontal")
        OWGUI.separator(b1, 16, 0)
        b2 = OWGUI.widgetBox(b1)
        self.cbLimitRef, self.hbxRel1 = OWGUI.checkWithSpin(b2, self, "Limit the number of reference examples to ", 1, 1000, "limitRef", "relM")
        OWGUI.separator(b2)
        self.hbxRel2 = OWGUI.spin(b2, self, "relK", 1, 50, orientation="horizontal", label="Number of neighbours in ReliefF  ")

        OWGUI.separator(self.controlArea)

        OWGUI.radioButtonsInBox(self.controlArea, self, 'bin', self.binarizationOpts, "Binarization")
        OWGUI.separator(self.controlArea)

        self.measureChanged()

        self.pBox = OWGUI.widgetBox(self.controlArea, 'Pre-Pruning')

        self.preLeafInstBox, self.preLeafInstPBox = OWGUI.checkWithSpin(self.pBox, self, "Min. instances in leaves ", 1, 1000, "preLeafInst", "preLeafInstP")
        self.preNodeInstBox, self.preNodeInstPBox = OWGUI.checkWithSpin(self.pBox, self, "Stop splitting nodes with less instances than ", 1, 1000, "preNodeInst", "preNodeInstP")
        self.preNodeMajBox, self.preNodeMajPBox = OWGUI.checkWithSpin(self.pBox, self, "Stop splitting nodes with a majority class of (%)", 1, 100, "preNodeMaj", "preNodeMajP")
        self.cbLimitDepth, self.maxDepthBox = OWGUI.checkWithSpin(self.pBox, self, "Stop splitting nodes at depth", 0, 1000, "limitDepth", "maxDepth")
        OWGUI.separator(self.controlArea)
        self.mBox = OWGUI.widgetBox(self.controlArea, 'Post-Pruning')

        OWGUI.checkBox(self.mBox, self, 'postMaj', 'Recursively merge leaves with same majority class')
        self.postMPruningBox, self.postMPruningPBox = OWGUI.checkWithSpin(self.mBox, self, "Pruning with m-estimate, m=", 0, 1000, 'postMPruning', 'postM')

        OWGUI.separator(self.controlArea)
        self.btnApply = OWGUI.button(self.controlArea, self, "&Apply", callback=self.setLearner, disabled=0, default=True)

        OWGUI.rubber(self.controlArea)
        self.resize(200, 200)
Ejemplo n.º 26
0
    def __init__(self, parent=None):
        OWWidget.__init__(self, parent, 'Check')

        # GUI
        self.spinval = 10
        self.chkA = 1
        self.chkB = 0
        self.dx = 15

        box = OWGUI.widgetBox(self.controlArea, "Settings")
        gridbox = OWGUI.widgetBox(self.controlArea, "Grid Opions")
        gridbox.setEnabled(self.chkB)
        OWGUI.checkBox(box, self, "chkA", "Verbose")
        OWGUI.checkBox(box, self, "chkB", "Display Grid", disables=[gridbox])
        OWGUI.spin(gridbox, self, "dx", 10, 20)

        self.resize(100, 50)
Ejemplo n.º 27
0
    def __init__(self, parent=None):
        OWWidget.__init__(self, parent, 'Check')
        
        # GUI        
        self.spinval = 10
        self.chkA = 1
        self.chkB = 0
        self.dx = 15

        box = OWGUI.widgetBox(self.controlArea, "Settings")
        gridbox = OWGUI.widgetBox(self.controlArea, "Grid Opions")
        gridbox.setEnabled(self.chkB)
        OWGUI.checkBox(box, self, "chkA", "Verbose")
        OWGUI.checkBox(box, self, "chkB", "Display Grid", disables=[gridbox])
        OWGUI.spin(gridbox, self, "dx", 10, 20)
        
        self.resize(100,50)
Ejemplo n.º 28
0
    def __init__(self, parent=None, signalManager = None, name='ML-kNN'):
        OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0, resizingEnabled = 0)

        self.callbackDeposit = []

        self.inputs = [("Examples", ExampleTable, self.set_data), 
                       ("Preprocess", PreprocessedLearner, self.set_preprocessor)
                       ]
        self.outputs = [("Learner", orange.Learner),("ML-kNN Classifier", Orange.multilabel.MLkNNClassifier)]

        # Settings
        self.name = 'ML-kNN'
        self.k = 1
        self.smooth = 1.0
        
        self.loadSettings()

        self.data = None                    # input data set
        self.preprocessor = None            # no preprocessing as default
        self.set_learner()                  # this just sets the learner, no data
                                            # has come to the input yet

        OWGUI.lineEdit(self.controlArea, self, 'name', box='Learner/Classifier Name', \
                 tooltip='Name to be used by other widgets to identify your learner/classifier.')

        OWGUI.separator(self.controlArea)

        wbN = OWGUI.widgetBox(self.controlArea, "Neighbours")
        OWGUI.spin(wbN, self, "k", 1, 100, 1, None, "Number of neighbours", orientation="horizontal")
        
        OWGUI.separator(self.controlArea)
        OWGUI.widgetLabel(self.controlArea, 'Smoothing parameter')
        kernelSizeValid = QDoubleValidator(self.controlArea)
        kernelSizeValid.setRange(0,10,3)
        OWGUI.lineEdit(self.controlArea, self, 'smooth',
                       tooltip='Smoothing parameter controlling the strength of uniform prior (Default value is set to 1 which yields the Laplace smoothing).',
                       valueType = float, validator = kernelSizeValid)
                       
        OWGUI.separator(self.controlArea)

        OWGUI.button(self.controlArea, self, "&Apply", callback=self.set_learner, disabled=0, default=True)
        
        OWGUI.rubber(self.controlArea)

        self.resize(100,250)
Ejemplo n.º 29
0
    def __init__(self, parent=None, signalManager = None, name='Classification Tree'):
        OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0, resizingEnabled = 0)

        self.inputs = [("Examples", ExampleTable, self.setData), ("Preprocess", PreprocessedLearner, self.setPreprocessor)]
        self.outputs = [("Learner", orange.TreeLearner),("Classification Tree", orange.TreeClassifier)]

        self.name = 'Classification Tree'
        self.estim = 0; self.relK = 5; self.relM = 100; self.limitRef = True
        self.bin = 0; self.subset = 0
        self.preLeafInstP = 2; self.preNodeInstP = 5; self.preNodeMajP = 95
        self.preLeafInst = 1; self.preNodeInst = 0; self.preNodeMaj = 0
        self.postMaj = 1; self.postMPruning = 1; self.postM = 2.0
        self.limitDepth = False; self.maxDepth = 100
        self.loadSettings()

        self.data = None
        self.preprocessor = None
        self.setLearner()

        OWGUI.lineEdit(self.controlArea, self, 'name', box='Learner/Classifier Name', tooltip='Name to be used by other widgets to identify your learner/classifier.')
        OWGUI.separator(self.controlArea)

        qBox = OWGUI.widgetBox(self.controlArea, 'Attribute selection criterion')

        self.qMea = OWGUI.comboBox(qBox, self, "estim", items = [m[0] for m in self.measures], callback = self.measureChanged)

        b1 = OWGUI.widgetBox(qBox, orientation = "horizontal")
        OWGUI.separator(b1, 16, 0)
        b2 = OWGUI.widgetBox(b1)
        self.cbLimitRef, self.hbxRel1 = OWGUI.checkWithSpin(b2, self, "Limit the number of reference examples to ", 1, 1000, "limitRef", "relM")
        OWGUI.separator(b2)
        self.hbxRel2 = OWGUI.spin(b2, self, "relK", 1, 50, orientation="horizontal", label="Number of neighbours in ReliefF  ")
 
        OWGUI.separator(self.controlArea)

        OWGUI.radioButtonsInBox(self.controlArea, self, 'bin', self.binarizationOpts, "Binarization")
        OWGUI.separator(self.controlArea)

        self.measureChanged()

        self.pBox = OWGUI.widgetBox(self.controlArea, 'Pre-Pruning')

        self.preLeafInstBox, self.preLeafInstPBox = OWGUI.checkWithSpin(self.pBox, self, "Min. instances in leaves ", 1, 1000, "preLeafInst", "preLeafInstP")
        self.preNodeInstBox, self.preNodeInstPBox = OWGUI.checkWithSpin(self.pBox, self, "Stop splitting nodes with less instances than ", 1, 1000, "preNodeInst", "preNodeInstP")
        self.preNodeMajBox, self.preNodeMajPBox = OWGUI.checkWithSpin(self.pBox, self, "Stop splitting nodes with a majority class of (%)", 1, 100, "preNodeMaj", "preNodeMajP")
        self.cbLimitDepth, self.maxDepthBox = OWGUI.checkWithSpin(self.pBox, self, "Stop splitting nodes at depth", 0, 1000, "limitDepth", "maxDepth")
        OWGUI.separator(self.controlArea)
        self.mBox = OWGUI.widgetBox(self.controlArea, 'Post-Pruning')

        OWGUI.checkBox(self.mBox, self, 'postMaj', 'Recursively merge leaves with same majority class')
        self.postMPruningBox, self.postMPruningPBox = OWGUI.checkWithSpin(self.mBox, self, "Pruning with m-estimate, m=", 0, 1000, 'postMPruning', 'postM')

        OWGUI.separator(self.controlArea)
        self.btnApply = OWGUI.button(self.controlArea, self, "&Apply", callback = self.setLearner, disabled=0)
        
        OWGUI.rubber(self.controlArea)
        self.resize(200,200)
Ejemplo n.º 30
0
    def __init__(self, parent=None, signalManager = None, name='C4.5'):
        OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0, resizingEnabled = 0)

        self.callbackDeposit = []

        self.inputs = [("Examples", ExampleTable, self.setData), ("Preprocess", PreprocessedLearner, self.setPreprocessor)]
        self.outputs = [("Learner", orange.Learner),("Classification Tree", orange.TreeClassifier)]#, ("C45 Tree", orange.C45Classifier)]

        # Settings
        self.name = 'C4.5'
        self.infoGain = 0;  self.subset = 0;       self.probThresh = 0;
        self.useMinObjs = 1; self.minObjs = 2;   self.prune = 1;       self.cf = 25
        self.iterative = 0; self.manualWindow = 0; self.window = 50;     self.manualIncrement = 0;  self.increment = 10;   self.trials = 10

        self.convertToOrange = 1

        self.loadSettings()

        self.data = None                    # input data set
        self.preprocessor = None            # no preprocessing as default

        OWGUI.lineEdit(self.controlArea, self, 'name', box='Learner/Classifier Name',
                 tooltip='Name to be used by other widgets to identify your learner/classifier.')
        OWGUI.separator(self.controlArea)

        self.wbSplit = OWGUI.widgetBox(self.controlArea, "Splitting")
        OWGUI.checkBox(self.wbSplit, self, 'infoGain', 'Use information gain instead of ratio (-g)')
        OWGUI.checkBox(self.wbSplit, self, 'subset', 'Subsetting (-s)')
        OWGUI.checkBox(self.wbSplit, self, 'probThresh', 'Probabilistic threshold for continuous attributes (-p)')

        OWGUI.separator(self.controlArea)

        self.wbPruning = OWGUI.widgetBox(self.controlArea, "Pruning")
        OWGUI.checkWithSpin(self.wbPruning, self, 'Minimal examples in leaves (-m)', 1, 1000, 'useMinObjs', 'minObjs', '', 1, labelWidth = 225)
        OWGUI.checkWithSpin(self.wbPruning, self, 'Post pruning with confidence level (-cf) of ', 0, 100, 'prune', 'cf', '', 5, labelWidth = 225)

        OWGUI.separator(self.controlArea)

        self.wbIterative = OWGUI.widgetBox(self.controlArea, "Iterative generation")
        self.cbIterative = OWGUI.checkBox(self.wbIterative, self, 'iterative', 'Generate the tree iteratively (-i, -t, -w)')
        self.spTrial = OWGUI.spin(self.wbIterative, self, 'trials', 1, 30, 1, '', "       Number of trials (-t)", orientation = "horizontal", labelWidth = 225)
        self.csWindow = OWGUI.checkWithSpin(self.wbIterative, self, "Manually set initial window size (-w) to ", 10, 1000, 'manualWindow', 'window', '', 10, labelWidth = 225)
        self.csIncrement = OWGUI.checkWithSpin(self.wbIterative, self, "Manually set window increment (-i) to ", 10, 1000, 'manualIncrement', 'increment', '', 10, labelWidth = 225)

        self.cbIterative.disables = [self.spTrial, self.csWindow, self.csIncrement]
        self.cbIterative.makeConsistent()

#        OWGUI.separator(self.controlArea)

#        OWGUI.checkBox(self.controlArea, self, 'convertToOrange', 'Convert to orange tree structure', box = 1)

        OWGUI.separator(self.controlArea)

        OWGUI.button(self.controlArea, self, "&Apply", callback = self.setLearner, disabled=0)

        OWGUI.rubber(self.controlArea)
        self.setLearner()
Ejemplo n.º 31
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, 'LearningCurveA')

        self.inputs = [("Data", ExampleTable, self.dataset),
                       ("Learner", orange.Learner, self.learner, Multiple)]
        
        self.folds = 5     # cross validation folds
        self.steps = 10    # points in the learning curve
        self.scoringF = 0  # scoring function
        self.commitOnChange = 1 # compute curve on any change of parameters
        self.loadSettings()
        self.setCurvePoints() # sets self.curvePoints, self.steps equidistantpoints from 1/self.steps to 1
        self.scoring = [("Classification Accuracy", orngStat.CA), ("AUC", orngStat.AUC), ("BrierScore", orngStat.BrierScore), ("Information Score", orngStat.IS), ("Sensitivity", orngStat.sens), ("Specificity", orngStat.spec)]
        self.learners = [] # list of current learners from input channel, tuples (id, learner)
        self.data = None   # data on which to construct the learning curve
        self.curves = []   # list of evaluation results (one per learning curve point)
        self.scores = []   # list of current scores, learnerID:[learner scores]

        # GUI
        box = OWGUI.widgetBox(self.controlArea, "Info")
        self.infoa = OWGUI.widgetLabel(box, 'No data on input.')
        self.infob = OWGUI.widgetLabel(box, 'No learners.')

        OWGUI.separator(self.controlArea)
        box = OWGUI.widgetBox(self.controlArea, "Evaluation Scores")
        scoringNames = [x[0] for x in self.scoring]
        OWGUI.comboBox(box, self, "scoringF", items=scoringNames, callback=self.computeScores)

        OWGUI.separator(self.controlArea)
        box = OWGUI.widgetBox(self.controlArea, "Options")
        OWGUI.spin(box, self, 'folds', 2, 100, step=1, label='Cross validation folds:  ',
                   callback=lambda: self.computeCurve(self.commitOnChange))
        OWGUI.spin(box, self, 'steps', 2, 100, step=1, label='Learning curve points:  ',
                   callback=[self.setCurvePoints, lambda: self.computeCurve(self.commitOnChange)])

        OWGUI.checkBox(box, self, 'commitOnChange', 'Apply setting on any change')
        self.commitBtn = OWGUI.button(box, self, "Apply Setting", callback=self.computeCurve, disabled=1)

        # table widget
        self.table = OWGUI.table(self.mainArea, selectionMode=QTableWidget.NoSelection)
                
        self.resize(500,200)
Ejemplo n.º 32
0
    def __init__(self, parent=None):
        OWWidget.__init__(self, parent, 'Spin')

        # GUI
        self.spinval = 10
        OWGUI.spin(self.controlArea, self, "spinval", 0, 100, box="Value A")
        box = OWGUI.widgetBox(self.controlArea, "Options")
        self.alpha = 30
        self.beta = 4
        OWGUI.spin(box,
                   self,
                   "alpha",
                   0,
                   100,
                   label="Alpha:",
                   labelWidth=60,
                   orientation="horizontal",
                   callback=self.setInfo)
        OWGUI.spin(box,
                   self,
                   "beta",
                   -10,
                   10,
                   label="Beta:",
                   labelWidth=60,
                   orientation="horizontal",
                   callback=self.setInfo)

        box = OWGUI.widgetBox(self.controlArea, "Info")
        self.info = OWGUI.widgetLabel(box, "")
        self.setInfo()

        self.resize(100, 50)
Ejemplo n.º 33
0
    def __init__(self, parent=None, signalManager = None, name='kmeans'):
        OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0)

        self.callbackDeposit = []

        self.inputs = [("Data", Descriptors, self.setData)]
        self.outputs = [("Codebook", Codebook)] # , ("Histograms", ExampleTable)]

        self.useLazyEvaluation = pynopticon.useLazyEvaluation
        
        # Settings
        self.name = name
        self.kmeans = None
        self.loadSettings()

        self.numClusters = 20
        self.maxiter = 0
        self.numruns = 1
        self.sampleFromData = 1.0

        self.loadSettings()
        
        wbN = OWGUI.widgetBox(self.controlArea, "kMeans Settings")
        OWGUI.spin(wbN, self, "numClusters", 1, 100000, 100, None, "Number of clusters   ", orientation="horizontal")
        OWGUI.spin(wbN, self, "maxiter", 0, 100000, 1, None, "Maximum number of iterations", orientation="horizontal")
        OWGUI.spin(wbN, self, "numruns", 0, 100000, 1, None, "Number of runs ", orientation="horizontal")
        OWGUI.widgetLabel(wbN, 'Use x% of the data')
        OWGUI.lineEdit(wbN, self, 'sampleFromData', valueType=float)
        OWGUI.separator(self.controlArea)
	wbS = OWGUI.widgetBox(self.controlArea, "Widget Settings")
        OWGUI.checkBox(wbS, self, "useLazyEvaluation", "Use lazy evaluation")
        OWGUI.button(self.controlArea, self, "&Apply Settings", callback = self.applySettings, disabled=0)

        self.resize(100,150)
Ejemplo n.º 34
0
    def __init__(self,
                 parent=None,
                 signalManager=None,
                 title="Gaussin Mixture"):
        OWWidget.__init__(self, parent, signalManager, title)

        self.inputs = [("Data", Orange.data.Table, self.set_data)]
        self.outputs = [("Data with Indicator Matrix", Orange.data.Table)]

        self.init_method = 0
        self.n = 3
        self.auto_commit = True

        self.loadSettings()

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

        OWGUI.spin(self.controlArea,
                   self,
                   "n",
                   min=1,
                   max=10,
                   step=1,
                   box="Settings",
                   label="Number of gaussians",
                   tooltip="The number of gaussians in the mixture ",
                   callback=self.on_params_changed)

        OWGUI.comboBox(self.controlArea,
                       self,
                       "init_method",
                       box="Initialization",
                       items=["K-means", "Random"],
                       tooltip="Method used to initialize the mixture",
                       callback=self.on_params_changed)

        OWGUI.button(self.controlArea, self, "Apply", callback=self.commit)
Ejemplo n.º 35
0
    def __init__(self, parent=None, signalManager = None, title = "Calibrated Classifier"):
        OWWidget.__init__(self, parent, signalManager, title)

        self.inputs = [("Data", ExampleTable, self.setData), ("Base Learner", orange.Learner, self.setBaseLearner)]
        self.outputs = [("Learner", orange.Learner),("Classifier", orange.Classifier)]

        # Settings
        self.name = 'Calibrated Learner'
        self.optimalThreshold = 0
        self.threshold = self.accuracy = 50
        self.loadSettings()

        self.learner = None
        self.baseLearner = None
        self.data = None

        OWGUI.lineEdit(self.controlArea, self, 'name',
                       box='Learner/Classifier Name', 
                       tooltip='Name to be used by other widgets to identify your learner/classifier.')
        OWGUI.separator(self.controlArea)

        self.wbThreshold = OWGUI.widgetBox(self.controlArea, "Threshold", addSpace=True)
        self.cbOptimal = OWGUI.checkBox(self.wbThreshold, self, "optimalThreshold",
                                        "Use optimal threshold",
                                        callback=self.setThreshold)
        
        self.spThreshold = OWGUI.spin(self.wbThreshold, self, "threshold", 1, 99, step=5,
                                      label = "Threshold",
                                      orientation = "horizontal",
                                      callback = self.setThreshold)
        
        self.lbNotice = OWGUI.widgetLabel(self.wbThreshold, "Notice: If the widget is connected to a widget that takes a Learner, not a Classifier (eg 'Test Learners'), the automatically computed threshold can differ from the above.")
        self.lbNotice.setWordWrap(True)
         
        self.cbOptimal.disables = [self.lbNotice]
        self.cbOptimal.makeConsistent()
        self.spThreshold.setDisabled(self.optimalThreshold)
        
        OWGUI.rubber(self.controlArea)
        
        OWGUI.button(self.controlArea, self, "&Apply Setting",
                     callback = self.btApplyCallback,
                     disabled=0)

        self.btSave = OWGUI.button(self.controlArea, self, "&Save Graph", callback = self.saveToFile, disabled=1)

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

        self.resize(700, 330)
Ejemplo n.º 36
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, 'Nx Clustering')

        self.inputs = [("Network", Orange.network.Graph,
                        self.setNetwork, Default)]
        self.outputs = [("Network", Orange.network.Graph)]

        self.net = None
        self.method = 0
        self.iterationHistory = 0
        self.autoApply = 0
        self.iterations = 1000
        self.hop_attenuation = 0.1
        self.loadSettings()

        OWGUI.spin(self.controlArea, self, "iterations", 1,
                   100000, 1, label="Iterations: ")
        ribg = OWGUI.radioButtonsInBox(self.controlArea, self, "method",
                                       [], "Method", callback=self.cluster)
        OWGUI.appendRadioButton(ribg, self, "method",
                        "Label propagation clustering (Raghavan et al., 2007)",
                        callback=self.cluster)

        OWGUI.appendRadioButton(ribg, self, "method",
                        "Label propagation clustering (Leung et al., 2009)",
                        callback=self.cluster)
        OWGUI.doubleSpin(OWGUI.indentedBox(ribg), self, "hop_attenuation",
                         0, 1, 0.01, label="Hop attenuation (delta): ")

        self.info = OWGUI.widgetLabel(self.controlArea, ' ')
        OWGUI.checkBox(self.controlArea, self, "iterationHistory",
                       "Append clustering data on each iteration",
                       callback=self.cluster)
        OWGUI.checkBox(self.controlArea, self, "autoApply",
                       "Commit automatically")
        OWGUI.button(self.controlArea, self, "Commit",
                     callback=lambda b=True: self.cluster(b))
Ejemplo n.º 37
0
 def __init__(self, parent=None, signalManager=None):
     OWWidget.__init__(self, parent, signalManager, 'Pubmed Network View', wantMainArea=0)
     
     self.inputs = []
     self.outputs = [("Nx View", Orange.network.NxView)]
     
     self._nhops = 2
     self._edge_threshold = 0.5
     self._n_max_neighbors = 20
     self.selected_titles = []
     self.titles = []
     self.filter = ''
     self.ids = []
     self._selected_nodes = []
     self._algorithm = 0
     self._k_algorithm = 0.3
     
     self.loadSettings()
     
     box = OWGUI.widgetBox(self.controlArea, "Paper Selection", orientation="vertical")
     OWGUI.lineEdit(box, self, "filter", callback=self.filter_list, callbackOnType=True)
     self.list_titles = OWGUI.listBox(box, self, "selected_titles", "titles", selectionMode=QListWidget.MultiSelection, callback=self.update_view)
     OWGUI.separator(self.controlArea)
     box_pref = OWGUI.widgetBox(self.controlArea, "Preferences", orientation="vertical")
     OWGUI.spin(box_pref, self, "_nhops", 1, 6, 1, label="Number of hops: ", callback=self.update_view)
     OWGUI.spin(box_pref, self, "_n_max_neighbors", 1, 100, 1, label="Max number of neighbors: ", callback=self.update_view)
     OWGUI.doubleSpin(box_pref, self, "_edge_threshold", 0, 1, step=0.01, label="Edge threshold: ", callback=self.update_view)
     OWGUI.separator(self.controlArea)
     box_alg = OWGUI.widgetBox(self.controlArea, "Interest Propagation Algorithm", orientation="vertical")
     radio_box = OWGUI.radioButtonsInBox(box_alg, self, "_algorithm", [], callback=self.update_view)
     OWGUI.appendRadioButton(radio_box, self, "_algorithm", "Without Clustering", callback=self.update_view)
     OWGUI.doubleSpin(OWGUI.indentedBox(radio_box), self, "_k_algorithm", 0, 1, step=0.01, label="Parameter k: ", callback=self.update_view)
     OWGUI.appendRadioButton(radio_box, self, "_algorithm", "With Clustering", callback=self.update_view)
     
     self.inside_view = PubmedNetworkView(self)
     self.send("Nx View", self.inside_view)
Ejemplo n.º 38
0
    def __init__(self, parent=None, signalManager = None, name='BR-kNN'):
        OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0, resizingEnabled = 0)

        self.callbackDeposit = []

        self.inputs = [("Examples", ExampleTable, self.set_data), 
                       ("Preprocess", PreprocessedLearner, self.set_preprocessor)
                       ]
        self.outputs = [("Learner", orange.Learner),("BR-kNN Classifier", Orange.multilabel.BRkNNClassifier)]

        # Settings
        self.name = 'BR-kNN'
        self.k = 1
        
        self.loadSettings()

        self.data = None                    # input data set
        self.preprocessor = None            # no preprocessing as default
        self.set_learner()                  # this just sets the learner, no data
                                            # has come to the input yet

        OWGUI.lineEdit(self.controlArea, self, 'name', box='Learner/Classifier Name', \
                 tooltip='Name to be used by other widgets to identify your learner/classifier.')

        OWGUI.separator(self.controlArea)

        wbN = OWGUI.widgetBox(self.controlArea, "Neighbours")
        OWGUI.spin(wbN, self, "k", 1, 100, 1, None, "Number of neighbours", orientation="horizontal")
        
        OWGUI.separator(self.controlArea)

        OWGUI.button(self.controlArea, self, "&Apply", callback=self.set_learner, disabled=0, default=True)
        
        OWGUI.rubber(self.controlArea)

        self.resize(100,250)
Ejemplo n.º 39
0
    def __init__(self, parent=None):
        OWWidget.__init__(self, parent, 'Spin')
        
        # GUI
        self.spinval = 10
        OWGUI.spin(self.controlArea, self, "spinval", 0, 100, box="Value A")
        box = OWGUI.widgetBox(self.controlArea, "Options")
        self.alpha = 30
        self.beta = 4
        OWGUI.spin(box, self, "alpha", 0, 100, label="Alpha:", labelWidth=60,
                   orientation="horizontal", callback=self.setInfo)
        OWGUI.spin(box, self, "beta", -10, 10, label="Beta:", labelWidth=60,
                   orientation="horizontal", callback=self.setInfo)

        box = OWGUI.widgetBox(self.controlArea, "Info")
        self.info = OWGUI.widgetLabel(box, "")
        self.setInfo()
        
        self.resize(100,50)
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, 'LearningCurveC')

        self.inputs = [("Data", ExampleTable, self.dataset), ("Learner", orange.Learner, self.learner, 0)]

        self.folds = 5     # cross validation folds
        self.steps = 10    # points in the learning curve
        self.scoringF = 0  # scoring function
        self.commitOnChange = 1 # compute curve on any change of parameters
        self.graphPointSize = 5 # size of points in the graphs
        self.graphDrawLines = 1 # draw lines between points in the graph
        self.graphShowGrid = 1  # show gridlines in the graph
        self.selectedLearners = [] 
        self.loadSettings()

        warnings.filterwarnings("ignore", ".*builtin attribute.*", orange.AttributeWarning)

        self.setCurvePoints() # sets self.curvePoints, self.steps equidistantpoints from 1/self.steps to 1
        self.scoring = [("Classification Accuracy", orngStat.CA), ("AUC", orngStat.AUC), ("BrierScore", orngStat.BrierScore), ("Information Score", orngStat.IS), ("Sensitivity", orngStat.sens), ("Specificity", orngStat.spec)]
        self.learners = [] # list of current learners from input channel, tuples (id, learner)
        self.data = None   # data on which to construct the learning curve
        self.curves = []   # list of evaluation results (one per learning curve point)
        self.scores = []   # list of current scores, learnerID:[learner scores]

        # GUI
        box = OWGUI.widgetBox(self.controlArea, "Info")
        self.infoa = OWGUI.widgetLabel(box, 'No data on input.')
        self.infob = OWGUI.widgetLabel(box, 'No learners.')

        ## class selection (classQLB)
        OWGUI.separator(self.controlArea)
        self.cbox = OWGUI.widgetBox(self.controlArea, "Learners")
        self.llb = OWGUI.listBox(self.cbox, self, "selectedLearners", selectionMode=QListWidget.MultiSelection, callback=self.learnerSelectionChanged)
        
        self.llb.setMinimumHeight(50)
        self.blockSelectionChanges = 0

        OWGUI.separator(self.controlArea)
        box = OWGUI.widgetBox(self.controlArea, "Evaluation Scores")
        scoringNames = [x[0] for x in self.scoring]
        OWGUI.comboBox(box, self, "scoringF", items=scoringNames,
                       callback=self.computeScores)

        OWGUI.separator(self.controlArea)
        box = OWGUI.widgetBox(self.controlArea, "Options")
        OWGUI.spin(box, self, 'folds', 2, 100, step=1,
                   label='Cross validation folds:  ',
                   callback=lambda: self.computeCurve(self.commitOnChange))
        OWGUI.spin(box, self, 'steps', 2, 100, step=1,
                   label='Learning curve points:  ',
                   callback=[self.setCurvePoints, lambda: self.computeCurve(self.commitOnChange)])

        OWGUI.checkBox(box, self, 'commitOnChange', 'Apply setting on any change')
        self.commitBtn = OWGUI.button(box, self, "Apply Setting", callback=self.computeCurve, disabled=1)

        # start of content (right) area
        tabs = OWGUI.tabWidget(self.mainArea)

        # graph widget
        tab = OWGUI.createTabPage(tabs, "Graph")
        self.graph = OWPlot(tab)
        self.graph.set_axis_autoscale(xBottom)
        self.graph.set_axis_autoscale(yLeft)
        tab.layout().addWidget(self.graph)
        self.setGraphGrid()

        # table widget
        tab = OWGUI.createTabPage(tabs, "Table")
        self.table = OWGUI.table(tab, selectionMode=QTableWidget.NoSelection)

        self.resize(550,200)
Ejemplo n.º 41
0
    def __init__(self, parent=None, signalManager=None):
        """Widget creator."""
        
        OWWidget.__init__(            
            self,
            parent,
            signalManager,
            wantMainArea=0,
            wantStateInfoWidget=0,
        )
      
        # DEFINE OUTPUT
        
        self.outputs = [('Text data', Segmentation)]

       

        # Settings and other attribute initializations...

        self.segment_label = u'search_results'
        self.nb_tweet = 50
        self.include_RT = False
        self.word_to_search = ''
        self.autoSend = False

        self.useTwitterLicenseKey = False
        self.twitterLicenseKeys = False
        self.twitterLicenseKeysConsumerKey = ''
        self.twitterLicenseKeysConsumerSecret = ''
        self.twitterLicenseKeysAccessToken = ''
        self.twitterLicenseKeysAccessTokenSecret = ''

        self.service = u'Twitter'
        self.wiki_section = False
        self.wiki_type_of_text = u'Plain text'
        self.nb_bing_entry = 50
        self.language = 'English'
        self.createdInputs = list()

        self.dico_lang = {
            'English': 'en',
            'French': 'fr',
            'German': 'de',
            'Spanish': 'es',
            'Italian': 'it',
            'Dutch': 'nl'
        }

        

        # BASIC SETTING

        self.uuid = None
        self.loadSettings()
        self.uuid = getWidgetUuid(self)
        self.inputData = None

        self.infoBox = InfoBox(widget=self.controlArea)
        self.sendButton = SendButton(
            widget=self.controlArea,
            master=self,
            callback=self.sendData,
            infoBoxAttribute='infoBox'
        )

     
        # CONFIG BOXES
 
        optionsBox = OWGUI.widgetBox(self.controlArea, 'Options')
        OWGUI.separator(widget=self.controlArea, height=3)
        self.twitterBox = OWGUI.widgetBox(self.controlArea, 'Twitter')      
        self.wikipediaBox = OWGUI.widgetBox(self.controlArea, 'Wikipedia')
        self.bingBox = OWGUI.widgetBox(self.controlArea, 'Bing')
        OWGUI.separator(widget=self.controlArea, height=3)

        self.serviceBoxes = [self.twitterBox, self.wikipediaBox, self.bingBox]



        # OPTION BOX

        OWGUI.comboBox(
            widget              = optionsBox,
            master              = self,
            value               = 'service',
            items               = [u'Twitter', u'Wikipedia', u'Bing'],
            sendSelectedValue   = True,
            orientation         = 'horizontal',
            label               = u'Service:',
            labelWidth          = 160,
            callback            = self.set_service_box_visibility,
            tooltip             = (
                    u"Select a service."
            ),
        )

        OWGUI.separator(widget=optionsBox, height=3)

        OWGUI.comboBox(
            widget              = optionsBox,
            master              = self,
            value               = 'language',
            items               = ['English', 'French', 'German', 'Spanish', 'Italian', 'Dutch'],
            sendSelectedValue   = True,
            orientation         = 'horizontal',
            label               = u'Language:',
            labelWidth          = 160,
            callback            = self.sendButton.settingsChanged,
            tooltip             = (
                    u"Select language."
            ),
        )
        
        OWGUI.separator(widget=optionsBox, height=3)
        
        OWGUI.lineEdit(
            widget              = optionsBox,
            master              = self,
            value               = 'word_to_search',
            orientation         = 'horizontal',
            label               = u'Query:',
            callback            = self.sendButton.settingsChanged,
            labelWidth          = 160,
        )

        OWGUI.separator(widget=optionsBox, height=3)



        # TWITTER BOX

        OWGUI.spin(
            widget=self.twitterBox,          
            master=self, 
            value='nb_tweet',
            label='Number of tweets:',
            labelWidth=160,
            tooltip='Select a number of tweet.',
            callback= self.sendButton.settingsChanged,
            min= 1, 
            max= 3000, 
            step=1,
        )

        OWGUI.separator(widget=self.twitterBox, height=3)

        OWGUI.checkBox(
            widget              = self.twitterBox,
            master              = self,
            value               = 'include_RT',
            label               = u'Include retweets',
            labelWidth          = 160,
            callback            = self.sendButton.settingsChanged,
            tooltip             = (
                    u"Include re-tweets or not."
            ),
        )

        OWGUI.separator(widget=self.twitterBox, height=3)

        # TWITTER LICENSE KEY BOX

        OWGUI.checkBox(
            widget              = self.twitterBox,
            master              = self,
            value               = 'useTwitterLicenseKey',
            label               = u'Use license key',
            labelWidth          = 160,
            callback            = self.changeTwitterLicenseKeyBox,
            tooltip             = (
                    u"Use private license key or not."
            ),
        )

        self.twitterLicenseBox = OWGUI.indentedBox(self.twitterBox, sep=20)

        OWGUI.separator(widget=self.twitterLicenseBox, height=3)

        OWGUI.lineEdit(
            widget=self.twitterLicenseBox,
            master=self,
            value='twitterLicenseKeysConsumerKey',
            label=u'Consumer key: ',
            orientation='horizontal',
            callback=self.sendButton.settingsChanged,
            labelWidth=140,
            tooltip=(
                    u"Your twitter Consumer key."
            ),
        )

        OWGUI.separator(widget=self.twitterLicenseBox, height=3)

        OWGUI.lineEdit(
            widget=self.twitterLicenseBox,
            master=self,
            value='twitterLicenseKeysConsumerSecret',
            label=u'Consumer secret: ',
            orientation='horizontal',
            callback=self.sendButton.settingsChanged,
            labelWidth=140,
            tooltip=(
                    u"Your private twitter license key."
            ),
        )

        OWGUI.separator(widget=self.twitterLicenseBox, height=3)

        OWGUI.lineEdit(
            widget=self.twitterLicenseBox,
            master=self,
            value='twitterLicenseKeysAccessToken',
            label=u'Access token: ',
            orientation='horizontal',
            callback=self.sendButton.settingsChanged,
            labelWidth=140,
            tooltip=(
                    u"Your private twitter Access token."
            ),
        )

        OWGUI.separator(widget=self.twitterLicenseBox, height=3)

        OWGUI.lineEdit(
            widget=self.twitterLicenseBox,
            master=self,
            value='twitterLicenseKeysAccessTokenSecret',
            label=u'Access token secret: ',
            orientation='horizontal',
            callback=self.sendButton.settingsChanged,
            labelWidth=140,
            tooltip=(
                    u"Your private twitter access token secret."
            ),
        )
        OWGUI.separator(widget=self.twitterLicenseBox, height=3)




        # WIKIPEDIA BOX

        OWGUI.checkBox(
            widget              = self.wikipediaBox,
            master              = self,
            value               = 'wiki_section',
            label               = u'Segment into sections',
            labelWidth          = 160,
            callback            = self.sendButton.settingsChanged,
            tooltip             = (
                    u"Segment into Wikipedia sections:"
            ),
        )

        OWGUI.separator(widget=self.wikipediaBox, height=3)

        OWGUI.comboBox(
            widget              = self.wikipediaBox,
            master              = self,
            value               = 'wiki_type_of_text',
            items               = [u'Plain text', u'HTML'],
            sendSelectedValue   = True,
            orientation         = 'horizontal',
            label               = u'Output format:',
            labelWidth          = 160,
            callback            = self.sendButton.settingsChanged,
            tooltip             = (
                    u"Select type of text."
            ),
        )

        OWGUI.separator(widget=self.wikipediaBox, height=3)


        # BING BOX

        OWGUI.spin(
            widget=self.bingBox,          
            master=self, 
            value='nb_bing_entry',
            label='Number of results:',
            labelWidth=160,
            tooltip='Select a number of results.',
            callback= self.sendButton.settingsChanged,
            min= 1, 
            max= 1000, 
            step=1,
        )

        OWGUI.separator(widget=self.bingBox, height=3)

        # CONFIG WIDGET
        
        OWGUI.rubber(self.controlArea)
        self.sendButton.draw()
        self.infoBox.draw()
        self.set_service_box_visibility()
        self.changeTwitterLicenseKeyBox()
        self.sendButton.sendIf()
        self.adjustSizeWithTimer()        
Ejemplo n.º 42
0
    def __init__(self, parent=None, signalManager = None, name='sift'):
        OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0)

        self.callbackDeposit = []

        self.inputs = [("Images PIL", SeqContainer, self.setData)]
        self.outputs = [("Descriptors", SeqContainer)]

        
        
        # Settings
        self.name = name
	self.sift = None

	self.useLazyEvaluation = armor.useLazyEvaluation
	
        self.Octave = 6
        self.Levels = 3
        self.FirstOctave = 0
        self.PeakThresh = 0
        self.EdgeThresh = 10
	self.NormThresh = 0
        self.Orientations = 0

        self.loadSettings()
        
        self.data = None                    # input data set

        wbN = OWGUI.widgetBox(self.controlArea, "Sift Settings")
        OWGUI.spin(wbN, self, "Octave", -1, 8, 1, None, "Octaves   ", orientation="horizontal")
        OWGUI.spin(wbN, self, "Levels", 1, 8, 1, None, "Levels   ", orientation="horizontal")
        OWGUI.spin(wbN, self, "FirstOctave", 0, 8, 1, None, "First Octave ", orientation="horizontal")
        OWGUI.spin(wbN, self, "PeakThresh", -1, 8, 1, None, "PeakThresh", orientation="horizontal")
        OWGUI.spin(wbN, self, "EdgeThresh", -1, 8, 1, None, "EdgeThresh", orientation="horizontal")
	OWGUI.spin(wbN, self, "NormThresh", -1, 8, 1, None, "NormThresh", orientation="horizontal")    
        OWGUI.spin(wbN, self, "Orientations", 0, 1, 1, None, "Force computation of orientations", orientation="horizontal")
        wbS = OWGUI.widgetBox(self.controlArea, "Widget Settings")
        OWGUI.checkBox(wbS, self, "useLazyEvaluation", "Use lazy evaluation")
        OWGUI.separator(self.controlArea)
        
        OWGUI.button(self.controlArea, self, "&Apply Settings", callback = self.applySettings, disabled=0)

        self.resize(100,250)
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):
        "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.GeneralTab = self.SettingsTab = self.controlArea

        self.graph = OWDistributionGraph(self, self.mainArea)
        # Set a fixed minimum width. This disables the dynamic minimumSizeHint
        # from the layout, which can return a uselessly large width for the
        # x axis when showing a discrete variable with many values.
        self.graph.setMinimumWidth(250)

        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()

        self.barSize = 50

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

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

        b = OWGUI.widgetBox(self.controlArea, "Variable", addSpace=True)
        self.variablesQCB = OWGUI.comboBox(b,
                                           self,
                                           "attribute",
                                           valueType=str,
                                           sendSelectedValue=True,
                                           callback=self.setVariable)
        OWGUI.widgetLabel(b, "Displayed outcomes")
        self.outcomesQLB = OWGUI.listBox(
            b,
            self,
            "visibleOutcomes",
            "outcomes",
            selectionMode=QListWidget.MultiSelection,
            callback=self.outcomeSelectionChange)

        # GUI connections
        # options dialog connections
        #        b = OWGUI.widgetBox(self.SettingsTab, "Bars")
        #        OWGUI.spin(b, self, "numberOfBars", label="Number of bars", min=5, max=60, step=5, callback=self.setNumberOfBars, callbackOnReturn=True)
        #        self.numberOfBarsSlider = OWGUI.hSlider(self.SettingsTab, self, 'numberOfBars', box='Number of bars', minValue=5, maxValue=60, step=5, callback=self.setNumberOfBars, ticks=5)
        #        self.numberOfBarsSlider.setTracking(0) # no change until the user stop dragging the slider

        #        self.barSizeSlider = OWGUI.hSlider(self.SettingsTab, self, 'barSize', box="Bar size", minValue=30, maxValue=100, step=5, callback=self.setBarSize, ticks=10)
        #        OWGUI.spin(b, self, "barSize", label="Bar size", min=30, max=100, step=5, callback=self.setBarSize, callbackOnReturn=True)

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

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

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

        OWGUI.checkBox(box,
                       self,
                       'graph.showContinuousClassGraph',
                       'Show continuous class graph',
                       callback=self.setShowContinuousClassGraph)
        OWGUI.spin(box,
                   self,
                   "numberOfBars",
                   label="Number of bars",
                   min=5,
                   max=60,
                   step=5,
                   callback=self.setNumberOfBars,
                   callbackOnReturn=True)

        self.probabilityPlotBox = box5 = OWGUI.widgetBox(
            self.SettingsTab, "Probability plot")
        self.showProb = OWGUI.checkBox(box5,
                                       self,
                                       'showProbabilities',
                                       'Show probabilities',
                                       callback=self.setShowProbabilities)
        self.targetQCB = OWGUI.comboBox(OWGUI.indentedBox(
            box5, sep=OWGUI.checkButtonOffsetHint(self.showProb)),
                                        self,
                                        "targetValue",
                                        label="Target value",
                                        valueType=int,
                                        callback=self.setTarget)

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

        self.showYPaxisCheck = OWGUI.checkBox(box6,
                                              self,
                                              'showYPaxisTitle',
                                              'Axis title',
                                              callback=self.setShowYPaxisTitle)
        self.yPaxisEdit = OWGUI.lineEdit(box6,
                                         self,
                                         'yPaxisTitle',
                                         callback=self.setYPaxisTitle,
                                         enterPlaceholder=True)
        self.confIntCheck = OWGUI.checkBox(
            box5,
            self,
            'showConfidenceIntervals',
            'Show confidence intervals',
            callback=self.setShowConfidenceIntervals)
        self.cbSmooth = OWGUI.checkBox(box5,
                                       self,
                                       'smoothLines',
                                       'Smooth probability lines',
                                       callback=self.setSmoothLines)
        self.showProb.disables = [
            self.showYPaxisCheck, self.yPaxisEdit, self.confIntCheck,
            self.targetQCB, self.cbSmooth
        ]
        self.showProb.makeConsistent()

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

        OWGUI.rubber(self.SettingsTab)

        #add controls to self.controlArea widget

        self.icons = self.createAttributeIconDict()

        self.graph.numberOfBars = self.numberOfBars
        self.graph.barSize = self.barSize
        self.graph.setShowMainTitle(self.showMainTitle)
        self.graph.setShowXaxisTitle(self.showXaxisTitle)
        self.graph.setShowYLaxisTitle(self.showYaxisTitle)
        self.graph.setShowYRaxisTitle(self.showYPaxisTitle)
        self.graph.setMainTitle(self.mainTitle)
        self.graph.setXaxisTitle(self.xaxisTitle)
        self.graph.setYLaxisTitle(self.yaxisTitle)
        self.graph.setYRaxisTitle(self.yPaxisTitle)
        self.graph.showProbabilities = self.showProbabilities
        self.graph.showConfidenceIntervals = self.showConfidenceIntervals
        self.graph.smoothLines = self.smoothLines
        self.graph.lineWidth = self.lineWidth
        #self.graph.variableContinuous = self.VariableContinuous
        self.graph.targetValue = self.targetValue
    def __init__(self,parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "Association rules viewer")

        self.inputs = [("Association Rules", orange.AssociationRules, self.arules)]
        self.outputs = [("Association Rules", orange.AssociationRules), ("Covered Data", ExampleTable), ("Matching Data", ExampleTable), ("Mismatched Data", ExampleTable)]

        self.showWholeRules = 1
        self.treeDepth = 2
        self.autoSend = True
        self.dataChanged = False
        self.purgeAttributes = True
        self.purgeClasses = True

        self.nRules = self.nSelectedRules = self.nSelectedExamples = self.nMatchingExamples = self.nMismatchingExamples = ""
        
        self.showsupport = self.showconfidence = 1
        self.showlift = self.showleverage = self.showstrength = self.showcoverage = 0
        self.loadSettings()

#        self.grid = QGridLayout()
#        rightUpRight = OWGUI.widgetBox(self.mainArea, box="Shown measures", orientation = self.grid)
#        self.cbMeasures = [OWGUI.checkBox(rightUpRight, self, "show"+attr, long, callback = self.showHideColumn, addToLayout = 0) for long, short, attr in self.measures]
#        for i, cb in enumerate(self.cbMeasures):
#            self.grid.addWidget(cb, i % 2, i / 2)

        box = OWGUI.widgetBox(self.mainArea, orientation = 0)
        OWGUI.widgetLabel(box, "Shown measures: ")
        self.cbMeasures = [OWGUI.checkBox(box, self, "show"+attr, long+"   ", callback = self.showHideColumn) for long, short, attr in self.measures]
        OWGUI.rubber(box)

        self.treeRules = QTreeWidget(self.mainArea)
        self.mainArea.layout().addWidget(self.treeRules)
        self.treeRules.setSelectionMode (QTreeWidget.ExtendedSelection)
        self.treeRules.setHeaderLabels(["Rules"] + [m[1] for m in self.measures])
        self.treeRules.setAllColumnsShowFocus ( 1)
        self.treeRules.setAlternatingRowColors(1) 
        self.showHideColumn()
        self.connect(self.treeRules,SIGNAL("itemSelectionChanged()"),self. selectionChanged)

        box = OWGUI.widgetBox(self.controlArea, "Info", addSpace = True)
        OWGUI.label(box, self, "Number of rules: %(nRules)s")
        OWGUI.label(box, self, "Selected rules: %(nSelectedRules)s")
        OWGUI.label(box, self, "Selected examples: %(nSelectedExamples)s")
        ibox = OWGUI.indentedBox(box)
        OWGUI.label(ibox, self, "... matching: %(nMatchingExamples)s")
        OWGUI.label(ibox, self, "... mismatching: %(nMismatchingExamples)s")

        box = OWGUI.widgetBox(self.controlArea, "Options", addSpace = True)
        OWGUI.spin(box, self, "treeDepth", label = "Tree depth", min = 0, max = 10, step = 1, callback = self.displayRules, callbackOnReturn = True)
        OWGUI.separator(box)
        OWGUI.checkBox(box, self, "showWholeRules", "Display whole rules", callback = self.setWholeRules)

        OWGUI.rubber(self.controlArea)

        boxSettings = OWGUI.widgetBox(self.controlArea, 'Send selection')
        OWGUI.checkBox(boxSettings, self, "purgeAttributes", "Purge attribute values/attributes", box=None, callback=self.purgeChanged)
        self.purgeClassesCB = OWGUI.checkBox(OWGUI.indentedBox(boxSettings), self, "purgeClasses", "Purge class attribute", callback=self.purgeChanged)
        if not self.purgeAttributes:
            self.purgeClassesCB.setEnabled(False)
            self.oldPurgeClasses = False

        cbSendAuto = OWGUI.checkBox(boxSettings, self, "autoSend", "Send immediately", box=None)
        btnUpdate = OWGUI.button(boxSettings, self, "Send", self.sendData, default=True)
        OWGUI.setStopper(self, btnUpdate, cbSendAuto, "dataChanged", self.sendData)
        
        self.rules = None
    def __init__(self, parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "Predictions")

        self.callbackDeposit = []
        self.inputs = [("Data", ExampleTable, self.setData), ("Predictors", orange.Classifier, self.setPredictor, Multiple)]
        self.outputs = [("Predictions", ExampleTable)]
        self.predictors = {}

        # saveble settings
        self.showProb = 1;
        self.showClass = 1
        self.ShowAttributeMethod = 0
        self.sendOnChange = 1
        self.classes = []
        self.selectedClasses = []
        self.loadSettings()
        self.datalabel = "N/A"
        self.predictorlabel = "N/A"
        self.tasklabel = "N/A"
        self.precision = 2
        self.doPrediction = False
        self.outvar = None # current output variable (set by the first predictor/data set send in)

        self.data = None
        self.changedFlag = False
        
        self.loadSettings()

        # GUI - Options

        # Options - classification
        ibox = OWGUI.widgetBox(self.controlArea, "Info")
        OWGUI.label(ibox, self, "Data: %(datalabel)s")
        OWGUI.label(ibox, self, "Predictors: %(predictorlabel)s")
        OWGUI.label(ibox, self, "Task: %(tasklabel)s")
        OWGUI.separator(self.controlArea)
        
        self.copt = OWGUI.widgetBox(self.controlArea, "Options (classification)")
        self.copt.setDisabled(1)
        cb = OWGUI.checkBox(self.copt, self, 'showProb', "Show predicted probabilities", callback=self.setPredictionDelegate)#self.updateTableOutcomes)

#        self.lbClasses = OWGUI.listBox(self.copt, self, selectionMode = QListWidget.MultiSelection, callback = self.updateTableOutcomes)
        ibox = OWGUI.indentedBox(self.copt, sep=OWGUI.checkButtonOffsetHint(cb))
        self.lbcls = OWGUI.listBox(ibox, self, "selectedClasses", "classes",
                                   callback=[self.setPredictionDelegate, self.checksendpredictions],
#                                   callback=[self.updateTableOutcomes, self.checksendpredictions],
                                   selectionMode=QListWidget.MultiSelection)
        self.lbcls.setFixedHeight(50)

        OWGUI.spin(ibox, self, "precision", 1, 6, label="No. of decimals: ",
                   orientation=0, callback=self.setPredictionDelegate) #self.updateTableOutcomes)
        
        cb.disables.append(ibox)
        ibox.setEnabled(bool(self.showProb))

        OWGUI.checkBox(self.copt, self, 'showClass', "Show predicted class",
                       callback=[self.setPredictionDelegate, self.checksendpredictions])
#                       callback=[self.updateTableOutcomes, self.checksendpredictions])

        OWGUI.separator(self.controlArea)

        self.att = OWGUI.widgetBox(self.controlArea, "Data attributes")
        OWGUI.radioButtonsInBox(self.att, self, 'ShowAttributeMethod', ['Show all', 'Hide all'], callback=lambda :self.setDataModel(self.data)) #self.updateAttributes)
        self.att.setDisabled(1)
        OWGUI.rubber(self.controlArea)

        OWGUI.separator(self.controlArea)
        self.outbox = OWGUI.widgetBox(self.controlArea, "Output")
        
        b = self.commitBtn = OWGUI.button(self.outbox, self, "Send Predictions", callback=self.sendpredictions, default=True)
        cb = OWGUI.checkBox(self.outbox, self, 'sendOnChange', 'Send automatically')
        OWGUI.setStopper(self, b, cb, "changedFlag", callback=self.sendpredictions)
        OWGUI.checkBox(self.outbox, self, "doPrediction", "Replace/add predicted class",
                       tooltip="Apply the first predictor to input examples and replace/add the predicted value as the new class variable.",
                       callback=self.checksendpredictions)

        self.outbox.setDisabled(1)

        ## GUI table

        self.splitter = splitter = QSplitter(Qt.Horizontal, self.mainArea)
        self.dataView = QTableView()
        self.predictionsView = QTableView()
        
        self.dataView.verticalHeader().setDefaultSectionSize(22)
        self.dataView.setHorizontalScrollMode(QTableWidget.ScrollPerPixel)
        self.dataView.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.dataView.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        
        self.predictionsView.verticalHeader().setDefaultSectionSize(22)
        self.predictionsView.setHorizontalScrollMode(QTableWidget.ScrollPerPixel)
        self.predictionsView.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self.predictionsView.verticalHeader().hide()
        
        
#        def syncVertical(value):
#            """ sync vertical scroll positions of the two views
#            """
#            v1 = self.predictionsView.verticalScrollBar().value()
#            if v1 != value:
#                self.predictionsView.verticalScrollBar().setValue(value)
#            v2 = self.dataView.verticalScrollBar().value()
#            if v2 != value:
#                self.dataView.verticalScrollBar().setValue(v1)
                
        self.connect(self.dataView.verticalScrollBar(), SIGNAL("valueChanged(int)"), self.syncVertical)
        self.connect(self.predictionsView.verticalScrollBar(), SIGNAL("valueChanged(int)"), self.syncVertical)
        
        splitter.addWidget(self.dataView)
        splitter.addWidget(self.predictionsView)
        splitter.setHandleWidth(3)
        splitter.setChildrenCollapsible(False)
        self.mainArea.layout().addWidget(splitter)
        
        self.spliter_restore_state = -1, 0
        self.dataModel = None
        self.predictionsModel = None
        
        self.resize(800, 600)
        
        self.handledAllSignalsFlag = False
Ejemplo n.º 47
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self,parent,signalManager,"CN2", wantMainArea = 0, resizingEnabled = 0)

        self.inputs = [("Data", ExampleTable, self.dataset), ("Preprocess", PreprocessedLearner, self.setPreprocessor)]
        self.outputs = [("Learner", orange.Learner),("Classifier",orange.Classifier),("Unordered CN2 Classifier", orngCN2.CN2UnorderedClassifier)]
        self.QualityButton = 0
        self.CoveringButton = 0
        self.Alpha = 0.05
        self.stepAlpha = 0.2
        self.BeamWidth = 5
        self.MinCoverage = 0
        self.MaxRuleLength = 0
        self.useMaxRuleLength = False
        self.Weight = 0.9
        self.m = 2
        self.name = "CN2 rules"
        self.loadSettings()

        self.data=None
        self.preprocessor = None

        ##GUI
        labelWidth = 150
        self.learnerName = OWGUI.lineEdit(self.controlArea, self, "name", box="Learner/classifier name", tooltip="Name to be used by other widgets to identify the learner/classifier")
        #self.learnerName.setText(self.name)
        OWGUI.separator(self.controlArea)

        self.ruleQualityBG = OWGUI.widgetBox(self.controlArea, "Rule quality estimation")
        self.ruleQualityBG.buttons = []

        OWGUI.separator(self.controlArea)
        self.ruleValidationGroup = OWGUI.widgetBox(self.controlArea, "Pre-prunning (LRS)")

        OWGUI.separator(self.controlArea)
        OWGUI.spin(self.controlArea, self, "BeamWidth", 1, 100, box="Beam width", tooltip="The width of the search beam\n(number of rules to be specialized)")

        OWGUI.separator(self.controlArea)
        self.coveringAlgBG = OWGUI.widgetBox(self.controlArea, "Covering algorithm")
        self.coveringAlgBG.buttons = []

        """
        self.ruleQualityBG=OWGUI.radioButtonsInBox(self.ruleQualityGroup, self, "QualityButton",
                            btnLabels=["Laplace","m-estimate","WRACC"],
                            box="Rule quality", callback=self.qualityButtonPressed,
                            tooltips=["Laplace rule evaluator", "m-estimate rule evaluator",
                            "WRACC rule evaluator"])
        self.mSpin=Spin=OWGUI.spin(self.ruleQualityGroup, self, "m", 0, 100, label="m",
                orientation="horizontal", labelWidth=labelWidth-100, tooltip="m value for m estimate rule evaluator")
        """

        b1 = QRadioButton("Laplace", self.ruleQualityBG); self.ruleQualityBG.layout().addWidget(b1)
        g = OWGUI.widgetBox(self.ruleQualityBG, orientation = "horizontal");
        b2 = QRadioButton("m-estimate", g)
        g.layout().addWidget(b2)
        self.mSpin = OWGUI.doubleSpin(g,self,"m",0,100)
        b3 = QRadioButton("EVC", self.ruleQualityBG)
        self.ruleQualityBG.layout().addWidget(b3)
        b4 = QRadioButton("WRACC", self.ruleQualityBG)
        self.ruleQualityBG.layout().addWidget(b4)
        self.ruleQualityBG.buttons = [b1, b2, b3, b4]

        for i, button in enumerate([b1, b2, b3, b4]):
            self.connect(button, SIGNAL("clicked()"), lambda v=i: self.qualityButtonPressed(v))

        OWGUI.doubleSpin(self.ruleValidationGroup, self, "Alpha", 0, 1,0.001, label="Alpha (vs. default rule)",
                orientation="horizontal", labelWidth=labelWidth,
                tooltip="Required significance of the difference between the class distribution on all example and covered examples")
        OWGUI.doubleSpin(self.ruleValidationGroup, self, "stepAlpha", 0, 1,0.001, label="Stopping Alpha (vs. parent rule)",
                orientation="horizontal", labelWidth=labelWidth,
                tooltip="Required significance of each specialization of a rule.")
        OWGUI.spin(self.ruleValidationGroup, self, "MinCoverage", 0, 100,label="Minimum coverage",
                orientation="horizontal", labelWidth=labelWidth, tooltip=
                "Minimum number of examples a rule must\ncover (use 0 for not setting the limit)")
        OWGUI.checkWithSpin(self.ruleValidationGroup, self, "Maximal rule length", 0, 100, "useMaxRuleLength", "MaxRuleLength", labelWidth=labelWidth,
                            tooltip="Maximal number of conditions in the left\npart of the rule (use 0 for don't care)")

        """
        self.coveringAlgBG=OWGUI.radioButtonsInBox(self.coveringAlgGroup, self, "CoveringButton",
                            btnLabels=["Exclusive covering ","Weighted Covering"],
                            tooltips=["Each example will only be used once\n for the construction of a rule",
                                      "Examples can take part in the construction\n of many rules(CN2-SD Algorithm)"],
                            box="Covering algorithm", callback=self.coveringAlgButtonPressed)
        self.weightSpin=OWGUI.doubleSpin(self.coveringAlgGroup, self, "Weight",0, 0.95,0.05,label= "Weight",
                orientation="horizontal", labelWidth=labelWidth, tooltip=
                "Multiplication constant by which the weight of\nthe example will be reduced")
        """

        B1 = QRadioButton("Exclusive covering", self.coveringAlgBG); self.coveringAlgBG.layout().addWidget(B1)
        g = OWGUI.widgetBox(self.coveringAlgBG, orientation = "horizontal")
        B2 = QRadioButton("Weighted covering", g); g.layout().addWidget(B2)
        self.coveringAlgBG.buttons = [B1, B2]
        self.weightSpin=OWGUI.doubleSpin(g,self,"Weight",0,0.95,0.05)

        for i, button in enumerate([B1, B2]):
            self.connect(button, SIGNAL("clicked()"), lambda v=i: self.coveringAlgButtonPressed(v))

        OWGUI.separator(self.controlArea)
        self.btnApply = OWGUI.button(self.controlArea, self, "&Apply", callback=self.applySettings, default=True)

        self.Alpha=float(self.Alpha)
        self.stepAlpha=float(self.stepAlpha)
        self.Weight=float(self.Weight)

        #self.ruleQualityBG.buttons[self.QualityButton].setChecked(1)
        self.qualityButtonPressed(self.QualityButton)
        self.coveringAlgButtonPressed(self.CoveringButton)
        self.resize(100,100)
        self.setLearner()
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager,
                          "Association rules viewer")

        self.inputs = [("Association Rules", orange.AssociationRules,
                        self.arules)]
        self.outputs = [("Association Rules", orange.AssociationRules),
                        ("Covered Data", ExampleTable),
                        ("Matching Data", ExampleTable),
                        ("Mismatched Data", ExampleTable)]

        self.showWholeRules = 1
        self.treeDepth = 2
        self.autoSend = True
        self.dataChanged = False
        self.purgeAttributes = True
        self.purgeClasses = True

        self.nRules = self.nSelectedRules = self.nSelectedExamples = self.nMatchingExamples = self.nMismatchingExamples = ""

        self.showsupport = self.showconfidence = 1
        self.showlift = self.showleverage = self.showstrength = self.showcoverage = 0
        self.loadSettings()

        #        self.grid = QGridLayout()
        #        rightUpRight = OWGUI.widgetBox(self.mainArea, box="Shown measures", orientation = self.grid)
        #        self.cbMeasures = [OWGUI.checkBox(rightUpRight, self, "show"+attr, long, callback = self.showHideColumn, addToLayout = 0) for long, short, attr in self.measures]
        #        for i, cb in enumerate(self.cbMeasures):
        #            self.grid.addWidget(cb, i % 2, i / 2)

        box = OWGUI.widgetBox(self.mainArea, orientation=0)
        OWGUI.widgetLabel(box, "Shown measures: ")
        self.cbMeasures = [
            OWGUI.checkBox(box,
                           self,
                           "show" + attr,
                           long + "   ",
                           callback=self.showHideColumn)
            for long, short, attr in self.measures
        ]
        OWGUI.rubber(box)

        self.treeRules = QTreeWidget(self.mainArea)
        self.mainArea.layout().addWidget(self.treeRules)
        self.treeRules.setSelectionMode(QTreeWidget.ExtendedSelection)
        self.treeRules.setHeaderLabels(["Rules"] +
                                       [m[1] for m in self.measures])
        self.treeRules.setAllColumnsShowFocus(1)
        self.treeRules.setAlternatingRowColors(1)
        self.showHideColumn()
        self.connect(self.treeRules, SIGNAL("itemSelectionChanged()"),
                     self.selectionChanged)

        box = OWGUI.widgetBox(self.controlArea, "Info", addSpace=True)
        OWGUI.label(box, self, "Number of rules: %(nRules)s")
        OWGUI.label(box, self, "Selected rules: %(nSelectedRules)s")
        OWGUI.label(box, self, "Selected examples: %(nSelectedExamples)s")
        ibox = OWGUI.indentedBox(box)
        OWGUI.label(ibox, self, "... matching: %(nMatchingExamples)s")
        OWGUI.label(ibox, self, "... mismatching: %(nMismatchingExamples)s")

        box = OWGUI.widgetBox(self.controlArea, "Options", addSpace=True)
        OWGUI.spin(box,
                   self,
                   "treeDepth",
                   label="Tree depth",
                   min=0,
                   max=10,
                   step=1,
                   callback=self.displayRules,
                   callbackOnReturn=True)
        OWGUI.separator(box)
        OWGUI.checkBox(box,
                       self,
                       "showWholeRules",
                       "Display whole rules",
                       callback=self.setWholeRules)

        OWGUI.rubber(self.controlArea)

        boxSettings = OWGUI.widgetBox(self.controlArea, 'Send selection')
        OWGUI.checkBox(boxSettings,
                       self,
                       "purgeAttributes",
                       "Purge attribute values/attributes",
                       box=None,
                       callback=self.purgeChanged)
        self.purgeClassesCB = OWGUI.checkBox(OWGUI.indentedBox(boxSettings),
                                             self,
                                             "purgeClasses",
                                             "Purge class attribute",
                                             callback=self.purgeChanged)
        if not self.purgeAttributes:
            self.purgeClassesCB.setEnabled(False)
            self.oldPurgeClasses = False

        cbSendAuto = OWGUI.checkBox(boxSettings,
                                    self,
                                    "autoSend",
                                    "Send immediately",
                                    box=None)
        btnUpdate = OWGUI.button(boxSettings,
                                 self,
                                 "Send",
                                 self.sendData,
                                 default=True)
        OWGUI.setStopper(self, btnUpdate, cbSendAuto, "dataChanged",
                         self.sendData)

        self.rules = None
Ejemplo n.º 49
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, "Predictions")

        self.callbackDeposit = []
        self.inputs = [("Examples", ExampleTable, self.setData),
                       ("Predictors", orange.Classifier, self.setPredictor,
                        Multiple)]
        self.outputs = [("Predictions", ExampleTable)]
        self.predictors = {}

        # saveble settings
        self.showProb = 1
        self.showClass = 1
        self.ShowAttributeMethod = 0
        self.sendOnChange = 1
        self.classes = []
        self.selectedClasses = []
        self.loadSettings()
        self.datalabel = "N/A"
        self.predictorlabel = "N/A"
        self.tasklabel = "N/A"
        self.precision = 2
        self.outvar = None  # current output variable (set by the first predictor/data set send in)

        self.data = None

        # GUI - Options

        # Options - classification
        ibox = OWGUI.widgetBox(self.controlArea, "Info")
        OWGUI.label(ibox, self, "Data: %(datalabel)s")
        OWGUI.label(ibox, self, "Predictors: %(predictorlabel)s")
        OWGUI.label(ibox, self, "Task: %(tasklabel)s")
        OWGUI.separator(self.controlArea)

        self.copt = OWGUI.widgetBox(self.controlArea,
                                    "Options (classification)")
        self.copt.setDisabled(1)
        OWGUI.checkBox(self.copt,
                       self,
                       'showProb',
                       "Show predicted probabilities",
                       callback=self.updateTableOutcomes)

        #        self.lbClasses = OWGUI.listBox(self.copt, self, selectionMode = QListWidget.MultiSelection, callback = self.updateTableOutcomes)

        self.lbcls = OWGUI.listBox(
            self.copt,
            self,
            "selectedClasses",
            "classes",
            callback=[self.updateTableOutcomes, self.checksendpredictions],
            selectionMode=QListWidget.MultiSelection)
        self.lbcls.setFixedHeight(50)

        OWGUI.spin(self.copt,
                   self,
                   "precision",
                   1,
                   6,
                   label="No. of decimals: ",
                   orientation=0,
                   callback=self.updateTableOutcomes)

        OWGUI.checkBox(
            self.copt,
            self,
            'showClass',
            "Show predicted class",
            callback=[self.updateTableOutcomes, self.checksendpredictions])

        # Options - regression
        # self.ropt = QVButtonGroup("Options (regression)", self.controlArea)
        # OWGUI.checkBox(self.ropt, self, 'showClass', "Show predicted class",
        #                callback=[self.updateTableOutcomes, self.checksendpredictions])
        # self.ropt.hide()

        OWGUI.separator(self.controlArea)

        self.att = OWGUI.widgetBox(self.controlArea, "Data attributes")
        OWGUI.radioButtonsInBox(self.att,
                                self,
                                'ShowAttributeMethod',
                                ['Show all', 'Hide all'],
                                callback=self.updateAttributes)
        self.att.setDisabled(1)
        OWGUI.rubber(self.controlArea)

        OWGUI.separator(self.controlArea)
        self.outbox = OWGUI.widgetBox(self.controlArea, "Output")

        self.commitBtn = OWGUI.button(self.outbox,
                                      self,
                                      "Send Predictions",
                                      callback=self.sendpredictions)
        OWGUI.checkBox(self.outbox, self, 'sendOnChange', 'Send automatically')

        self.outbox.setDisabled(1)

        # GUI - Table
        self.table = OWGUI.table(self.mainArea,
                                 selectionMode=QTableWidget.NoSelection)

        self.table.setItemDelegate(OWGUI.TableBarItem(self))

        self.header = self.table.horizontalHeader()
        self.vheader = self.table.verticalHeader()
        # manage sorting (not correct, does not handle real values)
        self.connect(self.header, SIGNAL("sectionPressed(int)"), self.sort)
        self.sortby = -1
        self.resize(800, 600)
Ejemplo n.º 50
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):
        OWWidget.__init__(self, parent, signalManager, 'LearningCurveC')

        self.inputs = [("Data", ExampleTable, self.dataset),
                       ("Learner", orange.Learner, self.learner, Multiple)]

        self.folds = 5  # cross validation folds
        self.steps = 10  # points in the learning curve
        self.scoringF = 0  # scoring function
        self.commitOnChange = 1  # compute curve on any change of parameters
        self.graphPointSize = 5  # size of points in the graphs
        self.graphDrawLines = 1  # draw lines between points in the graph
        self.graphShowGrid = 1  # show gridlines in the graph
        self.selectedLearners = []
        self.loadSettings()

        warnings.filterwarnings("ignore", ".*builtin attribute.*",
                                orange.AttributeWarning)

        self.setCurvePoints(
        )  # sets self.curvePoints, self.steps equidistantpoints from 1/self.steps to 1
        self.scoring = [("Classification Accuracy", orngStat.CA),
                        ("AUC", orngStat.AUC),
                        ("BrierScore", orngStat.BrierScore),
                        ("Information Score", orngStat.IS),
                        ("Sensitivity", orngStat.sens),
                        ("Specificity", orngStat.spec)]
        self.learners = [
        ]  # list of current learners from input channel, tuples (id, learner)
        self.data = None  # data on which to construct the learning curve
        self.curves = [
        ]  # list of evaluation results (one per learning curve point)
        self.scores = []  # list of current scores, learnerID:[learner scores]

        # GUI
        box = OWGUI.widgetBox(self.controlArea, "Info")
        self.infoa = OWGUI.widgetLabel(box, 'No data on input.')
        self.infob = OWGUI.widgetLabel(box, 'No learners.')

        ## class selection (classQLB)
        OWGUI.separator(self.controlArea)
        self.cbox = OWGUI.widgetBox(self.controlArea, "Learners")
        self.llb = OWGUI.listBox(self.cbox,
                                 self,
                                 "selectedLearners",
                                 selectionMode=QListWidget.MultiSelection,
                                 callback=self.learnerSelectionChanged)

        self.llb.setMinimumHeight(50)
        self.blockSelectionChanges = 0

        OWGUI.separator(self.controlArea)
        box = OWGUI.widgetBox(self.controlArea, "Evaluation Scores")
        scoringNames = [x[0] for x in self.scoring]
        OWGUI.comboBox(box,
                       self,
                       "scoringF",
                       items=scoringNames,
                       callback=self.computeScores)

        OWGUI.separator(self.controlArea)
        box = OWGUI.widgetBox(self.controlArea, "Options")
        OWGUI.spin(box,
                   self,
                   'folds',
                   2,
                   100,
                   step=1,
                   label='Cross validation folds:  ',
                   callback=lambda: self.computeCurve(self.commitOnChange))
        OWGUI.spin(box,
                   self,
                   'steps',
                   2,
                   100,
                   step=1,
                   label='Learning curve points:  ',
                   callback=[
                       self.setCurvePoints,
                       lambda: self.computeCurve(self.commitOnChange)
                   ])

        OWGUI.checkBox(box, self, 'commitOnChange',
                       'Apply setting on any change')
        self.commitBtn = OWGUI.button(box,
                                      self,
                                      "Apply Setting",
                                      callback=self.computeCurve,
                                      disabled=1)

        # start of content (right) area
        tabs = OWGUI.tabWidget(self.mainArea)

        # graph widget
        tab = OWGUI.createTabPage(tabs, "Graph")
        self.graph = OWGraph(tab)
        self.graph.setAxisAutoScale(QwtPlot.xBottom)
        self.graph.setAxisAutoScale(QwtPlot.yLeft)
        tab.layout().addWidget(self.graph)
        self.setGraphGrid()

        # table widget
        tab = OWGUI.createTabPage(tabs, "Table")
        self.table = OWGUI.table(tab, selectionMode=QTableWidget.NoSelection)

        self.resize(550, 200)
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, "Nomogram", 1)

        #self.setWFlags(Qt.WResizeNoErase | Qt.WRepaintNoErase) #this works like magic.. no flicker during repaint!
        self.parent = parent
        #        self.setWFlags(self.getWFlags()+Qt.WStyle_Maximize)

        self.callbackDeposit = []  # deposit for OWGUI callback functions
        self.alignType = 0
        self.contType = 0
        self.yAxis = 0
        self.probability = 0
        self.verticalSpacing = 60
        self.verticalSpacingContinuous = 100
        self.diff_between_ordinal = 30
        self.fontSize = 9
        self.lineWidth = 1
        self.histogram = 0
        self.histogram_size = 10
        self.data = None
        self.cl = None
        self.confidence_check = 0
        self.confidence_percent = 95
        self.sort_type = 0

        self.loadSettings()

        self.pointsName = ["Total", "Total"]
        self.totalPointsName = ["Probability", "Probability"]
        self.bnomogram = None

        self.inputs = [("Classifier", orange.Classifier, self.classifier)]

        self.TargetClassIndex = 0
        self.targetCombo = OWGUI.comboBox(
            self.controlArea,
            self,
            "TargetClassIndex",
            " Target Class ",
            addSpace=True,
            tooltip='Select target (prediction) class in the model.',
            callback=self.setTarget)

        self.alignRadio = OWGUI.radioButtonsInBox(
            self.controlArea,
            self,
            'alignType', ['Align left', 'Align by zero influence'],
            box='Attribute placement',
            tooltips=[
                'Attributes in nomogram are left aligned',
                'Attributes are not aligned, top scale represents true (normalized) regression coefficient value'
            ],
            addSpace=True,
            callback=self.showNomogram)
        self.verticalSpacingLabel = OWGUI.spin(
            self.alignRadio,
            self,
            'verticalSpacing',
            15,
            200,
            label='Vertical spacing:',
            orientation=0,
            tooltip='Define space (pixels) between adjacent attributes.',
            callback=self.showNomogram)

        self.ContRadio = OWGUI.radioButtonsInBox(
            self.controlArea,
            self,
            'contType', ['1D projection', '2D curve'],
            'Continuous attributes',
            tooltips=[
                'Continuous attribute are presented on a single scale',
                'Two dimensional space is used to present continuous attributes in nomogram.'
            ],
            addSpace=True,
            callback=[
                lambda: self.verticalSpacingContLabel.setDisabled(
                    not self.contType), self.showNomogram
            ])

        self.verticalSpacingContLabel = OWGUI.spin(
            OWGUI.indentedBox(self.ContRadio,
                              sep=OWGUI.checkButtonOffsetHint(
                                  self.ContRadio.buttons[-1])),
            self,
            'verticalSpacingContinuous',
            15,
            200,
            label="Height",
            orientation=0,
            tooltip=
            'Define space (pixels) between adjacent 2d presentation of attributes.',
            callback=self.showNomogram)
        self.verticalSpacingContLabel.setDisabled(not self.contType)

        self.yAxisRadio = OWGUI.radioButtonsInBox(
            self.controlArea,
            self,
            'yAxis', ['Point scale', 'Log odds ratios'],
            'Scale',
            tooltips=[
                'values are normalized on a 0-100 point scale',
                'values on top axis show log-linear contribution of attribute to full model'
            ],
            addSpace=True,
            callback=self.showNomogram)

        layoutBox = OWGUI.widgetBox(self.controlArea,
                                    "Display",
                                    orientation=1,
                                    addSpace=True)

        self.probabilityCheck = OWGUI.checkBox(layoutBox,
                                               self,
                                               'probability',
                                               'Show prediction',
                                               tooltip='',
                                               callback=self.setProbability)

        self.CICheck, self.CILabel = OWGUI.checkWithSpin(
            layoutBox,
            self,
            'Confidence intervals (%):',
            min=1,
            max=99,
            step=1,
            checked='confidence_check',
            value='confidence_percent',
            checkCallback=self.showNomogram,
            spinCallback=self.showNomogram)

        self.histogramCheck, self.histogramLabel = OWGUI.checkWithSpin(
            layoutBox,
            self,
            'Show histogram, size',
            min=1,
            max=30,
            checked='histogram',
            value='histogram_size',
            step=1,
            tooltip='-(TODO)-',
            checkCallback=self.showNomogram,
            spinCallback=self.showNomogram)

        OWGUI.separator(layoutBox)
        self.sortOptions = [
            "No sorting", "Absolute importance", "Positive influence",
            "Negative influence"
        ]
        self.sortBox = OWGUI.comboBox(layoutBox,
                                      self,
                                      "sort_type",
                                      label="Sort by ",
                                      items=self.sortOptions,
                                      callback=self.sortNomogram,
                                      orientation="horizontal")

        OWGUI.rubber(self.controlArea)

        self.connect(self.graphButton, SIGNAL("clicked()"),
                     self.menuItemPrinter)

        #add a graph widget
        self.header = OWNomogramHeader(None, self.mainArea)
        self.header.setFixedHeight(60)
        self.header.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.header.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.graph = OWNomogramGraph(self.bnomogram, self.mainArea)
        self.graph.setMinimumWidth(200)
        self.graph.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.footer = OWNomogramHeader(None, self.mainArea)
        self.footer.setFixedHeight(60 * 2 + 10)
        self.footer.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.footer.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)

        self.mainArea.layout().addWidget(self.header)
        self.mainArea.layout().addWidget(self.graph)
        self.mainArea.layout().addWidget(self.footer)
        self.resize(700, 500)
        #self.repaint()
        #self.update()

        # mouse pressed flag
        self.mousepr = False