Ejemplo n.º 1
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)
    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.º 3
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.º 4
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.º 5
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)
 def __init__(self, parent=None, signalManager=None, name="Fragmenter"):
     OWWidget.__init__(self, parent, signalManager, name, wantMainArea=False)
     
     self.inputs = [("Active chemicals", ExampleTable, self.setActive), ("Inactive chemicals", ExampleTable, self.setInactive)]
     self.outputs = [("Fragments", ExampleTable)]
     
     self.minSupport = 0.2
     self.maxSupport = 0.2
     self.activeSmilesAttr = 0
     self.inactiveSmilesAttr = 0
     
     self.loadSettings()
     #  GUI
     
     box = OWGUI.widgetBox(self.controlArea, "Active Chemicals Set") 
     OWGUI.doubleSpin(box, self, "minSupport", 0.05, 0.95, step=0.05, 
                      label="Min. active frequency", 
                      tooltip="Minimal fragment frequency in the active chemicals set.",
                      callback=self.updateFreq)
     
     self.activeSmilesAttrCB = OWGUI.comboBox(box, self, "activeSmilesAttr",
                                              label="SMILES attribute",
                                              callback=self.updateAttrs)
     
     box = OWGUI.widgetBox(self.controlArea, "Inactive Chemicals Set")
     OWGUI.doubleSpin(box, self, "maxSupport", 0.05, 0.95, step=0.05,
                      label="Max. inactive frequency",
                      tooltip="Maximal fragment frequency in the inactive chemicals set.",
                      callback=self.updateFreq)
     
     self.inactiveSmilesAttrCB = OWGUI.comboBox(box, self, "inactiveSmilesAttr",
                                                label="SMILES attribute",
                                                callback=self.updateAttrs)
     
     OWGUI.button(self.controlArea, self, "Run",
                  callback=self.run)
     
     self.activeData = None
     self.inactiveData = None
     self.activeDataAttrs = []
     self.inactiveDataAttrs = []
     
     self.resize(100, 100)
Ejemplo n.º 7
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.ShowAttributeMethod = 0
        self.classes = []
        self.selectedClasses = []
        self.loadSettings()
        self.datalabel = "N/A"
        self.predictorlabel = "N/A"
        self.tasklabel = "N/A"
        self.outvar = None # current output variable (set by the first predictor/data set send in)
        self.classifications = []
        self.rindx = None        
        self.data = None
        self.verbose = 0
        self.nVarImportance = 0

        # GUI - Options

        # Options - classification
        ibox = OWGUI.widgetBox(self.controlArea, "Info")
        OWGUI.label(ibox, self, "Data: %(datalabel)s")
        OWGUI.label(ibox, self, "Predictors: %(predictorlabel)s")
        OWGUI.label(ibox, self, "Task: %(tasklabel)s")
        OWGUI.separator(ibox)
        OWGUI.label(ibox, self, "Predictions can be viewed with the 'Data Table'\nand saved with the 'Save' widget!")

        OWGUI.separator(self.controlArea)
        
        self.copt = OWGUI.widgetBox(self.controlArea,"Probabilities (classification)")
        self.copt.setDisabled(1)

        self.lbcls = OWGUI.listBox(self.copt, self, "selectedClasses", "classes",
                                   selectionMode=QListWidget.MultiSelection)
        self.lbcls.setFixedHeight(50)
        OWGUI.separator(self.controlArea)
        self.VarImportanceBox = OWGUI.doubleSpin(self.controlArea, self, "nVarImportance", 0,9999999,1, label="Variable importance",  orientation="horizontal", tooltip="The number of variables to report for each prediction.")

        OWGUI.checkBox(self.controlArea, self, 'verbose', 'Verbose', tooltip='Show detailed info while predicting. This will slow down the predictions process!') 
        OWGUI.separator(self.controlArea)
        self.outbox = OWGUI.widgetBox(self.controlArea,"Output")
        self.apply = OWGUI.button(self.outbox, self, "Apply", callback=self.sendpredictions)

        OWGUI.rubber(self.controlArea)
        self.adjustSize()
Ejemplo n.º 8
0
    def __init__ (self, parent=None, signalManager = None, name = "Logistic regression"):
        OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0, resizingEnabled = 0)

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

        self.regularizations = [ Orange.classification.logreg.LibLinearLogRegLearner.L2R_LR, Orange.classification.logreg.LibLinearLogRegLearner.L1R_LR ]
        self.regularizationsStr = [ "L2 (squared weights)", "L1 (absolute weights)" ]

        self.name = "Logistic regression"
        self.normalization = True
        self.C = 1.
        self.regularization = 0

        self.data = None
        self.preprocessor = None

        self.loadSettings()

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

        box = OWGUI.widgetBox(self.controlArea, "Regularization")

        self.regularizationCombo = OWGUI.comboBox(box, self, "regularization", items=self.regularizationsStr)

        cset = OWGUI.doubleSpin(box, self, "C", 0.01, 512.0, 0.1,
            decimals=2,
            addToLayout=True,
            label="Training error cost (C)",
            alignment=Qt.AlignRight,
            tooltip= "Weight of log-loss term (higher C means better fit on the training data)."),


        OWGUI.separator(self.controlArea)

        box = OWGUI.widgetBox(self.controlArea, "Preprocessing")

        OWGUI.checkBox(box, self, "normalization",
            label="Normalize data", 
            tooltip="Normalize data before learning.")

        OWGUI.separator(self.controlArea)

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

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

        self.applyLearner()
Ejemplo n.º 9
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.º 10
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.º 11
0
    def __init__(self, parent=None, signalManager=None, name="SVM"):
        OWWidget.__init__(self, parent, signalManager, name)
        self.inputs=[("Example Table", ExampleTable, self.setData)]
        self.outputs=[("Learner", orange.Learner),("Classifier", orange.Classifier)]   #  ,("Support Vectors", ExampleTable)]

        self.data = None
        self.name="Support Vector Machine"
        self.nMin = -1
        self.nMax = 1
        self.nClassMin = -1
        self.nClassMax = 1
        self.svm_typeGUI = None
        self.stopCritGUI = None
        self.priorsGUI = ""
        #Read default parameters from AZOrangeConfig.py file
        for par in ("kernel_type", "svm_type","gamma","C","p","epsC","epsR","stopCrit",\
                        "maxIter","nu","scaleData","scaleClass","priors","coef0","degree"):
            setattr(self, par, AZOC.CVSVMDEFAULTDICT[par])
        if self.svm_type in (103,104):
            self.eps = self.epsR
        else:
            self.eps = self.epsC
        self.setSVMTypeGUI(self.svm_type)
        self.setStopCritGUI(self.stopCrit)
        self.setPriorsGUI()#self.priors)

##scJS Added parameter needed for saving an SVM model
        self.modelFile = os.path.join(os.getcwd(),"SVM.model")
