Changeset 3485:77ca60fe9a4b in orange


Ignore:
Timestamp:
04/04/07 13:29:56 (7 years ago)
Author:
Gregor <Gregor@…>
Branch:
default
Convert:
301d113ee660a78e3aba5a56bd8671eacab3152c
Message:

* empty log message *

Location:
orange/OrangeWidgets
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/OWDlgs.py

    r3332 r3485  
    473473            self.__dict__[name+"passThroughBlack"] = chk 
    474474            self.__dict__[name+"passThroughBlackCheckbox"].setChecked(chk) 
    475             pallete = self.createPalette(self.rgbToQColor(l), self.rgbToQColor(r), chk) + 5*[Qt.white.rgb()] 
    476             self.__dict__[name+"View"].setPalette1(pallete) 
     475            palette = self.createPalette(self.rgbToQColor(l), self.rgbToQColor(r), chk) + 5*[Qt.white.rgb()] 
     476            self.__dict__[name+"View"].setPalette1(palette) 
    477477 
    478478        self.discreteColors = [self.rgbToQColor(col) for col in discPalette] 
  • orange/OrangeWidgets/OWFreeVizOptimization.py

    r3413 r3485  
    1717    forceRelValues = ["4 : 1", "3 : 1", "2 : 1", "3 : 2", "1 : 1", "2 : 3", "1 : 2", "1 : 3", "1 : 4"] 
    1818    attractRepelValues = [(4, 1), (3, 1), (2, 1), (3, 2), (1, 1), (2, 3), (1, 2), (1, 3), (1, 4)] 
    19      
     19 
    2020    def __init__(self, parentWidget = None, signalManager = None, graph = None, parentName = "Visualization widget"): 
    2121        OWBaseWidget.__init__(self, None, signalManager, "FreeViz Dialog") 
     
    3232        self.graph = graph 
    3333        self.rawdata = None 
    34          
     34 
    3535        if self.graph: 
    3636            self.graph.hideRadius = 0 
     
    3939        # differential evolution 
    4040        self.differentialEvolutionPopSize = 100 
    41         self.DERadvizSolver = None         
    42          
     41        self.DERadvizSolver = None 
     42 
    4343        self.loadSettings() 
    44          
     44 
    4545        self.tabs = QTabWidget(self, 'tabWidget') 
    4646        self.controlArea.addWidget(self.tabs) 
    47          
     47 
    4848        self.MainTab = QVGroupBox(self) 
    4949        self.S2NHeuristicTab = QVGroupBox(self) 
    50                  
     50 
    5151        self.tabs.insertTab(self.MainTab, "Main") 
    5252        self.tabs.insertTab(self.S2NHeuristicTab, "S2N Heuristic") 
     
    5555            self.LinearTransformationTab = QVGroupBox(self) 
    5656            self.tabs.insertTab(self.LinearTransformationTab, "Supervised PCA") 
    57          
     57 
    5858        # ########################### 
    5959        # MAIN TAB 
    6060        OWGUI.comboBox(self.MainTab, self, "implementation", box = "FreeViz Implementation", items = ["Fast (C) implementation", "Slow (Python) implementation", "LDA"]) 
    61          
     61 
    6262        box = OWGUI.widgetBox(self.MainTab, "Gradient Optimization") 
    63          
     63 
    6464        self.optimizeButton = OWGUI.button(box, self, "Optimize Separation", callback = self.optimizeSeparation) 
    6565        self.stopButton = OWGUI.button(box, self, "Stop optimization", callback = self.stopOptimization) 
     
    7070        self.attrKNeighboursCombo = OWGUI.comboBoxWithCaption(box, self, "stepsBeforeUpdate", "Number of steps before updating graph: ", tooltip = "Set the number of optimization steps that will be executed before the updated anchor positions will be visualized", items = [1, 3, 5, 10, 15, 20, 30, 50, 75, 100, 150, 200, 300], sendSelectedValue = 1, valueType = int) 
    7171        OWGUI.checkBox(box, self, "mirrorSymmetry", "Keep mirror symmetry", tooltip = "'Rotational' keeps the second anchor upside") 
    72          
     72 
    7373        vbox = OWGUI.widgetBox(self.MainTab, "Set Anchor Positions") 
    7474        hbox1 = OWGUI.widgetBox(vbox, orientation = "horizontal") 
     
    8484 
    8585        hbox2 = QHBox(box2); OWGUI.separator(hbox2, 20, 0); vbox2 = QVBox(hbox2) 
    86          
     86 
    8787        validSigma = QDoubleValidator(self); validSigma.setBottom(0.01) 
    8888        self.spinSigma = OWGUI.lineEdit(vbox2, self, "forceSigma", label = "Kernel width (sigma) ", labelWidth = 110, orientation = "horizontal", valueType = float) 
     
    110110##        self.createPopulationButton = OWGUI.button(box2, self, "Create population", callback = self.createPopulation) 
    111111##        self.evolvePopulationButton = OWGUI.button(box2, self, "Evolve population", callback = self.evolvePopulation) 
    112 ##     
     112## 
    113113        #box = OWGUI.widgetBox(self.MainTab, 1) 
    114114        #self.energyLabel = QLabel(box, "Energy: ") 
     
    123123        OWGUI.comboBoxWithCaption(box, self, "s2nPlaceAttributes", "Attributes to place: ", tooltip = "Set the number of top ranked attributes to place. You can select a higher value than the actual number of attributes", items = self.attrsNum, callback = self.s2nMixAnchors, sendSelectedValue = 1, valueType = int) 
    124124        OWGUI.checkBox(box, self, 'autoSetParameters', 'Automatically find optimal parameters') 
    125         self.s2nMixButton = OWGUI.button(box, self, "Place anchors", callback = self.s2nMixAnchorsAutoSet)         
     125        self.s2nMixButton = OWGUI.button(box, self, "Place anchors", callback = self.s2nMixAnchorsAutoSet) 
    126126 
    127127        # ########################## 
    128128        # SUPERVISED PCA TAB 
    129129        if parentName.lower() != "radviz": 
    130             OWGUI.button(self.LinearTransformationTab, self, "Find PCA projection", callback = self.findPCAProjection)         
    131             OWGUI.button(self.LinearTransformationTab, self, "Find supervised PCA projection", callback = self.findSPCAProjection)         
     130            OWGUI.button(self.LinearTransformationTab, self, "Find PCA projection", callback = self.findPCAProjection) 
     131            OWGUI.button(self.LinearTransformationTab, self, "Find supervised PCA projection", callback = self.findSPCAProjection) 
    132132            OWGUI.checkBox(self.LinearTransformationTab, self, "useGeneralizedEigenvectors", "Try to merge examples with same class value") 
    133              
     133 
    134134 
    135135        # ########################### 
     
    142142        self.tabs.setMinimumWidth(310) 
    143143 
    144         self.parentWidget.learnersArray[3] = S2NHeuristicLearner(self, self.parentWidget) 
     144##        self.parentWidget.learnersArray[3] = S2NHeuristicLearner(self, self.parentWidget) 
    145145        self.activateLoadedSettings() 
    146      
    147          
     146 
     147 
    148148    def activateLoadedSettings(self): 
    149149        self.forceLawChanged() 
     
    157157    def setManualPosition(self): 
    158158        self.parentWidget.graph.manualPositioning = self.manualPositioningButton.isOn() 
    159              
     159 
    160160    def setData(self, data): 
    161161        self.rawdata = data 
    162162        self.s2nMixData = None 
    163163        self.classPermutationList = None 
    164          
     164 
    165165    # save subsetdata. first example from this dataset can be used with argumentation - it can find arguments for classifying the example to the possible class values 
    166166    def setSubsetData(self, subsetdata): 
    167167        self.subsetdata = subsetdata 
    168                      
     168 
    169169    def destroy(self, dw = 1, dsw = 1): 
    170170        self.saveSettings() 
     
    183183            self.cbforcerel.setDisabled(False) 
    184184            self.cbforcebal.setDisabled(False) 
    185              
     185 
    186186        self.printEvent("Updated: %i, %i" % (self.attractG, self.repelG), eventVerbosity = 1) 
    187187 
     
    211211            self.disableRepulsive = 0 
    212212        self.updateForces() 
    213              
     213 
    214214    def setDisableRepulsive(self): 
    215215        if self.cbDisableRepulsive.isChecked(): 
     
    225225        self.graph.repaint() 
    226226        #self.recomputeEnergy() 
    227          
     227 
    228228    def radialAnchors(self): 
    229229        FreeViz.radialAnchors(self) 
     
    252252        self.graph.potentialsBmp = None 
    253253        self.graph.updateData() 
    254     
     254 
    255255    def optimizeSeparation(self, steps = 10, singleStep = False): 
    256256        self.optimizeButton.hide() 
     
    279279        Max = [1.0] * 2* l 
    280280        self.DERadvizSolver.Setup(Min, Max, 0, 0.95, 1) 
    281          
     281 
    282282    def evolvePopulation(self): 
    283283        if not self.DERadvizSolver: 
     
    306306            self.setStatusBarText("More attributes than examples. Singular matrix. Exiting...") 
    307307            return 
    308          
     308 
    309309        FreeViz.findSPCAProjection(self, attrIndices, setGraphAnchors = 1, SPCA = SPCA) 
    310          
     310 
    311311        self.graph.updateData() 
    312312        self.graph.repaint() 
     
    318318 
    319319# ############################################################### 
    320 # Optimize anchor position using differential evolution  
     320# Optimize anchor position using differential evolution 
    321321class RadvizSolver(DESolver.DESolver): 
    322322    def __init__(self, radvizWidget, dim, pop): 
     
    355355            self.optimizationDlg.optimize(nrOfFreeVizSteps) 
    356356 
    357     # for a given example run argumentation and find out to which class it most often fall         
     357    # for a given example run argumentation and find out to which class it most often fall 
    358358    def __call__(self, example, returnType): 
    359359        table = orange.ExampleTable(example.domain) 
    360360        table.append(example) 
    361361        self.radvizWidget.setSubsetData(table)       # show the example is we use the widget 
    362              
     362        self.radvizWidget.handleNewSignals() 
     363 
    363364        anchorData = self.radvizWidget.graph.anchorData 
    364365        attributeNameIndex = self.radvizWidget.graph.attributeNameIndex 
     
    367368        attrListIndices = [attributeNameIndex[val[2]] for val in anchorData] 
    368369        attrVals = [scaleFunction(example, index) for index in attrListIndices] 
    369                  
     370 
    370371        table = self.radvizWidget.graph.createProjectionAsExampleTable(attrListIndices, scaleFactor = self.radvizWidget.graph.trueScaleFactor, useAnchorData = 1) 
    371372        knn = self.radvizWidget.optimizationDlg.createkNNLearner(kValueFormula = 0)(table) 
     
    376377        if returnType == orange.GetBoth: return classVal, prob 
    377378        else:                            return classVal 
    378          
     379 
    379380 
    380381class S2NHeuristicLearner(orange.Learner): 
     
    383384        self.optimizationDlg = optimizationDlg 
    384385        self.name = "S2N Feature Selection Learner" 
    385          
     386 
    386387    def __call__(self, examples, weightID = 0, nrOfFreeVizSteps = 0): 
    387388        return S2NHeuristicClassifier(self.optimizationDlg, self.radvizWidget, examples, nrOfFreeVizSteps) 
    388389 
    389390 
    390                  
     391 
    391392 
    392393#test widget appearance 
     
    398399    ow.show() 
    399400    a.exec_loop() 
    400      
Note: See TracChangeset for help on using the changeset viewer.