##ecJS
        OWGUI.lineEdit(self.controlArea, self, 'name', box='Learner/Classifier Name', \
                       tooltip='Name to be used by other widgets to identify your learner/classifier.<br>This should be a unique name!')
        ## scLC
        # Do not use the one class svm (type 2).
        self.svmTypeBox=b=OWGUI.widgetBox(self.controlArea,"SVM Type")
        self.svmTyperadio = OWGUI.radioButtonsInBox(b, self, "svm_typeGUI", btnLabels=["C-SVC", "nu-SVC","epsilon-SVR", "nu-SVR"], callback=self.setSVMTypeLearner)
        ## ecLC

        self.kernelBox=b=OWGUI.widgetBox(self.controlArea, "Kernel")
        self.kernelradio = OWGUI.radioButtonsInBox(b, self, "kernel_type", btnLabels=["Linear,   x.y", "Polynomial,   (g*x.y+c)^d",
                    "RBF,   exp(-g*(x-y).(x-y))", "Sigmoid,   tanh(g*x.y+c)"], callback=self.changeKernel)

        self.gcd = OWGUI.widgetBox(b, orientation="horizontal")
        self.leg = OWGUI.doubleSpin(self.gcd, self, "gamma",0.0,10.0,0.0001, label="gamma: ", orientation="horizontal", callback=self.changeKernel)
        self.led = OWGUI.doubleSpin(self.gcd, self, "coef0", 0.0,10.0,0.0001, label="  coef0: ", orientation="horizontal", callback=self.changeKernel)
        self.lec = OWGUI.doubleSpin(self.gcd, self, "degree", 0.0,10.0,0.5, label="  degree: ", orientation="horizontal", callback=self.changeKernel)

        OWGUI.separator(self.controlArea)


        #self.layout=QVBoxLayout(self.mainArea)
        self.optionsBox=b=OWGUI.widgetBox(self.mainArea, "Options", addSpace = True)
        self.cBox = OWGUI.doubleSpin(b,self, "C", 0.0, 512.0, 0.5, label="Model complexity (C)",  orientation="horizontal", tooltip="Penalty cost")
        self.cBox.control.setDecimals(3)
        self.pBox = OWGUI.doubleSpin(b,self, "p", 0.0, 10.0, 0.1, label="Tolerance (p)",  orientation="horizontal", tooltip="zero-loss width zone")
        self.pBox.control.setDecimals(3)
        self.nuBox = OWGUI.doubleSpin(b, self, "nu", 0.0,1.0,0.1, label="Complexity bound (nu)",  orientation="horizontal", tooltip="Upper bound on the ratio of support vectors")
        self.nuBox.control.setDecimals(3)        

        self.priorBox = OWGUI.lineEdit(b, self, 'priorsGUI', box='Class weights', \
                       tooltip='Ex: POS:2 , NEG:1')

        self.stopCritBox=OWGUI.widgetBox(self.optionsBox,"Stop Criteria")
        self.stopCritradio = OWGUI.radioButtonsInBox(self.stopCritBox, self, "stopCritGUI", btnLabels=["Maximum number of iterations (maxIter)", "Numeric precision (eps)"], callback=self.setStopCritLearner)
        OWGUI.doubleSpin(self.stopCritBox,self, "eps", 0.0, 0.5, 0.001, label="Numeric precision (eps)",  orientation="horizontal")
        OWGUI.doubleSpin(self.stopCritBox,self, "maxIter", 0, 100000, 1, label="Maximum number of iterations (maxIter)",  orientation="horizontal")


        self.scaleDataBox=OWGUI.checkBox(b, self, "scaleData", "Scale Data", tooltip="Scales the training data, and the input examples",callback = self.changeScaling)
        self.scaleClassBox=OWGUI.checkBox(OWGUI.indentedBox(b), self, "scaleClass", "Scale Class variable", tooltip="Scales the class variable of training data, and the output predictions",callback = self.changeScaling)
        #self.scalenMin = OWGUI.lineEdit(OWGUI.indentedBox(b), self, 'nMin', 'Var min:', orientation="horizontal", tooltip='Variables scaling minimum')
        #self.scalenMax = OWGUI.lineEdit(OWGUI.indentedBox(b), self, 'nMax', 'Var max:', orientation="horizontal", tooltip='Variables scaling maximum')
        #OWGUI.separator(OWGUI.indentedBox(b))
        self.scalenClassMin = OWGUI.lineEdit(OWGUI.indentedBox(b), self, 'nClassMin', 'Class min:', orientation="horizontal", tooltip='Class scaling minimum')
        self.scalenClassMax = OWGUI.lineEdit(OWGUI.indentedBox(b), self, 'nClassMax', 'Class max:', orientation="horizontal", tooltip='Class scaling maximum')
        OWGUI.separator(self.controlArea)

        #self.paramButton=OWGUI.button(self.controlArea, self, "Automatic parameter search", callback=self.parameterSearch,
        #                             tooltip="Automaticaly searches for parameters that optimize classifier acuracy")
        self.optionsBox.adjustSize()
        #self.layout.add(self.optionsBox)

        #OWGUI.separator(self.controlArea)

        OWGUI.button(self.controlArea, self,"&Apply", callback=self.applySettings)
##scJS Adding saving of svm models 

        # Get desired location of model file
        boxFile = OWGUI.widgetBox(self.controlArea, "Path for saving Model", addSpace = True, orientation=0)
        L1 = OWGUI.lineEdit(boxFile, self, "modelFile", labelWidth=80,  orientation = "horizontal", \
        tooltip = "Once a model is created (connect this widget with a data widget), \nit can be saved by giving a \
file name here and clicking the save button.")
        #L1.setMinimumWidth(200)
        button = OWGUI.button(boxFile, self, '...', callback = self.browseFile, disabled=0,tooltip = "Choose the dir where to save. After chosen, add a name for the model file!")
        #button.setMaximumWidth(25)

        # Save model
        OWGUI.button(self.controlArea, self,"&Save SVM model", callback=self.saveModel)

        #self.adjustSize()
        #self.loadSettings()
        self.setStopCritLearner()
        self.setSVMTypeLearner()
        self.changeKernel() 
        self.applySettings()
        self.resize(500,400)
Ejemplo n.º 12
0
    def __init__(self, parent=None, signalManager=None, title="PCA"):
        OWWidget.__init__(self, parent, signalManager, title, wantGraph=True)

        self.inputs = [("Input Data", Orange.data.Table, self.set_data)]
        self.outputs = [("Transformed Data", Orange.data.Table, Default),
                        ("Eigen Vectors", Orange.data.Table)]

        self.standardize = True
        self.max_components = 0
        self.variance_covered = 100.0
        self.use_generalized_eigenvectors = False
        self.auto_commit = False

        self.loadSettings()

        self.data = None
        self.changed_flag = False

        #####
        # GUI
        #####
        grid = QGridLayout()
        box = OWGUI.widgetBox(self.controlArea,
                              "Components Selection",
                              orientation=grid)

        label1 = QLabel("Max components", box)
        grid.addWidget(label1, 1, 0)

        sb1 = OWGUI.spin(box,
                         self,
                         "max_components",
                         0,
                         1000,
                         tooltip="Maximum number of components",
                         callback=self.on_update,
                         addToLayout=False,
                         keyboardTracking=False)
        self.max_components_spin = sb1.control
        self.max_components_spin.setSpecialValueText("All")
        grid.addWidget(sb1.control, 1, 1)

        label2 = QLabel("Variance covered", box)
        grid.addWidget(label2, 2, 0)

        sb2 = OWGUI.doubleSpin(box,
                               self,
                               "variance_covered",
                               1.0,
                               100.0,
                               1.0,
                               tooltip="Percent of variance covered.",
                               callback=self.on_update,
                               decimals=1,
                               addToLayout=False,
                               keyboardTracking=False)
        sb2.control.setSuffix("%")
        grid.addWidget(sb2.control, 2, 1)

        OWGUI.rubber(self.controlArea)

        box = OWGUI.widgetBox(self.controlArea, "Commit")
        cb = OWGUI.checkBox(box, self, "auto_commit", "Commit on any change")
        b = OWGUI.button(box, self, "Commit", callback=self.update_components)
        OWGUI.setStopper(self, b, cb, "changed_flag", self.update_components)

        self.plot = Graph()
        canvas = self.plot.canvas()
        canvas.setFrameStyle(QFrame.StyledPanel)
        self.mainArea.layout().addWidget(self.plot)
        self.plot.setAxisTitle(QwtPlot.yLeft, "Proportion of Variance")
        self.plot.setAxisTitle(QwtPlot.xBottom, "Principal Components")
        self.plot.setAxisScale(QwtPlot.yLeft, 0.0, 1.0)
        self.plot.enableGridXB(True)
        self.plot.enableGridYL(True)
        self.plot.setGridColor(Qt.lightGray)

        self.variance_curve = plot_curve("Variance",
                                         pen=QPen(Qt.red, 2),
                                         symbol=QwtSymbol.NoSymbol,
                                         xaxis=QwtPlot.xBottom,
                                         yaxis=QwtPlot.yLeft)
        self.cumulative_variance_curve = plot_curve("Cumulative Variance",
                                                    pen=QPen(Qt.darkYellow, 2),
                                                    symbol=QwtSymbol.NoSymbol,
                                                    xaxis=QwtPlot.xBottom,
                                                    yaxis=QwtPlot.yLeft)

        self.variance_curve.attach(self.plot)
        self.cumulative_variance_curve.attach(self.plot)

        self.selection_tool = CutoffControler(parent=self.plot.canvas())
        self.selection_tool.cutoffMoved.connect(self.on_cutoff_moved)

        self.graphButton.clicked.connect(self.saveToFile)
        self.components = None
        self.variances = None
        self.variances_sum = None
        self.projector_full = None
        self.currently_selected = 0

        self.resize(800, 400)
Ejemplo n.º 13
0
    def __init__(self,
                 parent=None,
                 signalManager=None,
                 name="Logistic regression"):
        OWWidget.__init__(self,
                          parent,
                          signalManager,
                          name,
                          wantMainArea=0,
                          resizingEnabled=0)

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

        self.regularizations = [
            Orange.classification.logreg.LibLinearLogRegLearner.L2R_LR,
            Orange.classification.logreg.LibLinearLogRegLearner.L1R_LR
        ]
        self.regularizationsStr = [
            "L2 (squared weights)", "L1 (absolute weights)"
        ]

        self.name = "Logistic regression"
        self.normalization = True
        self.C = 1.
        self.regularization = 0

        self.data = None
        self.preprocessor = None

        self.loadSettings()

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

        box = OWGUI.widgetBox(self.controlArea, "Regularization")

        self.regularizationCombo = OWGUI.comboBox(
            box, self, "regularization", items=self.regularizationsStr)

        cset = OWGUI.doubleSpin(
            box,
            self,
            "C",
            0.01,
            512.0,
            0.1,
            decimals=2,
            addToLayout=True,
            label="Training error cost (C)",
            alignment=Qt.AlignRight,
            tooltip=
            "Weight of log-loss term (higher C means better fit on the training data)."
        ),

        OWGUI.separator(self.controlArea)

        box = OWGUI.widgetBox(self.controlArea, "Preprocessing")

        OWGUI.checkBox(box,
                       self,
                       "normalization",
                       label="Normalize data",
                       tooltip="Normalize data before learning.")

        OWGUI.separator(self.controlArea)

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

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

        self.applyLearner()
    def __init__(self, parent=None, signalManager=None):
        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, name="Sens profile"):
        OWWidget.__init__(self, parent, signalManager, name, wantMainArea=False)
        self.inputs = [("Sensitivity", ExampleTable, self.sensData)]
        self.outputs = [("Molecule fragmetns", ExampleTable), ("Slim-based molecular profiles", ExampleTable), ("Molecule-based slim profiles", ExampleTable), ("Slim-based fragment profiles", ExampleTable), ("Fragment-based slim profiles", ExampleTable)]

        self.aspectNum = 0
        self.fragFreq = 0.1
        self.smilesFileName = ""
        self.slimsOnly = 1
        self.maxTerms = 100
        
        self.loadSettings()
        
        OWGUI.radioButtonsInBox(self.controlArea, self, "aspectNum",
                                ["Process", "Function", "Component"], "Aspect")
        
        OWGUI.checkBox(self.controlArea, self, "slimsOnly", "Slims only",
                       tooltip="Search for slim GO terms only")
        
        OWGUI.spin(self.controlArea, self, "maxTerms", 10, 1000, box="Number of terms",
                   tooltip="Maximum number of GO terms")
        
        self.findTermsButton = OWGUI.button(self.controlArea, self, "Find terms",
                                            tooltip="Run term search",
                                            callback=self.findTerms)
        
        OWGUI.button(self.controlArea, self, "Load selected terms",
                     tooltip="Load selected terms from a file",
                     callback=self.loadSelectedTerms)
        
        OWGUI.doubleSpin(self.controlArea, self, "fragFreq", 0.05, 0.95, 0.05,
                         box="Fragment frequency",
                         tooltip="Minimum fragment frequency")
        
        self.findFragmentsButton = OWGUI.button(self.controlArea, self, "Find fragments",
                                                tooltip="Run fragment search", 
                                                callback=self.findFragments)
        
        OWGUI.button(self.controlArea, self, "Load smiles",
                     tooltip="Load fragment SMILES descriptors from a file",
                     callback=self.loadSmiles)
        
        self.commitButton = OWGUI.button(self.controlArea, self, "Commit",
                                         callback=self.commitData)
        
        self.findTermsButton.setEnabled(0)
        self.findFragmentsButton.setEnabled(0)
        self.commitButton.setEnabled(0)
        self.resize(100,100)
        
        self.fragments = []
        self.sensDict = {}
        self.smilesDict = {}
        self.reverseSmilesDict = {}
        self.data = None
        self.fragmentMap = None
        self.terms = None
        self.ontology = None
        self.annotations = None
        self.selectedTerms = []
        self.lastDir = os.path.expanduser("~/")
        
        
        self.loadSmiles(self.smilesFileName)
        
        self.loadSettings()
Ejemplo n.º 16
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.ShowAttributeMethod = 0
        self.classes = []
        self.selectedClasses = []
        self.loadSettings()
        self.datalabel = "N/A"
        self.predictorlabel = "N/A"
        self.tasklabel = "N/A"
        self.outvar = None  # current output variable (set by the first predictor/data set send in)
        self.classifications = []
        self.rindx = None
        self.data = None
        self.verbose = 0
        self.nVarImportance = 0

        # GUI - Options

        # Options - classification
        ibox = OWGUI.widgetBox(self.controlArea, "Info")
        OWGUI.label(ibox, self, "Data: %(datalabel)s")
        OWGUI.label(ibox, self, "Predictors: %(predictorlabel)s")
        OWGUI.label(ibox, self, "Task: %(tasklabel)s")
        OWGUI.separator(ibox)
        OWGUI.label(
            ibox, self,
            "Predictions can be viewed with the 'Data Table'\nand saved with the 'Save' widget!"
        )

        OWGUI.separator(self.controlArea)

        self.copt = OWGUI.widgetBox(self.controlArea,
                                    "Probabilities (classification)")
        self.copt.setDisabled(1)

        self.lbcls = OWGUI.listBox(self.copt,
                                   self,
                                   "selectedClasses",
                                   "classes",
                                   selectionMode=QListWidget.MultiSelection)
        self.lbcls.setFixedHeight(50)
        OWGUI.separator(self.controlArea)
        self.VarImportanceBox = OWGUI.doubleSpin(
            self.controlArea,
            self,
            "nVarImportance",
            0,
            9999999,
            1,
            label="Variable importance",
            orientation="horizontal",
            tooltip="The number of variables to report for each prediction.")

        OWGUI.checkBox(
            self.controlArea,
            self,
            'verbose',
            'Verbose',
            tooltip=
            'Show detailed info while predicting. This will slow down the predictions process!'
        )
        OWGUI.separator(self.controlArea)
        self.outbox = OWGUI.widgetBox(self.controlArea, "Output")
        self.apply = OWGUI.button(self.outbox,
                                  self,
                                  "Apply",
                                  callback=self.sendpredictions)

        OWGUI.rubber(self.controlArea)
        self.adjustSize()
    def __init__(self, parent=None, signalManager=None, title="PCA"):
        OWWidget.__init__(self, parent, signalManager, title, wantGraph=True)

        self.inputs = [("Input Data", Orange.data.Table, self.set_data)]
        self.outputs = [("Transformed Data", Orange.data.Table, Default),
                        ("Eigen Vectors", Orange.data.Table)]

        self.standardize = True
        self.max_components = 0
        self.variance_covered = 100.0
        self.use_generalized_eigenvectors = False
        self.auto_commit = False

        self.loadSettings()

        self.data = None
        self.changed_flag = False

        #####
        # GUI
        #####
        grid = QGridLayout()
        box = OWGUI.widgetBox(self.controlArea,
                              "Components Selection",
                              orientation=grid)

        label1 = QLabel("Max components", box)
        grid.addWidget(label1, 1, 0)

        sb1 = OWGUI.spin(box,
                         self,
                         "max_components",
                         0,
                         1000,
                         tooltip="Maximum number of components",
                         callback=self.on_update,
                         addToLayout=False,
                         keyboardTracking=False)
        self.max_components_spin = sb1.control
        self.max_components_spin.setSpecialValueText("All")
        grid.addWidget(sb1.control, 1, 1)

        label2 = QLabel("Variance covered", box)
        grid.addWidget(label2, 2, 0)

        sb2 = OWGUI.doubleSpin(box,
                               self,
                               "variance_covered",
                               1.0,
                               100.0,
                               1.0,
                               tooltip="Percent of variance covered.",
                               callback=self.on_update,
                               decimals=1,
                               addToLayout=False,
                               keyboardTracking=False)
        sb2.control.setSuffix("%")
        grid.addWidget(sb2.control, 2, 1)

        OWGUI.rubber(self.controlArea)

        box = OWGUI.widgetBox(self.controlArea, "Commit")
        cb = OWGUI.checkBox(box, self, "auto_commit", "Commit on any change")
        b = OWGUI.button(box, self, "Commit", callback=self.update_components)
        OWGUI.setStopper(self, b, cb, "changed_flag", self.update_components)

        self.scree_plot = ScreePlot(self)
        #        self.scree_plot.set_main_title("Scree Plot")
        #        self.scree_plot.set_show_main_title(True)
        self.scree_plot.set_axis_title(owaxis.xBottom, "Principal Components")
        self.scree_plot.set_show_axis_title(owaxis.xBottom, 1)
        self.scree_plot.set_axis_title(owaxis.yLeft, "Proportion of Variance")
        self.scree_plot.set_show_axis_title(owaxis.yLeft, 1)

        self.variance_curve = self.scree_plot.add_curve(
            "Variance",
            Qt.red,
            Qt.red,
            2,
            xData=[],
            yData=[],
            style=OWCurve.Lines,
            enableLegend=True,
            lineWidth=2,
            autoScale=1,
            x_axis_key=owaxis.xBottom,
            y_axis_key=owaxis.yLeft,
        )

        self.cumulative_variance_curve = self.scree_plot.add_curve(
            "Cumulative Variance",
            Qt.darkYellow,
            Qt.darkYellow,
            2,
            xData=[],
            yData=[],
            style=OWCurve.Lines,
            enableLegend=True,
            lineWidth=2,
            autoScale=1,
            x_axis_key=owaxis.xBottom,
            y_axis_key=owaxis.yLeft,
        )

        self.mainArea.layout().addWidget(self.scree_plot)
        self.connect(self.scree_plot, SIGNAL("cutoff_moved(double)"),
                     self.on_cutoff_moved)

        self.connect(self.graphButton, SIGNAL("clicked()"),
                     self.scree_plot.save_to_file)

        self.components = None
        self.variances = None
        self.variances_sum = None
        self.projector_full = None
        self.currently_selected = 0

        self.resize(800, 400)
Ejemplo n.º 18
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, "CN2", wantMainArea=False, resizingEnabled=False)

        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 = []

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

        form = QFormLayout(
            labelAlignment=Qt.AlignLeft, formAlignment=Qt.AlignLeft, fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow
        )

        self.ruleValidationGroup.layout().addLayout(form)

        alpha_spin = OWGUI.doubleSpin(
            self.ruleValidationGroup,
            self,
            "Alpha",
            0,
            1,
            0.001,
            tooltip="Required significance of the difference between the "
            + "class distribution on all examples and covered examples",
        )

        step_alpha_spin = OWGUI.doubleSpin(
            self.ruleValidationGroup,
            self,
            "stepAlpha",
            0,
            1,
            0.001,
            tooltip="Required significance of each specialization of a rule.",
        )

        min_coverage_spin = OWGUI.spin(
            self.ruleValidationGroup,
            self,
            "MinCoverage",
            0,
            100,
            tooltip="Minimum number of examples a rule must cover " + "(use 0 for not setting the limit)",
        )

        min_coverage_spin.setSpecialValueText("Unlimited")

        # Check box needs to be in alayout for the form layout to center it
        # in the vertical direction.
        max_rule_box = OWGUI.widgetBox(self.ruleValidationGroup, "")
        max_rule_cb = OWGUI.checkBox(max_rule_box, self, "useMaxRuleLength", "Maximal rule length")

        max_rule_spin = OWGUI.spin(
            self.ruleValidationGroup,
            self,
            "MaxRuleLength",
            1,
            100,
            tooltip="Maximal number of conditions in the left " + "part of the rule",
        )
        max_rule_cb.disables += [max_rule_spin]
        max_rule_cb.makeConsistent()

        form.addRow("Alpha (vs. default rule)", alpha_spin)
        form.addRow("Stopping Alpha (vs. parent rule)", step_alpha_spin)
        form.addRow("Minimum coverage", min_coverage_spin)
        form.addRow(max_rule_box, max_rule_spin)

        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, name='kNN'):
        OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0, resizingEnabled = 0)

        self.callbackDeposit = []

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

        self.boostType = [("Discrete Boosting","DISCRETE"),
                       ("Real Boosting","REAL"),
                       ("Logit Boosting","LOGIT"),
                       ("Gentle Boosting","GENTLE")
                            ]
        self.splitCrit = [("Default","DEFAULT"),
                       ("Gini","GINI"),
                       ("MissClass","MISCLASS"),
                       ("Squared Error","SQERR")
                            ]

        self.currentSplitCrits = []
        # Settings
        self.name = 'CvBoost'
        self.classifier = None
        self.learner = None
        self.modelFile = os.path.join(os.getcwd(),"Boost.model")
        #CVBOOSTTYPE = { "DISCRETE":0, "REAL":1, "LOGIT":2, "GENTLE":3 }
        #CVBOOSTSPLITCRIT{ "DEFAULT":0, "GINI":1, "MISCLASS":3, "SQERR":4 }
        #CVBOOSTDEFAULTDICT = {"boost_type":"DISCRETE","weak_count":100,"split_criteria":"DEFAULT","weight_trim_rate":0.95, "max_depth":1, "use_surrogates":True, "priors":None}
        for par in ("boost_type","weak_count","split_criteria","weight_trim_rate", "max_depth", "use_surrogates","priors"):
            setattr(self, par, AZOC.CVBOOSTDEFAULTDICT[par])

        self.data = None                    # input data set
        OWGUI.lineEdit(self.controlArea, self, 'name', box='Learner/Classifier Name', \
                 tooltip='Name to be used by other widgets to identify the learner/classifier.')

        OWGUI.separator(self.controlArea)

        pars = OWGUI.widgetBox(self.controlArea, "Parameters")
        self.bType = [x[1] for x in self.boostType].index(self.boost_type)
        self.splitC = 0
        OWGUI.comboBox(pars, self, "bType", items = [x[0] for x in self.boostType], label = "Boost Type", orientation="horizontal", valueType = str,callback= self.updateSplitCritCombo)
        self.splitCombo = OWGUI.comboBox(pars, self, "splitC", items = [x[0] for x in self.splitCrit], label = "Split Criteria", orientation="horizontal", valueType = str, tooltip = "Node splitting criteria.")
        self.updateSplitCritCombo()
        if self.split_criteria not in [x[1] for x in self.currentSplitCrits]:
            print "ERROR: Invalid CvBoost default parameters in the AZOrangeConfig.py file"
        self.splitC = [x[1] for x in self.currentSplitCrits].index(self.split_criteria)

        OWGUI.spin(pars, self, "weak_count", 0, 1000, 1, None,     "Weak Count         ", orientation="horizontal", tooltip = "The number of trees used.")
        wtrBox = OWGUI.doubleSpin(pars, self, "weight_trim_rate", 0.0, 1.0, 0.01, label="Weight Trim Rate",  orientation="horizontal", tooltip = "Removal of well classified examples. Used only for computational efficiency. The greater the number, the fewer the number of examples removed.")
        wtrBox.control.setDecimals(2)
        OWGUI.spin(pars, self, "max_depth", 1, 1000, 1, None,      "Max Depth          ", orientation="horizontal", tooltip = "Maximal branching depth")
        OWGUI.checkBox(pars, self, "use_surrogates", "Use Surrogates", tooltip = "Use surrogate nodes for missing values")
        

        OWGUI.separator(self.controlArea)

        self.setLearner()
        OWGUI.button(self.controlArea, self, "&Apply", callback = self.setLearner, disabled=0)
        
        # Get desired location of model file
        boxFile = OWGUI.widgetBox(self.controlArea, "Path for saving Model", addSpace = True, orientation=0)
        L1 = OWGUI.lineEdit(boxFile, self, "modelFile", labelWidth=80,  orientation = "horizontal", \
        tooltip = "Once a model is created (connect this widget with a data widget), \nit can be saved by giving a \
file name here and clicking the save button.\nPlease observe that model names should not contain an extention.")
        L1.setMinimumWidth(200)
        button = OWGUI.button(boxFile, self, '...', callback = self.browseFile, disabled=0,tooltip = "Choose the dir where to save. After chosen, add a name for the model file!")
        button.setMaximumWidth(25)

        # Save the model
        OWGUI.button(self.controlArea, self,"&Save model to file", callback=self.saveModel)


        self.adjustSize()
Ejemplo n.º 20
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)]
        self.outputs = [("Learner", orange.Learner),
                        ("Classifier", orange.Classifier)]

        self.boostType = [("Discrete Boosting", "DISCRETE"),
                          ("Real Boosting", "REAL"),
                          ("Logit Boosting", "LOGIT"),
                          ("Gentle Boosting", "GENTLE")]
        self.splitCrit = [("Default", "DEFAULT"), ("Gini", "GINI"),
                          ("MissClass", "MISCLASS"),
                          ("Squared Error", "SQERR")]

        self.currentSplitCrits = []
        # Settings
        self.name = 'CvBoost'
        self.classifier = None
        self.learner = None
        self.modelFile = os.path.join(os.getcwd(), "Boost.model")
        #CVBOOSTTYPE = { "DISCRETE":0, "REAL":1, "LOGIT":2, "GENTLE":3 }
        #CVBOOSTSPLITCRIT{ "DEFAULT":0, "GINI":1, "MISCLASS":3, "SQERR":4 }
        #CVBOOSTDEFAULTDICT = {"boost_type":"DISCRETE","weak_count":100,"split_criteria":"DEFAULT","weight_trim_rate":0.95, "max_depth":1, "use_surrogates":True, "priors":None}
        for par in ("boost_type", "weak_count", "split_criteria",
                    "weight_trim_rate", "max_depth", "use_surrogates",
                    "priors"):
            setattr(self, par, AZOC.CVBOOSTDEFAULTDICT[par])

        self.data = None  # input data set
        OWGUI.lineEdit(self.controlArea, self, 'name', box='Learner/Classifier Name', \
                 tooltip='Name to be used by other widgets to identify the learner/classifier.')

        OWGUI.separator(self.controlArea)

        pars = OWGUI.widgetBox(self.controlArea, "Parameters")
        self.bType = [x[1] for x in self.boostType].index(self.boost_type)
        self.splitC = 0
        OWGUI.comboBox(pars,
                       self,
                       "bType",
                       items=[x[0] for x in self.boostType],
                       label="Boost Type",
                       orientation="horizontal",
                       valueType=str,
                       callback=self.updateSplitCritCombo)
        self.splitCombo = OWGUI.comboBox(pars,
                                         self,
                                         "splitC",
                                         items=[x[0] for x in self.splitCrit],
                                         label="Split Criteria",
                                         orientation="horizontal",
                                         valueType=str,
                                         tooltip="Node splitting criteria.")
        self.updateSplitCritCombo()
        if self.split_criteria not in [x[1] for x in self.currentSplitCrits]:
            print "ERROR: Invalid CvBoost default parameters in the AZOrangeConfig.py file"
        self.splitC = [x[1] for x in self.currentSplitCrits
                       ].index(self.split_criteria)

        OWGUI.spin(pars,
                   self,
                   "weak_count",
                   0,
                   1000,
                   1,
                   None,
                   "Weak Count         ",
                   orientation="horizontal",
                   tooltip="The number of trees used.")
        wtrBox = OWGUI.doubleSpin(
            pars,
            self,
            "weight_trim_rate",
            0.0,
            1.0,
            0.01,
            label="Weight Trim Rate",
            orientation="horizontal",
            tooltip=
            "Removal of well classified examples. Used only for computational efficiency. The greater the number, the fewer the number of examples removed."
        )
        wtrBox.control.setDecimals(2)
        OWGUI.spin(pars,
                   self,
                   "max_depth",
                   1,
                   1000,
                   1,
                   None,
                   "Max Depth          ",
                   orientation="horizontal",
                   tooltip="Maximal branching depth")
        OWGUI.checkBox(pars,
                       self,
                       "use_surrogates",
                       "Use Surrogates",
                       tooltip="Use surrogate nodes for missing values")

        OWGUI.separator(self.controlArea)

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

        # Get desired location of model file
        boxFile = OWGUI.widgetBox(self.controlArea,
                                  "Path for saving Model",
                                  addSpace=True,
                                  orientation=0)
        L1 = OWGUI.lineEdit(boxFile, self, "modelFile", labelWidth=80,  orientation = "horizontal", \
        tooltip = "Once a model is created (connect this widget with a data widget), \nit can be saved by giving a \
file name here and clicking the save button.\nPlease observe that model names should not contain an extention."                                                                                                               )
        L1.setMinimumWidth(200)
        button = OWGUI.button(
            boxFile,
            self,
            '...',
            callback=self.browseFile,
            disabled=0,
            tooltip=
            "Choose the dir where to save. After chosen, add a name for the model file!"
        )
        button.setMaximumWidth(25)

        # Save the model
        OWGUI.button(self.controlArea,
                     self,
                     "&Save model to file",
                     callback=self.saveModel)

        self.adjustSize()
Ejemplo n.º 21
0
    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),
                        ("Predictor", earth.EarthClassifier)]

        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.º 22
0
    def __init__(self, parent=None, signalManager=None, title="PCA"):
        OWWidget.__init__(self, parent, signalManager, title, wantGraph=True)

        self.inputs = [("Input Data", Orange.data.Table, self.set_data)]
        self.outputs = [("Transformed Data", Orange.data.Table, Default),
                        ("Eigen Vectors", Orange.data.Table)]

        self.standardize = True
        self.max_components = 0
        self.variance_covered = 100.0
        self.use_generalized_eigenvectors = False
        self.auto_commit = False

        self.loadSettings()

        self.data = None
        self.changed_flag = False

        #####
        # GUI
        #####
        grid = QGridLayout()
        box = OWGUI.widgetBox(self.controlArea, "Components Selection",
                              orientation=grid)

        label1 = QLabel("Max components", box)
        grid.addWidget(label1, 1, 0)

        sb1 = OWGUI.spin(box, self, "max_components", 0, 1000,
                         tooltip="Maximum number of components",
                         callback=self.on_update,
                         addToLayout=False,
                         keyboardTracking=False
                         )
        self.max_components_spin = sb1.control
        self.max_components_spin.setSpecialValueText("All")
        grid.addWidget(sb1.control, 1, 1)

        label2 = QLabel("Variance covered", box)
        grid.addWidget(label2, 2, 0)

        sb2 = OWGUI.doubleSpin(box, self, "variance_covered", 1.0, 100.0, 1.0,
                               tooltip="Percent of variance covered.",
                               callback=self.on_update,
                               decimals=1,
                               addToLayout=False,
                               keyboardTracking=False
                               )
        sb2.control.setSuffix("%")
        grid.addWidget(sb2.control, 2, 1)

        OWGUI.rubber(self.controlArea)

        box = OWGUI.widgetBox(self.controlArea, "Commit")
        cb = OWGUI.checkBox(box, self, "auto_commit", "Commit on any change")
        b = OWGUI.button(box, self, "Commit",
                         callback=self.update_components)
        OWGUI.setStopper(self, b, cb, "changed_flag", self.update_components)

        self.plot = Graph()
        canvas = self.plot.canvas()
        canvas.setFrameStyle(QFrame.StyledPanel)
        self.mainArea.layout().addWidget(self.plot)
        self.plot.setAxisTitle(QwtPlot.yLeft, "Proportion of Variance")
        self.plot.setAxisTitle(QwtPlot.xBottom, "Principal Components")
        self.plot.setAxisScale(QwtPlot.yLeft, 0.0, 1.0)
        self.plot.enableGridXB(True)
        self.plot.enableGridYL(True)
        self.plot.setGridColor(Qt.lightGray)

        self.variance_curve = plot_curve(
            "Variance",
            pen=QPen(Qt.red, 2),
            symbol=QwtSymbol.NoSymbol,
            xaxis=QwtPlot.xBottom,
            yaxis=QwtPlot.yLeft
        )
        self.cumulative_variance_curve = plot_curve(
            "Cumulative Variance",
            pen=QPen(Qt.darkYellow, 2),
            symbol=QwtSymbol.NoSymbol,
            xaxis=QwtPlot.xBottom,
            yaxis=QwtPlot.yLeft
        )

        self.variance_curve.attach(self.plot)
        self.cumulative_variance_curve.attach(self.plot)

        self.selection_tool = CutoffControler(parent=self.plot.canvas())
        self.selection_tool.cutoffMoved.connect(self.on_cutoff_moved)

        self.graphButton.clicked.connect(self.saveToFile)
        self.components = None
        self.variances = None
        self.variances_sum = None
        self.projector_full = None
        self.currently_selected = 0

        self.resize(800, 400)
Ejemplo n.º 23
0
    def __init__(self, parent=None, signalManager=None, title="Neural Network"):
        OWWidget.__init__(self, parent, signalManager, title, wantMainArea=False, resizingEnabled=False)

        self.inputs = [
            ("Data", Orange.data.Table, self.set_data),
            ("Preprocess", PreprocessedLearner, self.set_preprocessor),
        ]
        self.outputs = [("Learner", Orange.classification.Learner), ("Classifier", Orange.classification.Classifier)]

        self.name = "Neural Network"
        self.n_mid = 20
        self.reg_fact = 1
        self.max_iter = 300
        self.normalize = True

        self.loadSettings()

        box = OWGUI.widgetBox(self.controlArea, "Name", addSpace=True)
        OWGUI.lineEdit(box, self, "name")

        box = OWGUI.widgetBox(self.controlArea, "Settings", addSpace=True)

        form = QFormLayout(
            spacing=8,
            formAlignment=Qt.AlignLeft,
            labelAlignment=Qt.AlignLeft,
            fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow,
        )
        box.layout().addLayout(form)

        form.addRow(
            "Hidden layer neurons",
            OWGUI.spin(
                box, self, "n_mid", 2, 10000, 1, tooltip="Number of neurons in the hidden layer.", addToLayout=False
            ),
        )

        form.addRow("Regularization factor", OWGUI.doubleSpin(box, self, "reg_fact", 0.1, 10.0, 0.1, addToLayout=False))

        form.addRow(
            "Max iterations",
            OWGUI.spin(
                box,
                self,
                "max_iter",
                100,
                10000,
                1,
                tooltip="Maximal number of optimization iterations.",
                addToLayout=False,
            ),
        )

        OWGUI.checkBox(box, self, "normalize", "Normalize the data")

        OWGUI.button(
            self.controlArea,
            self,
            "&Apply",
            callback=self.apply,
            tooltip="Create the learner and apply it on input data.",
            autoDefault=True,
        )

        self.data = None
        self.preprocessor = None
        self.apply()
Ejemplo n.º 24
0
    def __init__(self, parent=None, signalManager=None, title="PCA"):
        OWWidget.__init__(self, parent, signalManager, title, wantGraph=True)

        self.inputs = [("Input Data", Orange.data.Table, self.set_data)]
        self.outputs = [("Transformed Data", Orange.data.Table, Default),
                        ("Eigen Vectors", Orange.data.Table)]

        self.standardize = True
        self.max_components = 0
        self.variance_covered = 100.0
        self.use_generalized_eigenvectors = False
        self.auto_commit = False

        self.loadSettings()

        self.data = None
        self.changed_flag = False

        #####
        # GUI
        #####
        grid = QGridLayout()
        box = OWGUI.widgetBox(self.controlArea, "Components Selection",
                              orientation=grid)

        label1 = QLabel("Max components", box)
        grid.addWidget(label1, 1, 0)

        sb1 = OWGUI.spin(box, self, "max_components", 0, 1000,
                         tooltip="Maximum number of components",
                         callback=self.on_update,
                         addToLayout=False,
                         keyboardTracking=False
                         )
        self.max_components_spin = sb1.control
        self.max_components_spin.setSpecialValueText("All")
        grid.addWidget(sb1.control, 1, 1)

        label2 = QLabel("Variance covered", box)
        grid.addWidget(label2, 2, 0)

        sb2 = OWGUI.doubleSpin(box, self, "variance_covered", 1.0, 100.0, 1.0,
                               tooltip="Percent of variance covered.",
                               callback=self.on_update,
                               decimals=1,
                               addToLayout=False,
                               keyboardTracking=False
                               )
        sb2.control.setSuffix("%")
        grid.addWidget(sb2.control, 2, 1)

        OWGUI.rubber(self.controlArea)

        box = OWGUI.widgetBox(self.controlArea, "Commit")
        cb = OWGUI.checkBox(box, self, "auto_commit", "Commit on any change")
        b = OWGUI.button(box, self, "Commit",
                         callback=self.update_components)
        OWGUI.setStopper(self, b, cb, "changed_flag", self.update_components)

        self.scree_plot = ScreePlot(self)
#        self.scree_plot.set_main_title("Scree Plot")
#        self.scree_plot.set_show_main_title(True)
        self.scree_plot.set_axis_title(owaxis.xBottom, "Principal Components")
        self.scree_plot.set_show_axis_title(owaxis.xBottom, 1)
        self.scree_plot.set_axis_title(owaxis.yLeft, "Proportion of Variance")
        self.scree_plot.set_show_axis_title(owaxis.yLeft, 1)

        self.variance_curve = self.scree_plot.add_curve(
                        "Variance",
                        Qt.red, Qt.red, 2,
                        xData=[],
                        yData=[],
                        style=OWCurve.Lines,
                        enableLegend=True,
                        lineWidth=2,
                        autoScale=1,
                        x_axis_key=owaxis.xBottom,
                        y_axis_key=owaxis.yLeft,
                        )

        self.cumulative_variance_curve = self.scree_plot.add_curve(
                        "Cumulative Variance",
                        Qt.darkYellow, Qt.darkYellow, 2,
                        xData=[],
                        yData=[],
                        style=OWCurve.Lines,
                        enableLegend=True,
                        lineWidth=2,
                        autoScale=1,
                        x_axis_key=owaxis.xBottom,
                        y_axis_key=owaxis.yLeft,
                        )

        self.mainArea.layout().addWidget(self.scree_plot)
        self.connect(self.scree_plot,
                     SIGNAL("cutoff_moved(double)"),
                     self.on_cutoff_moved
                     )

        self.connect(self.graphButton,
                     SIGNAL("clicked()"),
                     self.scree_plot.save_to_file)

        self.components = None
        self.variances = None
        self.variances_sum = None
        self.projector_full = None
        self.currently_selected = 0

        self.resize(800, 400)
Ejemplo n.º 25
0
    def __init__(self, parent=None, signalManager=None, name="SVM"):
        OWWidget.__init__(self, parent, signalManager, name, wantMainArea = 0, resizingEnabled = 0)
        
        self.inputs = [("Data", ExampleTable, self.setData),
                       ("Preprocess", PreprocessedLearner, self.setPreprocessor)]
        self.outputs = [("Learner", orange.Learner, Default),
                        ("Classifier", orange.Classifier, Default),
                        ("Support Vectors", ExampleTable)]

        self.kernel_type = 2
        self.gamma = 0.0
        self.coef0 = 0.0
        self.degree = 3
        self.C = 1.0
        self.p = 0.1
        self.eps = 1e-3
        self.nu = 0.5
        self.shrinking = 1
        self.probability=1
        self.useNu=0
        self.nomogram=0
        self.normalization=1
        self.data = None
        self.selFlag=False
        self.preprocessor = None
        self.name="SVM"

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

        b = OWGUI.radioButtonsInBox(self.controlArea, self, "useNu", [], 
                                    box="SVM Type", 
                                    orientation = QGridLayout(), 
                                    addSpace=True)
        
        b.layout().addWidget(OWGUI.appendRadioButton(b, self, "useNu", "C-SVM",
                                                     addToLayout=False),
                             0, 0, Qt.AlignLeft)
        
        b.layout().addWidget(QLabel("Cost (C)", b), 0, 1, Qt.AlignRight)
        b.layout().addWidget(OWGUI.doubleSpin(b, self, "C", 0.1, 512.0, 0.1,
                                decimals=2,
                                addToLayout=False,
                                callback=lambda *x: self.setType(0),
                                alignment=Qt.AlignRight,
                                tooltip= "Cost for a mis-classified training instance."),
                             0, 2)
        
        b.layout().addWidget(OWGUI.appendRadioButton(b, self, "useNu", u"ν-SVM",
                                                     addToLayout=False),
                             1, 0, Qt.AlignLeft)

        b.layout().addWidget(QLabel(u"Complexity bound (\u03bd)", b), 1, 1, Qt.AlignRight)
        b.layout().addWidget(OWGUI.doubleSpin(b, self, "nu", 0.05, 1.0, 0.05,
                                tooltip="Lower bound on the ratio of support vectors",
                                addToLayout=False,
                                callback=lambda *x: self.setType(1),
                                alignment=Qt.AlignRight),
                             1, 2)
        
        self.kernelBox=b = OWGUI.widgetBox(self.controlArea, "Kernel")
        self.kernelradio = OWGUI.radioButtonsInBox(b, self, "kernel_type",
                                        btnLabels=[u"Linear,   x∙y",
                                                   u"Polynomial,   (g x∙y + c)^d",
                                                   u"RBF,   exp(-g|x-y|²)",
                                                   u"Sigmoid,   tanh(g x∙y + c)"],
                                        callback=self.changeKernel)

        OWGUI.separator(b)
        self.gcd = OWGUI.widgetBox(b, orientation="horizontal")
        self.leg = OWGUI.doubleSpin(self.gcd, self, "gamma",0.0,10.0,0.0001,
                                decimals=5,
                                label="  g: ",
                                orientation="horizontal",
                                callback=self.changeKernel,
                                alignment=Qt.AlignRight)
        
        self.led = OWGUI.doubleSpin(self.gcd, self, "coef0", 0.0,10.0,0.0001,
                                label="  c: ",
                                orientation="horizontal",
                                callback=self.changeKernel,
                                alignment=Qt.AlignRight)
        
        self.lec = OWGUI.doubleSpin(self.gcd, self, "degree", 0.0,10.0,0.5,
                                label="  d: ",
                                orientation="horizontal",
                                callback=self.changeKernel,
                                alignment=Qt.AlignRight)

        OWGUI.separator(self.controlArea)
        
        self.optionsBox=b=OWGUI.widgetBox(self.controlArea, "Options",
                                          addSpace=True)
        
        OWGUI.doubleSpin(b,self, "eps", 0.0005, 1.0, 0.0005,
                         label=u"Numerical tolerance",
                         labelWidth = 180,
                         orientation="horizontal",
                         tooltip="Numerical tolerance of termination criterion.",
                         alignment=Qt.AlignRight)

        self.probBox = OWGUI.checkBox(b,self, "probability",
                                      label="Estimate class probabilities",
                                      tooltip="Create classifiers that support class probability estimation."
                                      )
        
        OWGUI.checkBox(b, self, "normalization",
                       label="Normalize data", 
                       tooltip="Use data normalization")

        self.paramButton=OWGUI.button(self.controlArea, self, "Automatic parameter search",
                                      callback=self.parameterSearch,
                                      tooltip="Automatically searches for parameters that optimize classifier accuracy", 
                                      debuggingEnabled=0)
        
        self.paramButton.setDisabled(True)

        OWGUI.button(self.controlArea, self,"&Apply", 
                     callback=self.applySettings, 
                     default=True)
        
        OWGUI.rubber(self.controlArea)
        
        self.loadSettings()
        self.changeKernel()
        self.searching=False
        self.applySettings()
Ejemplo n.º 26
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self,
                          parent,
                          signalManager,
                          "CN2",
                          wantMainArea=False,
                          resizingEnabled=False)

        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 = []

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

        form = QFormLayout(labelAlignment=Qt.AlignLeft,
                           formAlignment=Qt.AlignLeft,
                           fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow)

        self.ruleValidationGroup.layout().addLayout(form)

        alpha_spin = OWGUI.doubleSpin(
            self.ruleValidationGroup,
            self,
            "Alpha",
            0,
            1,
            0.001,
            tooltip="Required significance of the difference between the " +
            "class distribution on all examples and covered examples")

        step_alpha_spin = OWGUI.doubleSpin(
            self.ruleValidationGroup,
            self,
            "stepAlpha",
            0,
            1,
            0.001,
            tooltip="Required significance of each specialization of a rule.")

        min_coverage_spin = OWGUI.spin(
            self.ruleValidationGroup,
            self,
            "MinCoverage",
            0,
            100,
            tooltip="Minimum number of examples a rule must cover " +
            "(use 0 for not setting the limit)")

        min_coverage_spin.setSpecialValueText("Unlimited")

        # Check box needs to be in alayout for the form layout to center it
        # in the vertical direction.
        max_rule_box = OWGUI.widgetBox(self.ruleValidationGroup, "")
        max_rule_cb = OWGUI.checkBox(max_rule_box, self, "useMaxRuleLength",
                                     "Maximal rule length")

        max_rule_spin = OWGUI.spin(
            self.ruleValidationGroup,
            self,
            "MaxRuleLength",
            1,
            100,
            tooltip="Maximal number of conditions in the left " +
            "part of the rule")
        max_rule_cb.disables += [max_rule_spin]
        max_rule_cb.makeConsistent()

        form.addRow("Alpha (vs. default rule)", alpha_spin)
        form.addRow("Stopping Alpha (vs. parent rule)", step_alpha_spin)
        form.addRow("Minimum coverage", min_coverage_spin)
        form.addRow(max_rule_box, max_rule_spin)

        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()
Ejemplo n.º 27
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()
Ejemplo n.º 28
0
    def __init__(self, parent=None, signalManager=None, name="SVM"):
        OWWidget.__init__(self, parent, signalManager, name)
        self.inputs=[("Example Table", ExampleTable, self.setData)]
        self.outputs=[("Learner", orange.Learner),("Classifier", orange.Classifier)]   #  ,("Support Vectors", ExampleTable)]

        self.data = None
        self.name="Support Vector Machine"
        self.nMin = -1
        self.nMax = 1
        self.nClassMin = -1
        self.nClassMax = 1
        self.svm_typeGUI = None
        self.stopCritGUI = None
        self.priorsGUI = ""
        #Read default parameters from AZOrangeConfig.py file
        for par in ("kernel_type", "svm_type","gamma","C","p","epsC","epsR","stopCrit",\
                        "maxIter","nu","scaleData","scaleClass","priors","coef0","degree"):
            setattr(self, par, AZOC.CVSVMDEFAULTDICT[par])
        if self.svm_type in (103,104):
            self.eps = self.epsR
        else:
            self.eps = self.epsC
        self.setSVMTypeGUI(self.svm_type)
        self.setStopCritGUI(self.stopCrit)
        self.setPriorsGUI()#self.priors)

##scJS Added parameter needed for saving an SVM model
        self.modelFile = os.path.join(os.getcwd(),"SVM.model")
##ecJS
        OWGUI.lineEdit(self.controlArea, self, 'name', box='Learner/Classifier Name', \
                       tooltip='Name to be used by other widgets to identify your learner/classifier.<br>This should be a unique name!')
        ## scLC
        # Do not use the one class svm (type 2).
        self.svmTypeBox=b=OWGUI.widgetBox(self.controlArea,"SVM Type")
        self.svmTyperadio = OWGUI.radioButtonsInBox(b, self, "svm_typeGUI", btnLabels=["C-SVC", "nu-SVC","epsilon-SVR", "nu-SVR"], callback=self.setSVMTypeLearner)
        ## ecLC

        self.kernelBox=b=OWGUI.widgetBox(self.controlArea, "Kernel")
        self.kernelradio = OWGUI.radioButtonsInBox(b, self, "kernel_type", btnLabels=["Linear,   x.y", "Polynomial,   (g*x.y+c)^d",
                    "RBF,   exp(-g*(x-y).(x-y))", "Sigmoid,   tanh(g*x.y+c)"], callback=self.changeKernel)

        self.gcd = OWGUI.widgetBox(b, orientation="horizontal")
        self.leg = OWGUI.doubleSpin(self.gcd, self, "gamma",0.0,10.0,0.0001, label="gamma: ", orientation="horizontal", callback=self.changeKernel)
        self.led = OWGUI.doubleSpin(self.gcd, self, "coef0", 0.0,10.0,0.0001, label="  coef0: ", orientation="horizontal", callback=self.changeKernel)
        self.lec = OWGUI.doubleSpin(self.gcd, self, "degree", 0.0,10.0,0.5, label="  degree: ", orientation="horizontal", callback=self.changeKernel)

        OWGUI.separator(self.controlArea)


        #self.layout=QVBoxLayout(self.mainArea)
        self.optionsBox=b=OWGUI.widgetBox(self.mainArea, "Options", addSpace = True)
        self.cBox = OWGUI.doubleSpin(b,self, "C", 0.0, 512.0, 0.5, label="Model complexity (C)",  orientation="horizontal", tooltip="Penalty cost")
        self.cBox.control.setDecimals(3)
        self.pBox = OWGUI.doubleSpin(b,self, "p", 0.0, 10.0, 0.1, label="Tolerance (p)",  orientation="horizontal", tooltip="zero-loss width zone")
        self.pBox.control.setDecimals(3)
        self.nuBox = OWGUI.doubleSpin(b, self, "nu", 0.0,1.0,0.1, label="Complexity bound (nu)",  orientation="horizontal", tooltip="Upper bound on the ratio of support vectors")
        self.nuBox.control.setDecimals(3)        

        self.priorBox = OWGUI.lineEdit(b, self, 'priorsGUI', box='Class weights', \
                       tooltip='Ex: POS:2 , NEG:1')

        self.stopCritBox=OWGUI.widgetBox(self.optionsBox,"Stop Criteria")
        self.stopCritradio = OWGUI.radioButtonsInBox(self.stopCritBox, self, "stopCritGUI", btnLabels=["Maximum number of iterations (maxIter)", "Numeric precision (eps)"], callback=self.setStopCritLearner)
        OWGUI.doubleSpin(self.stopCritBox,self, "eps", 0.0, 0.5, 0.001, label="Numeric precision (eps)",  orientation="horizontal")
        OWGUI.doubleSpin(self.stopCritBox,self, "maxIter", 0, 100000, 1, label="Maximum number of iterations (maxIter)",  orientation="horizontal")


        self.scaleDataBox=OWGUI.checkBox(b, self, "scaleData", "Scale Data", tooltip="Scales the training data, and the input examples",callback = self.changeScaling)
        self.scaleClassBox=OWGUI.checkBox(OWGUI.indentedBox(b), self, "scaleClass", "Scale Class variable", tooltip="Scales the class variable of training data, and the output predictions",callback = self.changeScaling)
        #self.scalenMin = OWGUI.lineEdit(OWGUI.indentedBox(b), self, 'nMin', 'Var min:', orientation="horizontal", tooltip='Variables scaling minimum')
        #self.scalenMax = OWGUI.lineEdit(OWGUI.indentedBox(b), self, 'nMax', 'Var max:', orientation="horizontal", tooltip='Variables scaling maximum')
        #OWGUI.separator(OWGUI.indentedBox(b))
        self.scalenClassMin = OWGUI.lineEdit(OWGUI.indentedBox(b), self, 'nClassMin', 'Class min:', orientation="horizontal", tooltip='Class scaling minimum')
        self.scalenClassMax = OWGUI.lineEdit(OWGUI.indentedBox(b), self, 'nClassMax', 'Class max:', orientation="horizontal", tooltip='Class scaling maximum')
        OWGUI.separator(self.controlArea)

        #self.paramButton=OWGUI.button(self.controlArea, self, "Automatic parameter search", callback=self.parameterSearch,
        #                             tooltip="Automaticaly searches for parameters that optimize classifier acuracy")
        self.optionsBox.adjustSize()
        #self.layout.add(self.optionsBox)

        #OWGUI.separator(self.controlArea)

        OWGUI.button(self.controlArea, self,"&Apply", callback=self.applySettings)
##scJS Adding saving of svm models 

        # Get desired location of model file
        boxFile = OWGUI.widgetBox(self.controlArea, "Path for saving Model", addSpace = True, orientation=0)
        L1 = OWGUI.lineEdit(boxFile, self, "modelFile", labelWidth=80,  orientation = "horizontal", \
        tooltip = "Once a model is created (connect this widget with a data widget), \nit can be saved by giving a \
file name here and clicking the save button.")
        #L1.setMinimumWidth(200)
        button = OWGUI.button(boxFile, self, '...', callback = self.browseFile, disabled=0,tooltip = "Choose the dir where to save. After chosen, add a name for the model file!")
        #button.setMaximumWidth(25)

        # Save model
        OWGUI.button(self.controlArea, self,"&Save SVM model", callback=self.saveModel)

        #self.adjustSize()
        #self.loadSettings()
        self.setStopCritLearner()
        self.setSVMTypeLearner()
        self.changeKernel() 
        self.applySettings()
        self.resize(500,400)