Ignore:
Files:
20 added
7 deleted
82 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeCanvas/orngCanvas.pyw

    r9671 r10463  
    1616RedR = False 
    1717product = "Red R" if RedR else "Orange" 
    18  
    1918 
    2019class OrangeCanvasDlg(QMainWindow): 
     
    533532        if name.isEmpty(): 
    534533            return 
     534        name = unicode(name) 
    535535        self.schema.clear() 
    536         self.schema.loadDocument(str(name), freeze = 0, importBlank = 1) 
    537         self.addToRecentMenu(str(name)) 
     536        self.schema.loadDocument(name, freeze = 0, importBlank = 1) 
     537        self.addToRecentMenu(name) 
    538538     
    539539    def openSchema(self, filename): 
     
    554554        if name.isEmpty(): 
    555555            return 
     556        name = unicode(name) 
    556557        self.schema.clear() 
    557         dirname = os.path.dirname(str(name)) 
     558        dirname = os.path.dirname(name) 
    558559        os.chdir(dirname) 
    559         self.schema.loadDocument(str(name), freeze=0) 
    560         self.addToRecentMenu(str(name)) 
     560        self.schema.loadDocument(name, freeze=0) 
     561        self.addToRecentMenu(name) 
    561562 
    562563    def menuItemOpenFreeze(self): 
     
    564565        if name.isEmpty(): 
    565566            return 
     567        name = unicode(name) 
    566568        self.schema.clear() 
    567         dirname = os.path.dirname(str(name)) 
     569        dirname = os.path.dirname(name) 
    568570        os.chdir(dirname) 
    569         self.schema.loadDocument(str(name), freeze=1) 
    570         self.addToRecentMenu(str(name)) 
     571        self.schema.loadDocument(name, freeze=1) 
     572        self.addToRecentMenu(name) 
    571573 
    572574    def menuItemOpenLastSchema(self): 
     
    681683        qname = QFileDialog.getSaveFileName(self, "Save Output To File", self.canvasSettingsDir + "/Output.html", "HTML Document (*.html)") 
    682684        if qname.isEmpty(): return 
    683         name = str(qname) 
    684  
     685         
    685686        text = str(self.output.textOutput.toHtml()) 
    686687        #text = text.replace("</nobr>", "</nobr><br>") 
    687688 
    688         file = open(name, "wt") 
     689        file = open(unicode(name), "wt") 
    689690        file.write(text) 
    690691        file.close() 
  • Orange/OrangeCanvas/orngDlgs.py

    r9671 r10472  
    14001400class AboutDlg(QDialog): 
    14011401    def __init__(self, *args): 
    1402         apply(QDialog.__init__,(self,) + args) 
     1402        QDialog.__init__(self, *args) 
    14031403        self.topLayout = QVBoxLayout(self) 
    14041404#        self.setWindowFlags(Qt.Popup)       # Commented out, because it makes the window appear in the top-left corner on Linux 
     
    14131413         
    14141414        try: 
    1415             import orange 
    1416             version = orange.version.split("(")[0].strip() 
    1417             date = orange.version.split(",")[-1].strip(" )") 
    1418             OWGUI.widgetLabel(self, '<p align="center">version %s</p>' % (version)) 
    1419             OWGUI.widgetLabel(self, '<p align="center">(built %s)</p>' % (date)) 
    1420         except: 
     1415            import Orange.version as version 
     1416            short_version = version.short_version 
     1417            hg_revision = version.hg_revision 
     1418            OWGUI.widgetLabel(self, '<p align="center">version %s</p>' % (short_version)) 
     1419            if not version.release: 
     1420                OWGUI.widgetLabel(self, '<p align="center">(hg revision %s)</p>' % (hg_revision)) 
     1421        except ImportError: 
    14211422            pass 
    14221423        OWGUI.widgetLabel(self, "" ) 
     
    14281429        self.connect(butt, SIGNAL("clicked()"), self.accept) 
    14291430         
    1430          
    14311431 
    14321432class saveApplicationDlg(QDialog): 
  • Orange/OrangeCanvas/orngDoc.py

    r9671 r10463  
    438438 
    439439    def saveDocumentAs(self): 
    440         name = str(QFileDialog.getSaveFileName(self, "Save Orange Schema", os.path.join(self.schemaPath, self.schemaName or "Untitled.ows"), "Orange Widget Schema (*.ows)")) 
     440        name = QFileDialog.getSaveFileName(self, "Save Orange Schema", os.path.join(self.schemaPath, self.schemaName or "Untitled.ows"), "Orange Widget Schema (*.ows)") 
     441        name = unicode(name) 
    441442        if os.path.splitext(name)[0] == "": 
    442443            return 
     
    546547        try: 
    547548            #load the data ... 
    548             doc = parse(str(filename)) 
     549            doc = parse(filename) 
    549550            schema = doc.firstChild 
    550551            widgets = schema.getElementsByTagName("widgets")[0] 
     
    620621        qname = QFileDialog.getSaveFileName(self, "Save Orange Schema as Application", os.path.join(appPath, appName) , "Orange Scripts (*%s)" % extension) 
    621622        if qname.isEmpty(): return 
    622         (appPath, appName) = os.path.split(str(qname)) 
     623        qname = unicode(qname) 
     624        (appPath, appName) = os.path.split(qname) 
    623625        appNameWithoutExt = os.path.splitext(appName)[0] 
    624626        if os.path.splitext(appName)[1].lower() not in [".py", ".pyw"]: appName = appNameWithoutExt + extension 
  • Orange/OrangeCanvas/orngRegistry.py

    r9671 r10453  
    3535    
    3636def readCategories(silent=False): 
    37     currentCacheVersion = 2 
     37    try: 
     38        from Orange.version import version as orange_version 
     39    except ImportError: 
     40        # Orange.version module is writen by setup.py, what if orange was build 
     41        # using make 
     42        orange_version = "???" 
     43    # Add orange version to the cache version (because cache contains names 
     44    # of types inside the Orange hierarchy, if that changes the cache should be 
     45    # invalidated) 
     46    currentCacheVersion = (2, orange_version) 
    3847     
    3948    global widgetsWithError, widgetsWithErrorPrototypes 
     
    5463        else: 
    5564            cachedWidgetDescriptions = {} 
    56     except: 
     65    except Exception: 
    5766        cachedWidgetDescriptions = {}  
    5867 
  • Orange/OrangeWidgets/Classify/OWClassificationTreeViewer.py

    r9671 r10458  
    272272        selected = self.v.selectedItems() 
    273273        item = selected.pop() if selected else None  
    274         print selected 
    275274        self.handleSelectionChanged(item) 
    276275        if self.tree and item: 
  • Orange/OrangeWidgets/Classify/OWITree.py

    r9671 r10457  
    1111from orngDataCaching import * 
    1212 
     13from OWItemModels import VariableListModel 
     14 
    1315class FixedTreeLearner(orange.Learner): 
    1416    def __init__(self, classifier, name): 
     
    183185        self.targetCombo.clear() 
    184186        if self.data: 
    185             self.attrsCombo.addItems([str(a) for a in data.domain.attributes]) 
     187            model = VariableListModel(list(data.domain.attributes)) 
     188            self.attrsCombo.setModel(model) 
    186189            self.basstat = getCached(data, orange.DomainBasicAttrStat, (data,)) 
    187190             
  • Orange/OrangeWidgets/Data/OWFile.py

    r9671 r10462  
    1616 
    1717warnings.filterwarnings("error", ".*" , orange.KernelWarning, "OWFile", 11) 
    18  
    1918 
    2019class FileNameContextHandler(ContextHandler): 
     
    200199                startfile = self.recentFiles[0] 
    201200 
    202         filename = str(QFileDialog.getOpenFileName(self, 'Open Orange Data File', startfile, self.dlgFormats)) 
    203  
     201        filename = QFileDialog.getOpenFileName(self, 'Open Orange Data File', startfile, self.dlgFormats) 
     202        filename = unicode(filename) 
     203         
    204204        if filename == "": 
    205205            return 
  • Orange/OrangeWidgets/Data/OWPythonScript.py

    r9671 r10462  
    1313 
    1414import code 
     15 
    1516 
    1617class PythonSyntaxHighlighter(QSyntaxHighlighter): 
     
    431432    def onAddScriptFromFile(self, *args): 
    432433        file = QFileDialog.getOpenFileName(self, 'Open Python Script', self.codeFile, 'Python files (*.py)\nAll files(*.*)') 
     434        file = unicode(file) 
    433435        if file: 
    434             file = str(file) 
    435436            name = os.path.basename(file) 
    436437            self.libraryList.append(Script(name, open(file, "rb").read(), 0, file)) 
     
    493494    def openScript(self, filename=None): 
    494495        if filename == None: 
    495             self.codeFile = str(QFileDialog.getOpenFileName(self, 'Open Python Script', self.codeFile, 'Python files (*.py)\nAll files(*.*)'))     
     496            filename = unicode(QFileDialog.getOpenFileName(self, 'Open Python Script', 
     497                               self.codeFile, 'Python files (*.py)\nAll files(*.*)')) 
     498            self.codeFile = filename 
    496499        else: 
    497500            self.codeFile = filename 
     
    517520        else: 
    518521            filename = self.codeFile 
    519              
    520         self.codeFile = QFileDialog.getSaveFileName(self, 'Save Python Script', filename, 'Python files (*.py)\nAll files(*.*)') 
     522        filename = QFileDialog.getSaveFileName(self, 'Save Python Script', 
     523                            filename, 'Python files (*.py)\nAll files(*.*)')  
     524        self.codeFile = unicode(filename) 
    521525         
    522526        if self.codeFile: 
    523527            fn = "" 
    524             head, tail = os.path.splitext(str(self.codeFile)) 
     528            head, tail = os.path.splitext(self.codeFile) 
    525529            if not tail: 
    526530                fn = head + ".py" 
    527531            else: 
    528                 fn = str(self.codeFile) 
     532                fn = self.codeFile 
    529533             
    530534            f = open(fn, 'w') 
  • Orange/OrangeWidgets/Data/OWSave.py

    r9671 r10462  
    77""" 
    88 
    9 # 
    10 # OWFile.py 
    11 # The File Widget 
    12 # A widget for opening orange data files 
    13 # 
    149from OWWidget import * 
    1510import OWGUI 
     
    9186#       The following is a workaround. 
    9287#       (As a consequence, filter selection is not taken into account when appending a default extension.) 
    93         filename, selectedFilter = str(QFileDialog.getSaveFileName(self, 'Save Orange Data File', startfile, 
    94                          self.dlgFormats)), self.dlgFormats.split("\n")[0] 
    95  
     88        filename, selectedFilter = QFileDialog.getSaveFileName(self, 'Save Orange Data File', startfile, 
     89                         self.dlgFormats), self.dlgFormats.split("\n")[0] 
     90        filename = unicode(filename) 
    9691        if not filename or not os.path.split(filename)[1]: 
    9792            return 
     
    9994        ext = lower(os.path.splitext(filename)[1]) 
    10095        if not ext in self.savers: 
    101             filt_ext = self.re_filterExtension.search(str(str(selectedFilter))).group("ext") 
     96            filt_ext = self.re_filterExtension.search(str(selectedFilter)).group("ext") 
    10297            if filt_ext == ".*": 
    10398                filt_ext = ".tab" 
     
    105100 
    106101 
    107         self.addFileToList(str(filename)) 
     102        self.addFileToList(filename) 
    108103        self.saveFile() 
    109104 
     
    111106        self.error() 
    112107        if self.data is not None: 
    113             combotext = str(self.filecombo.currentText()) 
     108            combotext = unicode(self.filecombo.currentText()) 
    114109            if combotext == "(none)": 
    115110                QMessageBox.information( None, "Error saving data", "Unable to save data. Select first a file name by clicking the '...' button.", QMessageBox.Ok + QMessageBox.Default) 
     
    125120                return 
    126121            self.error() 
    127  
    128  
    129122 
    130123    def addFileToList(self,fn): 
  • Orange/OrangeWidgets/Evaluate/OWTestLearners.py

    r9671 r10450  
    107107        self.targetClass = 0 
    108108        self.loadSettings() 
    109         self.resampling = 0             # cross-validation 
    110109 
    111110        self.stat = self.cStatistics 
     
    466465 
    467466            if self.learners: 
    468                 self.score([l.id for l in self.learners.values()]) 
     467                self.recompute() 
    469468             
    470469        self.openContext("", data) 
     
    481480            if self.resampling == 4: 
    482481                if self.data: 
    483                     self.score([l.id for l in self.learners.values()]) 
     482                    self.recompute() 
    484483                else: 
    485484                    for l in self.learners.values(): 
     
    515514            else: # new learner 
    516515                self.learners[id] = Learner(learner, id) 
    517             if self.applyBtn.isEnabled(): 
    518                 self.recompute(True) 
     516            if self.applyOnAnyChange: 
     517                self.score([id]) 
    519518            else: 
    520                 self.score([id]) 
     519                self.recompute() 
    521520        else: # remove a learner and corresponding results 
    522521            if id in self.learners: 
     
    534533        self.preprocessor = pp 
    535534        if self.learners: 
    536             self.score([l.id for l in self.learners.values()]) 
    537             self.paintscores() 
     535            self.recompute() 
    538536 
    539537    # handle output signals 
  • Orange/OrangeWidgets/OWBaseWidget.py

    r10018 r10466  
    471471                except IOError: 
    472472                    return  
    473         if type(file) == str: 
     473        if isinstance(file, basestring): 
    474474            if os.path.exists(file): 
    475475                return open(file, "r") 
     
    522522            if file==None: 
    523523                file = os.path.join(self.widgetSettingsDir, self.captionTitle + ".ini") 
    524             if type(file) == str: 
     524            if isinstance(file, basestring): 
    525525                file = open(file, "w") 
    526526            cPickle.dump(settings, file) 
  • Orange/OrangeWidgets/OWClusterOptimization.py

    r9671 r10466  
    583583            qname = QFileDialog.getSaveFileName( self.lastSaveDirName + "/" + filename, "Interesting clusters (*.clu)", self, "", "Save Clusters") 
    584584            if qname.isEmpty(): return 
    585             name = str(qname) 
     585            name = unicode(qname) 
    586586        else: 
    587587            name = filename 
     
    620620        name = QFileDialog.getOpenFileName( self.lastSaveDirName, "Interesting clusters (*.clu)", self, "", "Open Clusters") 
    621621        if name.isEmpty(): return 
    622         name = str(name) 
     622        name = unicode(name) 
    623623 
    624624        dirName, shortFileName = os.path.split(name) 
     
    692692 
    693693    def saveToFileAccept(self): 
    694         fileName = str(QFileDialog.getSaveFileName("Graph","Portable Network Graphics (*.PNG);;Windows Bitmap (*.BMP);;Graphics Interchange Format (*.GIF)", None, "Save to...", "Save to...")) 
     694        fileName = unicode(QFileDialog.getSaveFileName("Graph","Portable Network Graphics (*.PNG);;Windows Bitmap (*.BMP);;Graphics Interchange Format (*.GIF)", None, "Save to...", "Save to...")) 
    695695        if fileName == "": return 
    696696        (fil,ext) = os.path.splitext(fileName) 
  • Orange/OrangeWidgets/OWDlgs.py

    r9671 r10463  
    217217    # EXTRA FUNCTIONS ############################################ 
    218218    def getFileName(self, defaultName, mask, extension): 
    219         fileName = str(QFileDialog.getSaveFileName(self, "Save to..", os.path.join(self.lastSaveDirName, defaultName), mask)) 
     219        fileName = unicode(QFileDialog.getSaveFileName(self, "Save to..", os.path.join(self.lastSaveDirName, defaultName), mask)) 
    220220        if not fileName: return None 
    221221        if not os.path.splitext(fileName)[1][1:]: fileName = fileName + extension 
  • Orange/OrangeWidgets/OWGUI.py

    r9873 r10466  
    955955            import os 
    956956            iconDir = os.path.join(os.path.dirname(__file__), "icons") 
    957             if type(pixmap) == str: 
     957            if isinstance(pixmap, basestring): 
    958958                if os.path.exists(pixmap): 
    959959                    name = pixmap 
     
    10101010            import os 
    10111011            iconDir = os.path.join(os.path.dirname(__file__), "icons") 
    1012             if type(pixmap) == str: 
     1012            if isinstance(pixmap, basestring): 
    10131013                if os.path.exists(pixmap): 
    10141014                    name = pixmap 
  • Orange/OrangeWidgets/OWItemModels.py

    r10046 r10459  
    109109     
    110110    def flags(self, index): 
    111         if index.isValid(): 
     111        if index.isValid() and index.row() < len(self._other_data): 
    112112            return self._other_data[index.row()].get("flags", self._flags) 
    113113        else: 
  • Orange/OrangeWidgets/OWMosaicOptimization.py

    r9671 r10466  
    471471            qname = QFileDialog.getSaveFileName(self, "Save the List of Visualizations",  os.path.join(self.lastSaveDirName, filename), "Interesting visualizations (*.mproj)") 
    472472            if qname.isEmpty(): return 
    473             name = str(qname) 
     473            name = unicode(qname) 
    474474        else: 
    475475            name = filename 
     
    498498            name = QFileDialog.getOpenFileName(self, "Open a List of Visualizations", self.lastSaveDirName, "Interesting visualizations (*.mproj)") 
    499499            if name.isEmpty(): return 
    500             name = str(name) 
     500            name = unicode(name) 
    501501 
    502502        dirName, shortFileName = os.path.split(name) 
     
    765765            if qname.isEmpty(): 
    766766                return 
    767             name = str(qname) 
     767            name = unicode(qname) 
    768768        self.lastSaveDirName = os.path.split(name)[0] 
    769769 
     
    784784            name = QFileDialog.getOpenFileName(self, "Load tree", self.lastSaveDirName, "Explorer tree (*.tree)") 
    785785            if name.isEmpty(): return 
    786             name = str(name) 
     786            name = unicode(name) 
    787787 
    788788        self.lastSaveDirName = os.path.split(name)[0] 
  • Orange/OrangeWidgets/OWReport.py

    r9873 r10462  
    229229    def saveReport(self): 
    230230        filename = QFileDialog.getSaveFileName(self, "Save Report", self.saveDir, "Web page (*.html *.htm)") 
     231        filename = unicode(filename) 
     232         
    231233        if not filename: 
    232234            return 
    233  
    234         filename = str(filename) 
     235         
    235236        path, fname = os.path.split(filename) 
    236237        self.saveDir = path 
     
    287288    def saveXML(self): 
    288289        filename = QFileDialog.getSaveFileName(self, "Export Report", self.saveDir, "XML file (*.xml)") 
     290        filename = unicode(filename) 
    289291        if not filename: 
    290292            return 
    291293 
    292         outf = file(str(filename), "wt") 
     294        outf = file(filename, "wt") 
    293295        outf.write('<?xml version="1.0" encoding="ascii"?>\n<report version="1.0">\n') 
    294296         
     
    319321    def loadXML(self): 
    320322        filename = QFileDialog.getOpenFileName(self, "Import Report", self.saveDir, "XML file (*.xml)") 
     323        filename = unicode(filename) 
     324         
    321325        if not filename: 
    322326            return 
  • Orange/OrangeWidgets/OWTreeViewer2D.py

    r9671 r10466  
    608608    def saveDot(self, filename=None): 
    609609        if filename==None: 
    610             filename = str(QFileDialog.getSaveFileName(self, "Save to ...", "tree.dot", "Dot Tree File (.DOT)")) 
     610            filename = QFileDialog.getSaveFileName(self, "Save to ...", "tree.dot", "Dot Tree File (.DOT)") 
     611            filename = unicode(filename) 
    611612            if not filename: 
    612613                return 
  • Orange/OrangeWidgets/OWkNNOptimization.py

    r9671 r10466  
    540540        qname = QFileDialog.getSaveFileName(self, "Save Projections",  os.path.join(self.lastSaveDirName, filename), "Interesting projections (*.proj)") 
    541541        if qname.isEmpty(): return 
    542         name = str(qname) 
     542        name = unicode(qname) 
    543543 
    544544        self.lastSaveDirName = os.path.split(name)[0] 
     
    563563            name = QFileDialog.getOpenFileName(self, "Open Projections", self.lastSaveDirName, "Interesting projections (*.proj)") 
    564564            if name.isEmpty(): return 
    565             name = str(name) 
     565            name = unicode(name) 
    566566 
    567567        dirName, shortFileName = os.path.split(name) 
     
    907907        else: 
    908908            startfile = self.recentGeneSets[0] 
    909         filename = str(QFileDialog.getOpenFileName(None, 'Open Gene Set File', startfile, 'Gene set files (*.gmt)\nAll files(*.*)')) 
     909        filename = unicode(QFileDialog.getOpenFileName(None, 'Open Gene Set File', startfile, 'Gene set files (*.gmt)\nAll files(*.*)')) 
    910910        if filename == "": return 
    911911        if filename in self.recentGeneSets: self.recentGeneSets.remove(filename) 
     
    12011201        else: 
    12021202            startfile = self.recentGeneSets[0] 
    1203         filename = str(QFileDialog.getOpenFileName(None,'Open Gene Set File', startfile, 'Gene set files (*.gmt)\nAll files(*.*)')) 
     1203        filename = unicode(QFileDialog.getOpenFileName(None,'Open Gene Set File', startfile, 'Gene set files (*.gmt)\nAll files(*.*)')) 
    12041204        if filename == "": return 
    12051205        if filename in self.recentGeneSets: self.recentGeneSets.remove(filename) 
  • Orange/OrangeWidgets/Prototypes/OWInteractionGraphProto.py

    r9671 r10466  
    624624    def saveCanvasToFile(self, canvas, size): 
    625625        qfileName = QFileDialog.getSaveFileName(None, "Save to..", "graph.png","Portable Network Graphics (.PNG)\nWindows Bitmap (.BMP)\nGraphics Interchange Format (.GIF)") 
    626         fileName = str(qfileName) 
     626        fileName = unicode(qfileName) 
    627627        if fileName == "": return 
    628628        (fil,ext) = os.path.splitext(fileName) 
  • Orange/OrangeWidgets/Prototypes/OWItemsetViz.py

    r9671 r10466  
    504504    def saveNetwork(self): 
    505505        filename = QFileDialog.getSaveFileName(QString.null,'PAJEK networks (*.net)') 
     506        filename = unicode(filename) 
    506507        if filename: 
    507508            fn = "" 
    508             head, tail = os.path.splitext(str(filename)) 
     509            head, tail = os.path.splitext(filename) 
    509510            if not tail: 
    510511                fn = head + ".net" 
    511512            else: 
    512                 fn = str(filename) 
     513                fn = filename 
    513514             
    514515            self.graph.visualizer.saveNetwork(fn) 
  • Orange/OrangeWidgets/Prototypes/OWLoadAssocRules.py

    r9671 r10462  
    6161        filename = QFileDialog.getOpenFileName(self, "Load Rules From File", 
    6262                        self.last_file, "Pickle files (*.pickle *.pck)\nAll files (*.*)") 
    63         filename = str(filename) 
     63        filename = unicode(filename) 
    6464        if filename: 
    6565            if filename in self.filename_history: 
  • Orange/OrangeWidgets/Prototypes/OWLoadClassifier.py

    r9671 r10462  
    77 
    88from OWWidget import * 
     9 
    910import OWGUI 
    1011import orange 
     
    6465        filename = QFileDialog.getOpenFileName(self, "Load Classifier From File", 
    6566                        self.lastFile, "Pickle files (*.pickle *.pck)\nAll files (*.*)") 
    66         filename = str(filename) 
     67        filename = unicode(filename) 
    6768        if filename: 
    6869            if filename in self.filenameHistory: 
  • Orange/OrangeWidgets/Prototypes/OWPickle.py

    r9671 r10462  
    6666        filename = QFileDialog.getSaveFileName(self, "Save Object As ...", 
    6767                    self.last_save_file, "Pickle files (*.pickle *.pck);; All files (*.*)") 
    68         filename = str(filename) 
     68        filename = unicode(filename) 
    6969        if filename: 
    7070            if filename in self.filename_history: 
  • Orange/OrangeWidgets/Prototypes/OWRScript.py

    r9671 r10462  
    66 
    77from OWWidget import * 
     8 
    89from OWPythonScript import OWPythonScript, Script, ScriptItemDelegate, PythonConsole 
    910from OWItemModels import PyListModel, ModelActionsWidget 
     
    304305         
    305306    def onAddScriptFromFile(self): 
    306         filename = str(QFileDialog.getOpenFileName(self, "Open script", self.lastDir)) 
     307        filename = QFileDialog.getOpenFileName(self, "Open script", self.lastDir) 
     308        filename = unicode(filename) 
    307309        if filename: 
    308310            script = open(filename, "rb").read() 
     
    315317        if row is not None: 
    316318            script = self.libraryModel[row] 
    317             filename = str(QFileDialog.getSaveFileName(self, "Save Script As", script.sourceFileName or self.lastDir)) 
     319            filename = QFileDialog.getSaveFileName(self, "Save Script As", script.sourceFileName or self.lastDir) 
     320            filename = unicode(filename) 
    318321            if filename: 
    319322                self.lastDir, name = os.path.split(filename) 
  • Orange/OrangeWidgets/Prototypes/OWSQL.py

    r9671 r10466  
    128128     
    129129    def saveToFile(self): 
    130         fname = str(QFileDialog.getSaveFileName(self, "File name", self.lastDir, "SQL File (*.sql)\nAll files (*.*)")) 
     130        fname = unicode(QFileDialog.getSaveFileName(self, "File name", self.lastDir, "SQL File (*.sql)\nAll files (*.*)")) 
    131131        if not fname: 
    132132            return 
  • Orange/OrangeWidgets/Prototypes/OWSQLSelect.py

    r9671 r10466  
    148148            self.queryFile = '' 
    149149        if filename == None: 
    150             self.queryFile = str(QFileDialog.getOpenFileName(self, 'Open SQL file', self.queryFile, 'SQL files (*.sql)\nAll files(*.*)'))     
     150            self.queryFile = unicode(QFileDialog.getOpenFileName(self, 'Open SQL file', self.queryFile, 'SQL files (*.sql)\nAll files(*.*)'))     
    151151        else: 
    152152            self.queryFile = filename 
     
    161161        if self.queryFile is None: 
    162162            self.queryFile = '' 
    163         self.queryFile = QFileDialog.getSaveFileName(self, 'Save SQL file', self.queryFile, 'SQL files (*.sql)\nAll files(*.*)') 
     163        self.queryFile = unicode(QFileDialog.getSaveFileName(self, 'Save SQL file', self.queryFile, 'SQL files (*.sql)\nAll files(*.*)')) 
    164164         
    165165        if self.queryFile: 
    166166            fn = "" 
    167             head, tail = os.path.splitext(str(self.queryFile)) 
     167            head, tail = os.path.splitext(self.queryFile) 
    168168            if not tail: 
    169169                fn = head + ".sql" 
    170170            else: 
    171                 fn = str(self.queryFile) 
     171                fn = self.queryFile 
    172172            f = open(fn, 'w') 
    173173            f.write(self.queryTextEdit.toPlainText()) 
  • Orange/OrangeWidgets/Prototypes/OWSaveAssocRules.py

    r9671 r10462  
    6464        filename = QFileDialog.getSaveFileName(self, "Save Rules As ...", 
    6565                    self.last_save_file, "Pickle files (*.pickle *.pck);; All files (*.*)") 
    66         filename = str(filename) 
     66        filename = unicode(filename) 
    6767        if filename: 
    6868            if filename in self.filename_history: 
  • Orange/OrangeWidgets/Prototypes/OWSaveClassifier.py

    r9671 r10462  
    6969        filename = QFileDialog.getSaveFileName(self, "Save Classifier As ...", 
    7070                    self.lastSaveFile, "Pickle files (*.pickle *.pck);; All files (*.*)") 
    71         filename = str(filename) 
     71        filename = unicode(filename) 
    7272        if filename: 
    7373            if filename in self.filenameHistory: 
  • Orange/OrangeWidgets/Prototypes/OWUnpickle.py

    r9671 r10462  
    99from OWWidget import * 
    1010import OWGUI 
    11  
    1211 
    1312class OWUnpickle(OWWidget): 
     
    6463        filename = QFileDialog.getOpenFileName(self, "Load Object From File", 
    6564                        self.last_file, "Pickle files (*.pickle *.pck)\nAll files (*.*)") 
    66         filename = str(filename) 
     65        filename = unicode(filename) 
    6766        if filename: 
    6867            if filename in self.filename_history: 
  • Orange/OrangeWidgets/Regression/OWLinearRegression.py

    r10156 r10449  
    1818 
    1919class OWLinearRegression(OWWidget): 
    20     settingsList = ["name", "use_ridge", "ridge_lambda",  
     20    settingsList = ["name", "intercept", "use_ridge", "ridge_lambda", 
    2121                    "use_lasso", "t", "tol"] 
    2222     
     
    3636          
    3737        self.name = "Linear Regression" 
     38        self.intercept = True 
    3839        self.use_ridge = False 
    3940        self.ridge_lambda = 1.0 
     
    5051        OWGUI.lineEdit(self.controlArea, self, "name", box="Learner/predictor name",    
    5152                       tooltip="Name of the learner/predictor") 
     53         
     54        OWGUI.checkBox(self.controlArea, self, 'intercept', 'Intercept') 
    5255         
    5356        bbox = OWGUI.radioButtonsInBox(self.controlArea, self, "use_lasso", [],  
     
    121124        if self.use_ridge: 
    122125            learner = linear.LinearRegressionLearner(name=self.name, 
    123                                                 ridgeLambda=self.ridge_lambda) 
     126                intercept=self.intercept, ridgeLambda=self.ridge_lambda) 
    124127        else: 
    125             learner = linear.LinearRegressionLearner(name=self.name) 
     128            learner = linear.LinearRegressionLearner(name=self.name, 
     129                intercept=self.intercept) 
    126130        predictor = None 
    127131        if self.preprocessor: 
  • Orange/OrangeWidgets/Unsupervised/OWDistanceFile.py

    r10398 r10466  
    167167        else: 
    168168            lastPath = "." 
    169         fn = str(QFileDialog.getOpenFileName(self, "Open Distance Matrix File",  
     169        fn = unicode(QFileDialog.getOpenFileName(self, "Open Distance Matrix File",  
    170170                                             lastPath, "Distance matrix (*.*)")) 
    171171        fn = os.path.abspath(fn) 
  • Orange/OrangeWidgets/Unsupervised/OWModelFile.py

    r9671 r10466  
    4848        else: 
    4949            lastPath = "." 
    50         fn = str(QFileDialog.getOpenFileName(self, "Open Original Data File",  
     50        fn = unicode(QFileDialog.getOpenFileName(self, "Open Original Data File",  
    5151                                             lastPath, "Data File (*.tab)")) 
    5252        fn = os.path.abspath(fn) 
  • Orange/OrangeWidgets/Unsupervised/OWNetExplorer.py

    r9671 r10466  
    11061106         
    11071107        filename = QFileDialog.getSaveFileName(self, 'Save Network File', '', 'PAJEK network (*.net)\nGML network (*.gml)') 
     1108        filename = unicode(filename) 
    11081109        if filename: 
    11091110            fn = "" 
    1110             head, tail = os.path.splitext(str(filename)) 
     1111            head, tail = os.path.splitext(filename) 
    11111112            if not tail: 
    11121113                fn = head + ".net" 
    11131114            else: 
    1114                 fn = str(filename) 
     1115                fn = filename 
    11151116             
    11161117            self.optimization.graph.save(fn) 
  • Orange/OrangeWidgets/Unsupervised/OWNetworkFile.py

    r9671 r10466  
    358358                startfile = self.recentFiles[0] 
    359359                 
    360         filename = str(QFileDialog.getOpenFileName(self, 'Open a Network File', startfile, "Pajek files (*.net)\nGML files (*.gml)\nAll files (*.*)")) 
     360        filename = unicode(QFileDialog.getOpenFileName(self, 'Open a Network File',  
     361                    startfile, "Pajek files (*.net)\nGML files (*.gml)\nAll files (*.*)")) 
    361362         
    362363        if filename == "": return 
     
    383384            startfile = self.recentDataFiles[0] 
    384385                 
    385         filename = str(QFileDialog.getOpenFileName(self, 'Open a Vertices Data File', startfile, 'Data files (*.tab)\nAll files(*.*)')) 
     386        filename = unicode(QFileDialog.getOpenFileName(self, 'Open a Vertices Data File', startfile, 'Data files (*.tab)\nAll files(*.*)')) 
    386387     
    387388        if filename == "": return 
     
    408409            startfile = self.recentEdgesFiles[0] 
    409410                 
    410         filename = str(QFileDialog.getOpenFileName(self, 'Open a Edges Data File', startfile, 'Data files (*.tab)\nAll files(*.*)')) 
     411        filename = unicode(QFileDialog.getOpenFileName(self, 'Open a Edges Data File', startfile, 'Data files (*.tab)\nAll files(*.*)')) 
    411412     
    412413        if filename == "": return 
  • Orange/OrangeWidgets/Unsupervised/OWNxExplorer.py

    r10082 r10466  
    520520                '', 'NetworkX graph as Python pickle (*.gpickle)\nPajek ' + \ 
    521521                'network (*.net)\nGML network (*.gml)') 
     522            filename = unicode(filename) 
    522523            if filename: 
    523524                fn = "" 
    524                 head, tail = os.path.splitext(str(filename)) 
     525                head, tail = os.path.splitext(filename) 
    525526                if not tail: 
    526527                    fn = head + ".net" 
    527528                else: 
    528                     fn = str(filename) 
     529                    fn = filename 
    529530 
    530531                items = self.graph.items() 
  • Orange/OrangeWidgets/Unsupervised/OWNxExplorerQwt.py

    r10082 r10466  
    10751075 
    10761076        filename = QFileDialog.getSaveFileName(self, 'Save Network File', '', 'NetworkX graph as Python pickle (*.gpickle)\nPajek network (*.net)\nGML network (*.gml)') 
     1077        fileanme = unicode(filename) 
    10771078        if filename: 
    10781079            fn = "" 
    1079             head, tail = os.path.splitext(str(filename)) 
     1080            head, tail = os.path.splitext(filename) 
    10801081            if not tail: 
    10811082                fn = head + ".net" 
    10821083            else: 
    1083                 fn = str(filename) 
     1084                fn = filename 
    10841085 
    10851086            for i in range(self.graph.number_of_nodes()): 
  • Orange/OrangeWidgets/Unsupervised/OWNxFile.py

    r9671 r10466  
    396396                startfile = self.recentFiles[0] 
    397397                 
    398         filename = str(QFileDialog.getOpenFileName(self, 'Open a Network File', startfile, "All network files (*.gpickle *.net *.gml)\nNetworkX graph as Python pickle (*.gpickle)\nPajek files (*.net)\nGML files (*.gml)\nAll files (*.*)")) 
     398        filename = unicode(QFileDialog.getOpenFileName(self, 'Open a Network File', startfile, "All network files (*.gpickle *.net *.gml)\nNetworkX graph as Python pickle (*.gpickle)\nPajek files (*.net)\nGML files (*.gml)\nAll files (*.*)")) 
    399399         
    400400        if filename == "": return 
     
    421421            startfile = self.recentDataFiles[0] 
    422422                 
    423         filename = str(QFileDialog.getOpenFileName(self, 'Open a Vertices Data File', startfile, 'Data files (*.tab)\nAll files(*.*)')) 
     423        filename = unicode(QFileDialog.getOpenFileName(self, 'Open a Vertices Data File', startfile, 'Data files (*.tab)\nAll files(*.*)')) 
    424424     
    425425        if filename == "": return 
     
    446446            startfile = self.recentEdgesFiles[0] 
    447447                 
    448         filename = str(QFileDialog.getOpenFileName(self, 'Open a Edges Data File', startfile, 'Data files (*.tab)\nAll files(*.*)')) 
     448        filename = unicode(QFileDialog.getOpenFileName(self, 'Open a Edges Data File', startfile, 'Data files (*.tab)\nAll files(*.*)')) 
    449449     
    450450        if filename == "": return 
  • Orange/OrangeWidgets/Unsupervised/OWSOM.py

    r9671 r10455  
    121121##        params=[{"iterations":self.iterations1, "radius":self.radius1, "alpha":self.alpha1}, 
    122122##                {"iterations":self.iterations2, "radius":self.radius2, "alpha":self.alpha2}] 
    123         self.learner = orngSOM.SOMLearner(name=self.LearnerName, map_shape=(self.xdim, self.ydim), topology=topology, neighborhood=neigh, 
     123        self.learner = orngSOM.SOMLearner(name=self.LearnerName, map_shape=(self.xdim, self.ydim), topology=topology, neighbourhood=neigh, 
    124124                                        epochs=self.iterations1, eps=self.eps, initialize=self.initialization, 
    125125                                        radius_ini=self.radius1, radius_fin=self.radius2) #alphaType=alphaT, parameters=params) 
  • Orange/OrangeWidgets/Unsupervised/OWSaveDistanceFile.py

    r9671 r10466  
    5858            lastPath = "." 
    5959             
    60         fn = str(QFileDialog.getSaveFileName(self, "Save Distance Matrix File", lastPath, "Distance files (*.dst)\nSymMatrix files (*.sym)\nAll files (*.*)")) 
     60        fn = unicode(QFileDialog.getSaveFileName(self, "Save Distance Matrix File", lastPath, "Distance files (*.dst)\nSymMatrix files (*.sym)\nAll files (*.*)")) 
    6161         
    6262        if not fn or not os.path.split(fn)[1]: 
     
    8282        self.error() 
    8383        if self.data is not None: 
    84             combotext = str(self.filecombo.currentText()) 
     84            combotext = unicode(self.filecombo.currentText()) 
    8585            if combotext == "(none)": 
    8686                QMessageBox.information( None, "Error saving data", "Unable to save data. Select first a file name by clicking the '...' button.", QMessageBox.Ok + QMessageBox.Default) 
  • Orange/OrangeWidgets/Visualize Qt/OWLinProjGraphQt.py

    r10475 r10476  
    558558        lastSave = getattr(self, "lastPicTeXSave", "C:\\") 
    559559        qfileName = QFileDialog.getSaveFileName(None, "Save to..", lastSave + "graph.pictex","PicTeX (*.pictex);;All files (*.*)") 
    560         fileName = str(qfileName) 
     560        fileName = unicode(qfileName) 
    561561        if fileName == "": 
    562562            return 
  • Orange/OrangeWidgets/Visualize Qt/OWLinProjQt.py

    r9671 r10466  
    284284        qname = QFileDialog.getSaveFileName(self, "Save File",  os.path.realpath(".") + "/Linear_projection.tab", "Orange Example Table (*.tab)") 
    285285        if qname.isEmpty(): return 
    286         name = str(qname) 
     286        name = unicode(qname) 
    287287        if len(name) < 4 or name[-4] != ".": 
    288288            name = name + ".tab" 
  • Orange/OrangeWidgets/Visualize Qt/OWParallelCoordinatesQt.py

    r9671 r10466  
    437437 
    438438        if name == None: 
    439             name = str(QFileDialog.getOpenFileName(self, "Open Projections",  self.lastSaveDirName, "Interesting projections (*.proj)")) 
     439            name = unicode(QFileDialog.getOpenFileName(self, "Open Projections",  self.lastSaveDirName, "Interesting projections (*.proj)")) 
    440440            if name == "": return 
    441441 
     
    607607            else:                                       filename += " - " + "vizrank" 
    608608 
    609             name = str(QFileDialog.getSaveFileName(self, "Save Parallel Projections",  os.path.join(self.lastSaveDirName, filename), "Parallel projections (*.papr)")) 
     609            name = unicode(QFileDialog.getSaveFileName(self, "Save Parallel Projections",  os.path.join(self.lastSaveDirName, filename), "Parallel projections (*.papr)")) 
    610610            if name == "": return 
    611611        else: 
     
    627627        self.clearResults() 
    628628 
    629         name = str(QFileDialog.getOpenFileName(self, "Open Parallel Projections",  self.lastSaveDirName, "Parallel projections (*.papr)")) 
     629        name = unicode(QFileDialog.getOpenFileName(self, "Open Parallel Projections",  self.lastSaveDirName, "Parallel projections (*.papr)")) 
    630630        if name == "": return 
    631631 
  • Orange/OrangeWidgets/Visualize/OWLinProj.py

    r9671 r10466  
    215215        qname = QFileDialog.getSaveFileName(self, "Save File",  os.path.realpath(".") + "/Linear_projection.tab", "Orange Example Table (*.tab)") 
    216216        if qname.isEmpty(): return 
    217         name = str(qname) 
     217        name = unicode(qname) 
    218218        if len(name) < 4 or name[-4] != ".": 
    219219            name = name + ".tab" 
  • Orange/OrangeWidgets/Visualize/OWLinProjGraph.py

    r10475 r10476  
    585585        lastSave = getattr(self, "lastPicTeXSave", "C:\\") 
    586586        qfileName = QFileDialog.getSaveFileName(None, "Save to..", lastSave + "graph.pictex","PicTeX (*.pictex);;All files (*.*)") 
    587         fileName = str(qfileName) 
     587        fileName = unicode(qfileName) 
    588588        if fileName == "": 
    589589            return 
  • Orange/OrangeWidgets/Visualize/OWParallelCoordinates.py

    r9671 r10466  
    439439 
    440440        if name == None: 
    441             name = str(QFileDialog.getOpenFileName(self, "Open Projections",  self.lastSaveDirName, "Interesting projections (*.proj)")) 
     441            name = unicode(QFileDialog.getOpenFileName(self, "Open Projections",  self.lastSaveDirName, "Interesting projections (*.proj)")) 
    442442            if name == "": return 
    443443 
     
    609609            else:                                       filename += " - " + "vizrank" 
    610610 
    611             name = str(QFileDialog.getSaveFileName(self, "Save Parallel Projections",  os.path.join(self.lastSaveDirName, filename), "Parallel projections (*.papr)")) 
     611            name = unicode(QFileDialog.getSaveFileName(self, "Save Parallel Projections",  os.path.join(self.lastSaveDirName, filename), "Parallel projections (*.papr)")) 
    612612            if name == "": return 
    613613        else: 
     
    629629        self.clearResults() 
    630630 
    631         name = str(QFileDialog.getOpenFileName(self, "Open Parallel Projections",  self.lastSaveDirName, "Parallel projections (*.papr)")) 
     631        name = unicode(QFileDialog.getOpenFileName(self, "Open Parallel Projections",  self.lastSaveDirName, "Parallel projections (*.papr)")) 
    632632        if name == "": return 
    633633 
  • Orange/__init__.py

    r10391 r10471  
    11from __future__ import absolute_import 
     2 
    23__version__ = "2.5a4" 
    34 
     
    1920    try: 
    2021        __import__(name, globals(), locals(), [], -1) 
    21     except Exception as err: 
    22         warnings.warn("%sImporting '%s' failed: %s" %  
     22    except ImportError, err: 
     23        warnings.warn("%sImporting '%s' failed: %s" % 
    2324            (disabledMsg if not alreadyWarned else "", name, err), 
    2425            UserWarning, 2) 
     
    133134#_import("misc.r") 
    134135 
     136try: 
     137    from . import version 
     138    # Always use short_version here (see PEP 386) 
     139    __version__ = version.short_version 
     140    __hg_revision__ = version.hg_revision 
     141except ImportError: 
     142    # Leave the default version defined at the top. 
     143    pass 
     144 
  • Orange/classification/tree.py

    r10371 r10467  
    26872687        for various outlines supported by GraphViz. 
    26882688        """ 
    2689         fle = type(file_name) == str and open(file_name, "wt") or file_name 
     2689        fle = isinstance(file_name, basestring) and open(file_name, "wt") or file_name 
    26902690 
    26912691        _TreeDumper(leaf_str, node_str, user_formats + 
  • Orange/clustering/__init__.py

    r9725 r10421  
    1 """ 
    2 .. index:: clustering 
    3  
    4 Everything about clustering, including agglomerative and hierarchical clustering. 
    5 """ 
    6  
    71from __future__ import with_statement 
    82 
  • Orange/data/sql.py

    r10089 r10438  
    119119        return (quirks, dbmod.connect(**dbArgDict)) 
    120120 
     121 
     122 
    121123class SQLReader(object): 
    122124    """ 
     
    150152        """ 
    151153        self._dirty = True 
    152         self.delDomain() 
     154        self.del_domain() 
    153155        (self.quirks, self.conn) = _connection(uri) 
    154156 
     
    161163            self.conn.disconnect() 
    162164 
    163     def getClassName(self): 
     165    def get_class_name(self): 
    164166        self.update() 
    165167        return self.domain.class_var.name 
    166168 
    167     def setClassName(self, className): 
    168         self._className = className 
    169         self.delDomain() 
    170  
    171     def delClassName(self): 
     169    def set_class_name(self, class_name): 
     170        self._className = class_name 
     171        self.del_domain() 
     172 
     173    def del_class_name(self): 
    172174        del self._className 
    173175 
    174     class_name = property(getClassName, setClassName, delClassName, "Name of class variable.") 
    175     className = class_name 
    176      
    177     def getMetaNames(self): 
     176    class_name = property(get_class_name, set_class_name, del_class_name, "Name of class variable.") 
     177 
     178    def get_metas_name(self): 
    178179        self.update() 
    179180        return self.domain.get_metas().values() 
    180181 
    181     def setMetaNames(self, meta_names): 
     182    def set_metas_name(self, meta_names): 
    182183        self._metaNames = meta_names 
    183         self.delDomain() 
    184  
    185     def delMetaNames(self): 
     184        self.del_domain() 
     185 
     186    def del_metas_name(self): 
    186187        del self._metaNames 
    187188 
    188     meta_names = property(getMetaNames, setMetaNames, delMetaNames, "Names of meta attributes.") 
    189     metaName = meta_names 
    190  
    191     def setDiscreteNames(self, discrete_names): 
     189    meta_names = property(get_metas_name, set_metas_name, del_metas_name, "Names of meta attributes.") 
     190 
     191    def set_discrete_names(self, discrete_names): 
    192192        self._discreteNames = discrete_names 
    193         self.delDomain() 
    194  
    195     def getDiscreteNames(self): 
     193        self.del_domain() 
     194 
     195    def get_discrete_names(self): 
    196196        self.update() 
    197197        return self._discreteNames 
    198198 
    199     def delDiscreteNames(self): 
     199    def del_discrete_names(self): 
    200200        del self._discreteNames 
    201201 
    202     discrete_names = property(getDiscreteNames, setDiscreteNames, delDiscreteNames, "Names of discrete attributes.") 
    203     discreteNames = discrete_names 
    204  
    205     def setQuery(self, query, domain = None): 
     202    discrete_names = property(get_discrete_names, set_discrete_names, del_discrete_names, "Names of discrete attributes.") 
     203 
     204    def set_query(self, query, domain = None): 
    206205        #sets the query, resets the internal variables, without executing the query 
    207206        self._query = query 
     
    210209            self._domain = domain 
    211210        else: 
    212             self.delDomain() 
    213  
    214     def getQuery(self): 
     211            self.del_domain() 
     212 
     213    def get_query(self): 
    215214        return self._query 
    216215 
    217     def delQuery(self): 
     216    def del_query(self): 
    218217        del self._query 
    219218 
    220     query = property(getQuery, setQuery, delQuery, "Query to be executed on the next execute().") 
     219    query = property(get_query, set_query, del_query, "Query to be executed on the next execute().") 
    221220 
    222221    def generateDomain(self): 
    223222        pass 
    224223 
    225     def setDomain(self, domain): 
     224    def set_domain(self, domain): 
    226225        self._domain = domain 
    227226        self._dirty = True 
    228227 
    229     def getDomain(self): 
     228    def get_domain(self): 
    230229        if not hasattr(self, '_domain'): 
    231230            self._createDomain() 
    232231        return self._domain 
    233232 
    234     def delDomain(self): 
     233    def del_domain(self): 
    235234        if hasattr(self, '_domain'): 
    236235            del self._domain 
    237236 
    238     domain = property(getDomain, setDomain, delDomain, "Orange domain.") 
     237    domain = property(get_domain, set_domain, del_domain, "Orange domain.") 
    239238 
    240239    def execute(self, query, domain = None): 
     
    242241        Executes an sql query. 
    243242        """ 
    244         self.setQuery(query, domain) 
     243        self.set_query(query, domain) 
    245244        self.update() 
    246245 
     
    330329        return None 
    331330 
     331SQLReader = deprecated_members({"discreteNames":"discrete_names", "metaName":"meta_names"\ 
     332    , "className":"class_name"})(SQLReader) 
     333 
    332334class SQLWriter(object): 
    333335    """ 
  • Orange/evaluation/scoring.py

    r10367 r10429  
    770770    return ss, df, statc.chisqprob(ss, df) 
    771771 
    772 @deprecated_keywords({"confm": "confusion_matrix"}) 
    773 def sens(confusion_matrix): 
    774     """ 
    775     Return `sensitivity 
     772class CMScore(list): 
     773    """ 
     774    :param test_results: :obj:`~Orange.evaluation.testing.ExperimentResults` 
     775                         or list of :obj:`ConfusionMatrix`. 
     776    :rtype: list of scores, one for each learner.""" 
     777    def __new__(cls, test_results, **kwargs): 
     778        self = list.__new__(cls) 
     779        if isinstance(test_results, ConfusionMatrix): 
     780            self.__init__(test_results, **kwargs) 
     781            return self[0] 
     782        return self 
     783 
     784 
     785    @deprecated_keywords({"confm": "test_results"}) 
     786    def __init__(self, test_results=None): 
     787        super(CMScore, self).__init__() 
     788 
     789        if test_results is not None: 
     790            self[:] = self.__call__(test_results) 
     791 
     792    def __call__(self, test_results): 
     793        if isinstance(test_results, testing.ExperimentResults): 
     794            test_results = confusion_matrices(test_results, class_index=1) 
     795        if isinstance(test_results, ConfusionMatrix): 
     796            test_results = [test_results] 
     797 
     798        return map(self.compute, test_results) 
     799 
     800 
     801 
     802class Sensitivity(CMScore): 
     803    __doc__ = """Compute `sensitivity 
    776804    <http://en.wikipedia.org/wiki/Sensitivity_and_specificity>`_ (proportion 
    777805    of actual positives which are correctly identified as such). 
    778     """ 
    779     if type(confusion_matrix) == list: 
    780         return [sens(cm) for cm in confusion_matrix] 
    781     else: 
     806    """ + CMScore.__doc__ 
     807    @classmethod 
     808    def compute(self, confusion_matrix): 
    782809        tot = confusion_matrix.TP+confusion_matrix.FN 
    783810        if tot < 1e-6: 
    784811            import warnings 
    785812            warnings.warn("Can't compute sensitivity: one or both classes have no instances") 
    786             return -1 
     813            return None 
    787814 
    788815        return confusion_matrix.TP / tot 
    789816 
    790817 
    791 @deprecated_keywords({"confm": "confusion_matrix"}) 
    792 def recall(confusion_matrix): 
    793     """ 
    794     Return `recall <http://en.wikipedia.org/wiki/Precision_and_recall>`_ 
     818class Recall(Sensitivity): 
     819    __doc__ = """ Compute `recall 
     820    <http://en.wikipedia.org/wiki/Precision_and_recall>`_ 
    795821    (fraction of relevant instances that are retrieved). 
    796     """ 
    797     return sens(confusion_matrix) 
    798  
    799  
    800 @deprecated_keywords({"confm": "confusion_matrix"}) 
    801 def spec(confusion_matrix): 
    802     """ 
    803     Return `specificity 
     822    """ + CMScore.__doc__ 
     823    pass # Recall == Sensitivity 
     824 
     825 
     826class Specificity(CMScore): 
     827    __doc__ = """Compute `specificity 
    804828    <http://en.wikipedia.org/wiki/Sensitivity_and_specificity>`_ 
    805829    (proportion of negatives which are correctly identified). 
    806     """ 
    807     if type(confusion_matrix) == list: 
    808         return [spec(cm) for cm in confusion_matrix] 
    809     else: 
     830    """ + CMScore.__doc__ 
     831    @classmethod 
     832    def compute(self, confusion_matrix): 
    810833        tot = confusion_matrix.FP+confusion_matrix.TN 
    811834        if tot < 1e-6: 
    812835            import warnings 
    813836            warnings.warn("Can't compute specificity: one or both classes have no instances") 
    814             return -1 
     837            return None 
    815838        return confusion_matrix.TN / tot 
    816839 
    817840 
    818 @deprecated_keywords({"confm": "confusion_matrix"}) 
    819 def PPV(confusion_matrix): 
    820     """ 
    821     Return `positive predictive value 
     841class PPV(CMScore): 
     842    __doc__ = """Compute `positive predictive value 
    822843    <http://en.wikipedia.org/wiki/Positive_predictive_value>`_ (proportion of 
    823     subjects with positive test results who are correctly diagnosed).""" 
    824     if type(confusion_matrix) == list: 
    825         return [PPV(cm) for cm in confusion_matrix] 
    826     else: 
     844    subjects with positive test results who are correctly diagnosed). 
     845    """ + CMScore.__doc__ 
     846    @classmethod 
     847    def compute(self, confusion_matrix): 
    827848        tot = confusion_matrix.TP + confusion_matrix.FP 
    828849        if tot < 1e-6: 
    829850            import warnings 
    830851            warnings.warn("Can't compute PPV: one or both classes have no instances") 
    831             return -1 
     852            return None 
    832853        return confusion_matrix.TP/tot 
    833854 
    834855 
    835 @deprecated_keywords({"confm": "confusion_matrix"}) 
    836 def precision(confusion_matrix): 
    837     """ 
    838     Return `precision <http://en.wikipedia.org/wiki/Precision_and_recall>`_ 
     856class Precision(PPV): 
     857    __doc__ = """Compute `precision <http://en.wikipedia.org/wiki/Precision_and_recall>`_ 
    839858    (retrieved instances that are relevant). 
    840     """ 
    841     return PPV(confusion_matrix) 
    842  
    843 @deprecated_keywords({"confm": "confusion_matrix"}) 
    844 def NPV(confusion_matrix): 
    845     """ 
    846     Return `negative predictive value 
     859    """ + CMScore.__doc__ 
     860    pass # Precision == PPV 
     861 
     862 
     863class NPV(CMScore): 
     864    __doc__ = """Compute `negative predictive value 
    847865    <http://en.wikipedia.org/wiki/Negative_predictive_value>`_ (proportion of 
    848866    subjects with a negative test result who are correctly diagnosed). 
    849      """ 
    850     if type(confusion_matrix) == list: 
    851         return [NPV(cm) for cm in confusion_matrix] 
    852     else: 
     867     """ + CMScore.__doc__ 
     868    @classmethod 
     869    def compute(self, confusion_matrix): 
    853870        tot = confusion_matrix.FN + confusion_matrix.TN 
    854871        if tot < 1e-6: 
    855872            import warnings 
    856873            warnings.warn("Can't compute NPV: one or both classes have no instances") 
    857             return -1 
     874            return None 
    858875        return confusion_matrix.TN / tot 
    859876 
    860 @deprecated_keywords({"confm": "confusion_matrix"}) 
    861 def F1(confusion_matrix): 
    862     """ 
    863     Return `F1 score <http://en.wikipedia.org/wiki/F1_score>`_ 
     877 
     878class F1(CMScore): 
     879    __doc__ = """Return `F1 score 
     880    <http://en.wikipedia.org/wiki/F1_score>`_ 
    864881    (harmonic mean of precision and recall). 
    865     """ 
    866     if type(confusion_matrix) == list: 
    867         return [F1(cm) for cm in confusion_matrix] 
    868     else: 
    869         p = precision(confusion_matrix) 
    870         r = recall(confusion_matrix) 
    871         if p + r > 0: 
     882    """ + CMScore.__doc__ 
     883    @classmethod 
     884    def compute(self, confusion_matrix): 
     885        p = Precision.compute(confusion_matrix) 
     886        r = Recall.compute(confusion_matrix) 
     887        if p is not None and r is not None and (p+r) != 0: 
    872888            return 2. * p * r / (p + r) 
    873889        else: 
    874890            import warnings 
    875891            warnings.warn("Can't compute F1: P + R is zero or not defined") 
    876             return -1 
    877  
    878  
    879 @deprecated_keywords({"confm": "confusion_matrix"}) 
    880 def Falpha(confusion_matrix, alpha=1.0): 
    881     """ 
    882     Return the alpha-mean of precision and recall over the given confusion 
     892            return None 
     893 
     894 
     895class Falpha(CMScore): 
     896    __doc__ = """Compute the alpha-mean of precision and recall over the given confusion 
    883897    matrix. 
    884     """ 
    885     if type(confusion_matrix) == list: 
    886         return [Falpha(cm, alpha=alpha) for cm in confusion_matrix] 
    887     else: 
    888         p = precision(confusion_matrix) 
    889         r = recall(confusion_matrix) 
    890         return (1. + alpha) * p * r / (alpha * p + r) 
    891  
    892  
    893 @deprecated_keywords({"confm": "confusion_matrix"}) 
    894 def MCC(confusion_matrix): 
    895     """ 
    896     Return `Matthew correlation coefficient 
     898    """ + CMScore.__doc__ 
     899 
     900    def __init__(self, test_results, alpha=1.): 
     901        self.alpha = alpha 
     902        super(Falpha, self).__init__(test_results) 
     903 
     904    def compute(self, confusion_matrix): 
     905        p = Precision.compute(confusion_matrix) 
     906        r = Recall.compute(confusion_matrix) 
     907        return (1. + self.alpha) * p * r / (self.alpha * p + r) 
     908 
     909 
     910class MCC(CMScore): 
     911    __doc__ = """Compute `Matthew correlation coefficient 
    897912    <http://en.wikipedia.org/wiki/Matthews_correlation_coefficient>`_ 
    898913    (correlation coefficient between the observed and predicted binary 
    899914    classifications). 
    900     """ 
    901     # code by Boris Gorelik 
    902     if type(confusion_matrix) == list: 
    903         return [MCC(cm) for cm in confusion_matrix] 
    904     else: 
    905         truePositive = confusion_matrix.TP 
    906         trueNegative = confusion_matrix.TN 
    907         falsePositive = confusion_matrix.FP 
    908         falseNegative = confusion_matrix.FN 
     915    """ + CMScore.__doc__ 
     916    @classmethod 
     917    def compute(self, cm): 
     918        # code by Boris Gorelik 
     919        TP, TN, FP, FN = cm.TP, cm.TN, cm.FP, cm.FN 
    909920           
    910         try:    
    911             r = (((truePositive * trueNegative) - 
    912                   (falsePositive * falseNegative)) / 
    913                  math.sqrt((truePositive + falsePositive) * 
    914                            (truePositive + falseNegative) *  
    915                            (trueNegative + falsePositive) *  
    916                            (trueNegative + falseNegative))) 
     921        try: 
     922            return (TP*TN - FP*FN) /\ 
     923                 math.sqrt((TP+FP) * (TP+FN) * (TN+ FP) * (TN+FN)) 
    917924        except ZeroDivisionError: 
    918             # Zero difision occurs when there is either no true positives  
     925            # Zero division occurs when there is either no true positives 
    919926            # or no true negatives i.e. the problem contains only one  
    920927            # type of classes. 
    921928            import warnings 
    922929            warnings.warn("Can't compute MCC: TP or TN is zero or not defined") 
    923             r = None 
    924  
    925     return r 
    926930 
    927931 
     
    976980       ret = (prActual - prExpected) / (1.0 - prExpected) 
    977981       return ret 
     982 
     983# Backward compatibility 
     984sens = Sensitivity 
     985spec = Specificity 
     986precision = Precision 
     987recall = Recall 
     988 
     989 
    978990 
    979991@deprecated_keywords({"classIndex": "class_index", 
     
    14681480    """ 
    14691481    Compute the area under ROC curve given a set of experimental results. 
    1470     For multivalued class problems, return the result of 
    1471     :obj:`by_weighted_pairs`. 
    14721482    If testing consisted of multiple folds, each fold is scored and the 
    14731483    average score is returned. If a fold contains only instances with the 
     
    14761486    :param test_results: test results to score 
    14771487    :param ignore_weights: ignore instance weights when calculating score 
    1478     :param method: DEPRECATED, call the appropriate method directly. 
    1479     """ 
     1488    :param multiclass: tells what kind of averaging to perform if the target 
     1489                       class has more than 2 values. 
     1490    """ 
     1491 
     1492    #!Compute AUC for each pair of classes (ignoring instances of all other 
     1493    #!classes) and average the results, weighting them by the number of 
     1494    #!pairs of instances from these two classes (e.g. by the product of 
     1495    #!probabilities of the two classes). AUC computed in this way still 
     1496    #!behaves as the concordance index, e.g., gives the probability that two 
     1497    #!randomly chosen instances from different classes will be correctly 
     1498    #!recognized (if the classifier knows from which two classes the 
     1499    #!instances came). 
     1500    ByWeightedPairs = 0 
     1501 
     1502    #!Similar to ByWeightedPairs, except that the average over class pairs 
     1503    #!is not weighted. This AUC is, like the binary version, independent of 
     1504    #!class distributions, but it is not related to the concordance index 
     1505    #!any more. 
     1506    ByPairs = 1 
     1507 
     1508    #!For each class, it computes AUC for this class against all others (that 
     1509    #!is, treating other classes as one class). The AUCs are then averaged by 
     1510    #!the class probabilities. This is related to the concordance index in 
     1511    #!which we test the classifier's (average) capability of distinguishing 
     1512    #!the instances from a specified class from those that come from other 
     1513    #!classes. 
     1514    #!Unlike the binary AUC, the measure is not independent of class 
     1515    #!distributions. 
     1516    WeightedOneAgainstAll = 2 
     1517 
     1518    #!Similar to weighted_one_against_all, except that the average 
     1519    #!is not weighted. 
     1520    OneAgainstAll = 3 
    14801521 
    14811522    @replace_use_weights 
    1482     def __init__(self, test_results=None, method=0, ignore_weights=False): 
     1523    @deprecated_keywords({"method": "multiclass"}) 
     1524    def __init__(self, test_results=None, multiclass=ByWeightedPairs, ignore_weights=False): 
    14831525 
    14841526        super(AUC, self).__init__() 
    14851527 
    14861528        self.ignore_weights=ignore_weights 
    1487         self.method=method 
     1529        self.method=multiclass 
    14881530 
    14891531        if test_results is not None: 
    1490             self.__call__(test_results) 
     1532            self[:] = self.__call__(test_results) 
    14911533 
    14921534    def __call__(self, test_results): 
     
    14941536            raise ValueError("Cannot compute AUC on a single-class problem") 
    14951537        elif len(test_results.class_values) == 2: 
    1496             self._compute_for_binary_class(test_results) 
    1497         else: 
    1498             self._compute_for_multi_value_class(test_results, self.method) 
    1499  
    1500     @classmethod 
    1501     def by_weighted_pairs(cls, res, ignore_weights=False): 
    1502         """ 
    1503         Compute AUC for each pair of classes (ignoring instances of all other 
    1504         classes) and average the results, weighting them by the number of 
    1505         pairs of instances from these two classes (e.g. by the product of 
    1506         probabilities of the two classes). AUC computed in this way still 
    1507         behaves as the concordance index, e.g., gives the probability that two 
    1508         randomly chosen instances from different classes will be correctly 
    1509         recognized (if the classifier knows from which two classes the 
    1510         instances came). 
    1511         """ 
    1512         auc = AUC(ignore_weights=ignore_weights) 
    1513         auc._compute_for_multi_value_class(res, method=cls.ByWeightedPairs) 
    1514         return auc 
    1515  
    1516     @classmethod 
    1517     def by_pairs(cls, res, ignore_weights=False): 
    1518         """ 
    1519         Similar to by_weighted_pairs, except that the average over class pairs 
    1520         is not weighted. This AUC is, like the binary version, independent of 
    1521         class distributions, but it is not related to the concordance index 
    1522         any more. 
    1523         """ 
    1524         auc = AUC(ignore_weights=ignore_weights) 
    1525         auc._compute_for_multi_value_class(res, method=cls.ByPairs) 
    1526         return auc 
    1527  
    1528     @classmethod 
    1529     def weighted_one_against_all(cls, res, ignore_weights=False): 
    1530         """ 
    1531         For each class, it computes AUC for this class against all others (that 
    1532         is, treating other classes as one class). The AUCs are then averaged by 
    1533         the class probabilities. This is related to the concordance index in 
    1534         which we test the classifier's (average) capability of distinguishing 
    1535         the instances from a specified class from those that come from other 
    1536         classes. 
    1537         Unlike the binary AUC, the measure is not independent of class 
    1538         distributions. 
    1539         """ 
    1540         auc = AUC(ignore_weights=ignore_weights) 
    1541         auc._compute_for_multi_value_class(res, 
    1542             method=cls.WeightedOneAgainstAll) 
    1543         return auc 
    1544  
    1545     @classmethod 
    1546     def one_against_all(cls, res, ignore_weights=False): 
    1547         """ 
    1548         Similar to weighted_one_against_all, except that the average 
    1549         is not weighted. 
    1550         """ 
    1551         auc = AUC(ignore_weights=ignore_weights) 
    1552         auc._compute_for_multi_value_class(res, method=cls.OneAgainstAll) 
    1553         return auc 
    1554  
    1555     @classmethod 
    1556     def single_class(cls, res, class_index=-1, ignore_weights=False): 
    1557         """ 
    1558         Compute AUC where the class with the given class_index is singled 
    1559         out and all other classes are treated as a single class. 
    1560         """ 
    1561         if class_index < 0: 
    1562             if res.base_class >= 0: 
    1563                 class_index = res.base_class 
    1564             else: 
    1565                 class_index = 1 
    1566  
    1567         auc = AUC(ignore_weights=ignore_weights) 
    1568         auc._compute_for_single_class(res, class_index) 
    1569         return auc 
    1570  
    1571     @classmethod 
    1572     def pair(cls, res, class_index1, class_index2, ignore_weights=False): 
    1573         """ 
    1574         Computes AUC between a pair of classes, ignoring instances from all 
    1575         other classes. 
    1576         """ 
    1577         auc = AUC(ignore_weights=ignore_weights) 
    1578         auc._compute_for_pair_of_classes(res, class_index1, class_index2) 
    1579         return auc 
    1580  
    1581     @classmethod 
    1582     def matrix(cls, res, ignore_weights=False): 
    1583         """ 
    1584         Compute a (lower diagonal) matrix with AUCs for all pairs of classes. 
    1585         If there are empty classes, the corresponding elements in the matrix 
    1586         are -1. 
    1587         """ 
    1588         auc = AUC(ignore_weights=ignore_weights) 
    1589         auc._compute_matrix(res) 
    1590         return auc 
     1538            return self._compute_for_binary_class(test_results) 
     1539        else: 
     1540            return self._compute_for_multi_value_class(test_results, self.method) 
    15911541 
    15921542    def _compute_for_binary_class(self, res): 
     
    15981548                (-1, res, res.number_of_iterations)) 
    15991549        else: 
    1600             auc, _ = self._compute_one_class_against_all(res, -1) 
    1601             self[:] = auc 
    1602             return self 
     1550            return self._compute_one_class_against_all(res, -1)[0] 
    16031551 
    16041552    def _compute_for_multi_value_class(self, res, method=0): 
     
    16541602            sum_aucs = [x/usefulClassPairs for x in sum_aucs] 
    16551603 
    1656         self[:] = sum_aucs 
    1657         return self 
     1604        return sum_aucs 
    16581605 
    16591606    # computes the average AUC over folds using "AUCcomputer" (AUC_i or AUC_ij) 
     
    16621609    # over all folds or even this failed; 
    16631610    # in these cases the result is returned immediately 
    1664     @deprecated_keywords({"AUCcomputer": "auc_computer", 
    1665                           "computerArgs": "computer_args"}) 
    16661611    def _compute_for_multiple_folds(self, auc_computer, iterations, 
    16671612                                 computer_args): 
     
    16711616            aucs, foldsUsed = auc_computer(*(ite, ) + computer_args) 
    16721617            if not aucs: 
    1673                 return None 
     1618                import warnings 
     1619                warnings.warn("AUC cannot be computed (all instances belong to the same class).") 
     1620                return 
    16741621            if not foldsUsed: 
     1622                self[:] = aucs 
    16751623                return aucs 
    16761624            subsum_aucs = map(add, subsum_aucs, aucs) 
    1677         self[:] = subsum_aucs 
    1678         return self 
     1625        return subsum_aucs 
    16791626 
    16801627    # Computes AUC 
     
    16841631    def _compute_for_single_class(self, res, class_index): 
    16851632        if res.number_of_iterations > 1: 
    1686             self._compute_for_multiple_folds( 
     1633            return self._compute_for_multiple_folds( 
    16871634                self._compute_one_class_against_all, split_by_iterations(res), 
    16881635                (class_index, res, res.number_of_iterations)) 
    16891636        else: 
    1690             self._compute_one_class_against_all(res, class_index) 
     1637            return self._compute_one_class_against_all(res, class_index) 
    16911638 
    16921639    # Computes AUC for a pair of classes (as if there were no other classes) 
     
    16951642    def _compute_for_pair_of_classes(self, res, class_index1, class_index2): 
    16961643        if res.number_of_iterations > 1: 
    1697             self._compute_for_multiple_folds( 
     1644            return self._compute_for_multiple_folds( 
    16981645                self._compute_one_class_against_another, 
    16991646                split_by_iterations(res), 
    17001647                (class_index1, class_index2, res, res.number_of_iterations)) 
    17011648        else: 
    1702             self._compute_one_class_against_another(res, class_index1, 
     1649            return self._compute_one_class_against_another(res, class_index1, 
    17031650                                                    class_index2) 
    17041651 
     
    17521699        return False, False 
    17531700 
    1754     def _compute_matrix(self, res): 
    1755         numberOfClasses = len(res.class_values) 
    1756         number_of_learners = res.number_of_learners 
    1757         if res.number_of_iterations > 1: 
    1758             iterations, all_ite = split_by_iterations(res), res 
    1759         else: 
    1760             iterations, all_ite = [res], None 
     1701class AUC_for_single_class(AUC): 
     1702    """ 
     1703    Compute AUC where the class with the given class_index is singled 
     1704    out and all other classes are treated as a single class. 
     1705    """ 
     1706    def __init__(self, test_results=None, class_index=-1, ignore_weights=False): 
     1707        if class_index < 0: 
     1708            if test_results and test_results.base_class >= 0: 
     1709                self.class_index = test_results.base_class 
     1710            else: 
     1711                self.class_index = 1 
     1712        else: 
     1713            self.class_index = class_index 
     1714 
     1715        super(AUC_for_single_class, self).__init__(test_results, ignore_weights=ignore_weights) 
     1716 
     1717    def __call__(self, test_results): 
     1718        return self._compute_for_single_class(test_results, self.class_index) 
     1719 
     1720 
     1721class AUC_for_pair_of_classes(AUC): 
     1722    """ 
     1723    Computes AUC between a pair of classes, ignoring instances from all 
     1724    other classes. 
     1725    """ 
     1726    def __init__(self, test_results, class_index1, class_index2, ignore_weights=False): 
     1727        self.class_index1 = class_index1 
     1728        self.class_index2 = class_index2 
     1729 
     1730        super(AUC_for_pair_of_classes, self).__init__(test_results, ignore_weights=ignore_weights) 
     1731 
     1732    def __call__(self, test_results): 
     1733        return self._compute_for_pair_of_classes(test_results, self.class_index1, self.class_index2) 
     1734 
     1735 
     1736class AUC_matrix(AUC): 
     1737    """ 
     1738    Compute a (lower diagonal) matrix with AUCs for all pairs of classes. 
     1739    If there are empty classes, the corresponding elements in the matrix 
     1740    are -1. 
     1741    """ 
     1742 
     1743    def __call__(self, test_results): 
     1744        numberOfClasses = len(test_results.class_values) 
     1745        number_of_learners = test_results.number_of_learners 
     1746        if test_results.number_of_iterations > 1: 
     1747            iterations, all_ite = split_by_iterations(test_results), test_results 
     1748        else: 
     1749            iterations, all_ite = [test_results], None 
    17611750        aucs = [[[] for _ in range(numberOfClasses)] 
    1762                 for _ in range(number_of_learners)] 
     1751        for _ in range(number_of_learners)] 
    17631752        for classIndex1 in range(numberOfClasses): 
    17641753            for classIndex2 in range(classIndex1): 
     
    17661755                    self._compute_one_class_against_another, iterations, 
    17671756                    (classIndex1, classIndex2, all_ite, 
    1768                      res.number_of_iterations)) 
     1757                     test_results.number_of_iterations)) 
    17691758                if pair_aucs: 
    17701759                    for lrn in range(number_of_learners): 
     
    17731762                    for lrn in range(number_of_learners): 
    17741763                        aucs[lrn][classIndex1].append(-1) 
    1775         self[:] = aucs 
    17761764        return aucs 
    17771765 
    17781766#Backward compatibility 
    1779 AUC.ByWeightedPairs = 0 
    1780 AUC.ByPairs = 1 
    1781 AUC.WeightedOneAgainstAll = 2 
    1782 AUC.OneAgainstAll = 3 
    1783  
    17841767@replace_use_weights 
    17851768def AUC_binary(res, ignore_weights=False): 
     
    17951778    return auc 
    17961779 
     1780 
     1781@deprecated_keywords({"AUCcomputer": "auc_computer", 
     1782                      "computerArgs": "computer_args"}) 
    17971783def AUC_iterations(auc_computer, iterations, computer_args): 
    17981784    auc = deprecated_function_name(AUC)() 
     
    18091795def AUC_i(ite, class_index, ignore_weights=False, all_ite=None, 
    18101796          divide_by_if_ite=1.): 
    1811     auc = deprecated_function_name(AUC)() 
     1797    auc = deprecated_function_name(AUC)(ignore_weights=ignore_weights) 
    18121798    result = auc._compute_one_class_against_another(ite, class_index, 
    1813         all_ite=None, divide_by_if_ite=1.) 
     1799        all_ite=all_ite, divide_by_if_ite=divide_by_if_ite) 
    18141800    return result 
    18151801 
     
    18201806    auc = deprecated_function_name(AUC)(ignore_weights=ignore_weights) 
    18211807    result = auc._compute_one_class_against_another( 
    1822         ite, class_index1, class_index2, all_ite=None, divide_by_if_ite=1.) 
     1808        ite, class_index1, class_index2, all_ite=all_ite, divide_by_if_ite=divide_by_if_ite) 
    18231809    return result 
    1824  
    1825  
    1826  
    1827  
    1828 #AUC_binary = replace_use_weights(deprecated_function_name(AUC()._compute_for_binary_class)) 
    1829 #AUC_multi = replace_use_weights(deprecated_function_name(AUC._compute_for_multi_value_class)) 
    1830 #AUC_iterations = replace_use_weights(deprecated_function_name(AUC._compute_for_multiple_folds)) 
    1831 #AUC_x = replace_use_weights(deprecated_function_name(AUC._compute_auc)) 
    1832 #AUC_i = replace_use_weights(deprecated_function_name(AUC._compute_one_class_against_all)) 
    1833 #AUC_ij = replace_use_weights(deprecated_function_name(AUC._compute_one_class_against_another)) 
    18341810 
    18351811AUC_single = replace_use_weights( 
    18361812             deprecated_keywords({"classIndex": "class_index"})( 
    1837              deprecated_function_name(AUC.single_class))) 
     1813             deprecated_function_name(AUC_for_single_class))) 
    18381814AUC_pair = replace_use_weights( 
    18391815           deprecated_keywords({"classIndex1": "class_index1", 
    18401816                                "classIndex2": "class_index2"})( 
    1841            deprecated_function_name(AUC.pair))) 
    1842 AUC_matrix = replace_use_weights(deprecated_function_name(AUC.matrix)) 
     1817           deprecated_function_name(AUC_for_pair_of_classes))) 
     1818AUC_matrix = replace_use_weights(deprecated_function_name(AUC_matrix)) 
    18431819 
    18441820 
  • Orange/multilabel/mlknn.py

    r9994 r10417  
    66*************************************** 
    77 
    8 ML-kNN Classification is a kind of adaptation method for multi-label classification. 
    9 It is an adaptation of the kNN lazy learning algorithm for multi-label data. 
    10 In essence, ML-kNN uses the kNN algorithm independently for each label :math:`l`. 
    11 It finds the k nearest examples to the test instance and considers those that are 
    12 labeled at least with :math:`l` as positive and the rest as negative. 
    13 Actually this method follows the paradigm of Binary Relevance (BR). What mainly 
    14 differentiates this method from BR is the use of prior probabilities. ML-kNN has also 
    15 the capability of producing a ranking of the labels as an output. 
    16 For more information, see Zhang, M. and Zhou, Z. 2007. `ML-KNN: A lazy learning 
    17 approach to multi-label learning <http://dx.doi.org/10.1016/j.patcog.2006.12.019>`_.  
    18 Pattern Recogn. 40, 7 (Jul. 2007), 2038-2048.   
     8ML-kNN Classification is an adaptation kNN for multi-label 
     9classification.  In essence, ML-kNN uses the kNN algorithm 
     10independently for each label :math:`l`.  It finds the k nearest 
     11examples to the test instance and considers those that are labeled at 
     12least with :math:`l` as positive and the rest as negative.  What 
     13mainly differentiates this method from other binary relevance (BR) 
     14methods is the use of prior probabilities. ML-kNN can also rank labels. 
     15 
     16For more information, see Zhang, M. and Zhou, Z. 2007. `ML-KNN: A lazy 
     17learning approach to multi-label learning 
     18<http://dx.doi.org/10.1016/j.patcog.2006.12.019>`_.  Pattern 
     19Recogn. 40, 7 (Jul. 2007), 2038-2048. 
    1920 
    2021.. index:: ML-kNN Learner 
     
    5051class MLkNNLearner(_multiknn.MultikNNLearner): 
    5152    """ 
    52     Class implementing the ML-kNN (Multi-Label k Nearest Neighbours) algorithm. The class is based on the  
    53     pseudo-code made available by the authors. 
     53    Class implementing the ML-kNN (Multi-Label k Nearest Neighbours) 
     54    algorithm. The class is based on the pseudo-code made available by 
     55    the authors. 
    5456     
    5557    The pseudo code of ML-kNN: 
  • Orange/multilabel/multiknn.py

    r9936 r10417  
    5454    def __new__(cls, k=1, **argkw): 
    5555        """ 
    56         Constructor of MultikNNLearner 
     56        Constructor for MultikNNLearner 
    5757                 
    5858        :param k: number of nearest neighbors used in classification 
  • Orange/multitarget/__init__.py

    r10331 r10420  
    2929    :lines: 1-6 
    3030 
    31 Multi-target learners can be used to build prediction models (classifiers) 
     31Multi-target learners can build prediction models (classifiers) 
    3232which then predict (multiple) class values for a new instance (continuation of 
    3333:download:`multitarget.py <code/multitarget.py>`): 
     
    9999class MultitargetClassifier(Orange.classification.Classifier): 
    100100    """ 
    101     Multitarget classifier returning a list of predictions from each 
     101    Multitarget classifier that returns a list of predictions from each 
    102102    of the independent base classifiers. 
    103103 
  • Orange/multitarget/tree.py

    r10335 r10432  
    8585        # Types of classes allowed 
    8686        self.handles_discrete = True 
    87         ### TODO: for discrete classes with >2 values entropy should be used instead of variance 
     87        ## TODO: for discrete classes with >2 values entropy should be used 
     88        ## instead of variance 
    8889        self.handles_continuous = True 
    8990        # Can handle continuous features 
     
    9596 
    9697 
    97     def threshold_function(self, feature, data, cont_distrib=None, weightID=0): 
     98    def threshold_function(self, feature, data, cont_distrib=None, weights=0): 
    9899        """ 
    99100        Evaluates possible splits of a continuous feature into a binary one 
     
    140141        return (threshold, score, None) 
    141142 
    142     def __call__(self, feature, data, apriori_class_distribution=None, weightID=0): 
     143    def __call__(self, feature, data, apriori_class_distribution=None, 
     144                 weights=0): 
    143145        """ 
    144146        :param feature: The feature to be scored. 
     
    154156        for ins in data: 
    155157            split[ins[feature].value].append(ins.get_classes()) 
    156         score = -sum(weighted_variance(x, self.weights) * len(x) for x in split.values()) 
     158        score = -sum(weighted_variance(x, self.weights) * len(x) 
     159                     for x in split.values()) 
    157160        return score 
    158161 
  • Orange/network/__init__.py

    r9994 r10468  
    5353from Orange.core import GraphAsList, GraphAsMatrix, GraphAsTree 
    5454 
     55# Test if networkx is installed 
     56__have_networkx = False 
    5557try: 
    56     from network import * 
     58    import networkx as nx 
     59    __have_networkx = True 
    5760except ImportError: 
    5861    import warnings 
    5962    warnings.warn("Warning: some features are disabled. Install networkx to use the 'Orange.network' module.")  
     63 
     64if __have_networkx: 
     65    from network import * 
    6066 
    6167import community 
  • Orange/network/network.py

    r9916 r10469  
    5959import networkx as nx 
    6060import Orange 
    61 import orangeom 
     61from Orange import orangeom 
    6262import readwrite 
    6363from networkx import algorithms 
  • Orange/network/readwrite.py

    r9671 r10469  
    3131import Orange 
    3232import Orange.network 
    33 import orangeom 
     33from Orange import orangeom 
    3434 
    3535__all__ = ['read', 'write', 'read_gpickle', 'write_gpickle', 'read_pajek',  
  • Orange/orng/orngTree.py

    r9671 r10467  
    3131    DEPRECATED. Replaced by :obj:`TreeClassifier.dump`. 
    3232    """ 
    33     fle = type(fileName) == str and file(fileName, "wt") or fileName 
     33    fle = isinstance(fileName, basestring) and file(fileName, "wt") or fileName 
    3434 
    3535    _TreeDumper(leafStr, nodeStr, argkw.get("userFormats", []) +  
  • Orange/projection/som.py

    r10316 r10455  
    133133 
    134134    Node    Instances 
    135     (0, 0)  21 
    136     (0, 1)  1 
    137     (0, 2)  23 
    138     (1, 0)  22 
     135    (0, 0)  31 
     136    (0, 1)  7 
     137    (0, 2)  0 
     138    (1, 0)  24 
    139139    (1, 1)  7 
    140     (1, 2)  6 
    141     (2, 0)  32 
    142     (2, 1)  16 
    143     (2, 2)  22 
    144      
    145     Data instances in cell (1, 2): 
    146     [4.9, 2.4, 3.3, 1.0, 'Iris-versicolor'] 
    147     [5.0, 2.0, 3.5, 1.0, 'Iris-versicolor'] 
    148     [5.6, 2.9, 3.6, 1.3, 'Iris-versicolor'] 
    149     [5.7, 2.6, 3.5, 1.0, 'Iris-versicolor'] 
    150     [5.5, 2.4, 3.7, 1.0, 'Iris-versicolor'] 
    151     [5.0, 2.3, 3.3, 1.0, 'Iris-versicolor'] 
     140    (1, 2)  50 
     141    (2, 0)  10 
     142    (2, 1)  21 
     143    (2, 2)  0 
     144 
     145    Data instances in cell (0, 1): 
     146    [6.9, 3.1, 4.9, 1.5, 'Iris-versicolor'] 
     147    [6.7, 3.0, 5.0, 1.7, 'Iris-versicolor'] 
     148    [6.3, 2.9, 5.6, 1.8, 'Iris-virginica'] 
     149    [6.5, 3.2, 5.1, 2.0, 'Iris-virginica'] 
     150    [6.4, 2.7, 5.3, 1.9, 'Iris-virginica'] 
     151    [6.1, 2.6, 5.6, 1.4, 'Iris-virginica'] 
     152    [6.5, 3.0, 5.2, 2.0, 'Iris-virginica'] 
    152153     
    153154""" 
     
    225226 
    226227    def radius(self, epoch): 
    227         return self.radius_ini - (float(self.radius_ini) - self.radius_fin)*(float(epoch) / self.epochs) 
    228  
    229     def alpha(self, epoch): 
    230         """Compute the learning rate from epoch, starting with learning_rate to 0 at the end of training.  
    231         """ 
    232         return (1 - epoch/self.epochs)*self.learning_rate 
    233              
     228        return self.radius_ini - (float(self.radius_ini) - self.radius_fin)*(float(epoch) / (self.epochs-1)) 
     229 
     230    def radius_seq(self, iter): 
     231        """Compute the radius regarding the iterations, not epochs.""" 
     232        iterations = len(self.data)*self.epochs 
     233        return self.radius_ini - (float(self.radius_ini) - self.radius_fin)*(float(iter) / (iterations-1)) 
     234 
     235    def alpha(self, iter): 
     236        """Compute the learning rate from iterations, starting with learning_rate to 0 at the end of training. 
     237        """ 
     238        iterations = len(self.data)*self.epochs 
     239        return (1 - float(iter)/(iterations-1))*self.learning_rate 
     240 
    234241    @deprecated_keywords({"progressCallback": "progress_callback"}) 
    235242    def __call__(self, data, map, progress_callback=None): 
     
    287294            self.distances.append(min_dist) 
    288295 
     296            iter = epoch*len(self.data)+ind 
     297 
    289298            if self.neighbourhood == Map.NeighbourhoodGaussian: 
    290                 h = numpy.exp(-self.unit_distances[:, bmu]/(2*self.radius(epoch))) * (self.unit_distances[:, bmu] <= self.radius(epoch)) 
     299                h = numpy.exp(-self.unit_distances[:, bmu]**2/(2*self.radius_seq(iter)**2)) * (self.unit_distances[:, bmu]**2 <= self.radius_seq(iter)**2) 
    291300            elif self.neighbourhood == Map.NeighbourhoodEpanechicov: 
    292                 h = 1.0 - (self.unit_distances[:bmu]/self.radius(epoch))**2 
     301                h = 1.0 - (self.unit_distances[:bmu]/self.radius_seq(iter))**2 
    293302                h = h * (h >= 0.0) 
    294303            else: 
    295                 h = 1.0*(self.unit_distances[:, bmu] <= self.radius(epoch)) 
    296             h = h * self.alpha(epoch) 
     304                h = 1.0*(self.unit_distances[:, bmu] <= self.radius_seq(iter)) 
     305            h = h * self.alpha(iter) 
    297306 
    298307            nonzero = ma.nonzero(h) 
     
    344353 
    345354        if self.neighbourhood == Map.NeighbourhoodGaussian:         
    346             H = numpy.exp(-self.unit_distances/(2*self.radius(epoch))) * (self.unit_distances <= self.radius(epoch)) 
     355            H = numpy.exp(-self.unit_distances**2/(2*self.radius(epoch)**2)) * (self.unit_distances**2 <= self.radius(epoch)**2) 
    347356        elif self.neighbourhood == Map.NeighbourhoodEpanechicov: 
    348357            H = 1.0 - (self.unit_distances/self.radius(epoch))**2 
     
    676685        nodes = list(self) 
    677686        coords = numpy.zeros((len(nodes), len(self.map_shape))) 
    678         coords[:, 0] = numpy.floor(numpy.arange(len(nodes)) / self.map_shape[0]) 
    679         coords[:, 1] = numpy.mod(numpy.arange(len(nodes)), self.map_shape[1]) 
    680          
    681         ## in hexagonal topology we move every odd map row by 0.5 and multiply all by sqrt(0.75) 
     687 
     688        k = [self.map_shape[1],1] 
     689        inds = numpy.arange(len(nodes)) 
     690        for i in range(0,len(self.map_shape)): 
     691            coords[:,i] = numpy.transpose(numpy.floor(inds/k[i])) 
     692            inds = numpy.mod(inds,k[i]) 
     693 
     694        ## in hexagonal topology we move every odd map row by 0.5 (only the second coordinate) 
     695        ## and multiply all the first coordinates by sqrt(0.75) to assure that 
     696        ## distances between neighbours are of unit size 
    682697        if self.topology == Map.HexagonalTopology: 
    683             ind = numpy.nonzero(1 - numpy.mod(coords[:, 0], 2)) 
    684             coords[ind] = coords[ind] + 0.5 
    685             coords = coords * numpy.sqrt(0.75) 
     698            ind = numpy.nonzero(numpy.mod(coords[:, 0], 2)) 
     699            coords[ind,1] = coords[ind,1] + 0.5 
     700            coords[:,0] = coords[:,0] * numpy.sqrt(0.75) 
    686701        return coords 
    687702 
     
    733748        for d in range(mdim): 
    734749            max, min = numpy.max(unit_coords[:, d]), numpy.min(unit_coords[:, d]) 
    735             unit_coords[:, d] = (unit_coords[:, d] - min)/(max - min) 
     750            if max > min: 
     751                unit_coords[:, d] = (unit_coords[:, d] - min)/(max - min) 
     752            ## in case of one-dimensional SOM 
     753            else: 
     754                unit_coords[:, d] = 0.5 
     755 
    736756        unit_coords = (unit_coords - 0.5) * 2 
    737757 
  • Orange/regression/earth.py

    r10330 r10420  
    104104class EarthLearner(Orange.regression.base.BaseRegressionLearner): 
    105105    """Earth learner class. Supports both regression and classification 
    106     problems. In case of classification the class values are expanded into  
     106    problems. For classification, class values are expanded into  
    107107    continuous indicator columns (one for each value if the number of  
    108     values is grater then 2), and a multi response model is learned on these 
    109     new columns. The resulting classifier will then use the computed response 
     108    values is grater then 2), and a multi response model is fit to these 
     109    new columns. The resulting classifier the computes response 
    110110    values on new instances to select the final predicted class. 
    111111      
     
    126126         
    127127        :param degree: Maximum degree (num. of hinge functions per term) 
    128             of the terms in the model. 
     128            of the terms in the model (default: 1). 
    129129        :type degree: int 
    130         :param terms: Maximum number of terms in the forward pass (default 21). 
    131              
    132             .. note:: If this paramter is None then  
    133                 ``min(200, max(20, 2 * n_attributes)) + 1`` will be used. This 
    134                 is the same as the default setting in earth R package. 
    135                  
     130        :param terms: Maximum number of terms in the forward pass 
     131                (default: 21).  If set to ``None``, ``min(200, max(20, 2 
     132                * n_attributes)) + 1`` will be used, like the default 
     133                setting in earth R package. 
    136134        :type terms: int 
    137135        :param penalty: Penalty for hinges in the GCV computation (used  
    138             in the pruning pass). By default it is 3.0 if the degree > 1, 
    139             2.0 otherwise.  
     136            in the pruning pass). Default is 3.0 if ``degree`` is above 1, 
     137            and 2.0 otherwise.  
    140138        :type penalty: float 
    141139        :param thresh: Threshold for RSS decrease in the forward pass 
    142             (default 0.001). 
     140            (default: 0.001). 
    143141        :type thresh: float 
    144142        :param min_span: TODO. 
    145143        :param new_var_penalty: Penalty for introducing a new variable 
    146             in the model during the forward pass (default 0). 
     144            in the model during the forward pass (default: 0). 
    147145        :type new_var_penalty: float 
    148146        :param fast_k: Fast k. 
    149147        :param fast_beta: Fast beta. 
    150148        :param pruned_terms: Maximum number of terms in the model after 
    151             pruning (default None - no limit). 
     149            pruning (default: ``None``, no limit). 
    152150        :type pruned_terms: int 
    153         :param scale_resp: Scale responses prior to forward pass (default 
    154             True - ignored for multi response models). 
     151        :param scale_resp: Scale responses prior to forward pass (default: 
     152            ``True``); ignored for models with multiple responses. 
    155153        :type scale_resp: bool 
    156154        :param store_instances: Store training instances in the model 
    157             (default True). 
     155            (default: ``True``). 
    158156        :type store_instances: bool 
    159157          
     
    333331    def base_matrix(self, instances=None): 
    334332        """Return the base matrix (bx) of the Earth model for the table. 
    335         If table is not supplied the base matrix of the training instances  
     333        If table is not supplied, the base matrix of the training instances  
    336334        is returned. 
    337335        Base matrix is a len(instances) x num_terms matrix of computed values 
     
    350348     
    351349    def predict(self, instance): 
    352         """ Predict the response values for the instance 
     350        """ Predict the response value(s) 
    353351         
    354352        :param instance: Data instance 
     
    363361     
    364362    def used_attributes(self, term=None): 
    365         """ Return the used terms for term (index). If no term is given 
     363        """Return the used terms for term (index). If no term is given, 
    366364        return all attributes in the model. 
    367365         
     
    965963             
    966964class ScoreEarthImportance(scoring.Score): 
    967     """ An :class:`Orange.feature.scoring.Score` subclass. 
    968     Scores features based on their importance in the Earth 
    969     model using ``bagged_evimp``'s function return value. 
     965    """ A subclass of :class:`Orange.feature.scoring.Score` that. 
     966    scores features based on their importance in the Earth 
     967    model using ``bagged_evimp``. 
    970968     
    971969    """ 
  • Orange/regression/linear.py

    r10348 r10436  
    150150    """     
    151151 
    152     def __init__(self, name='linear regression', intercept=True, \ 
    153                  compute_stats=True, ridge_lambda=None,\ 
    154                  imputer=None, continuizer=None, \ 
    155                  use_vars=None, stepwise=False, add_sig=0.05, 
    156                  remove_sig=0.2, **kwds): 
     152    def __init__(self, name='linear regression', intercept=True, 
     153                 compute_stats=True, ridge_lambda=None, imputer=None, 
     154                 continuizer=None, use_vars=None, stepwise=False, 
     155                 add_sig=0.05, remove_sig=0.2, **kwds): 
    157156        """ 
    158157        :param name: name of the linear model, default 'linear regression' 
     
    160159        :param intercept: if True, the intercept beta0 is included 
    161160            in the model 
    162         :type intercept: boolean 
     161        :type intercept: bool 
    163162        :param compute_stats: if True, statistical properties of 
    164163            the estimators (standard error, t-scores, significances) 
    165164            and statistical properties of the model 
    166165            (sum of squares, R2, adjusted R2) are computed 
    167         :type compute_stats: boolean 
    168         :param ridge_lambda: if not None, the lambda parameter 
    169             in ridge regression 
    170         :type ridge_lambda: integer or None 
     166        :type compute_stats: bool 
     167        :param ridge_lambda: if not None, ridge regression is performed  
     168                             with the given lambda parameter controlling 
     169                             the regularization 
     170        :type ridge_lambda: :obj:`int` or :obj:`None` 
    171171        :param use_vars: the list of independent varaiables included in 
    172172            regression model. If None (default) all variables are used 
     
    176176            based on F-test is performed. The significance parameters are 
    177177            add_sig and remove_sig 
    178         :type stepwise: boolean 
     178        :type stepwise: bool 
    179179        :param add_sig: lower bound of significance for which the variable 
    180180            is included in regression model 
     
    222222        if self.stepwise: 
    223223            use_vars = stepwise(table, weight, add_sig=self.add_sig, 
    224                                       remove_sig=self.remove_sig) 
     224                                remove_sig=self.remove_sig) 
    225225            new_domain = Orange.data.Domain(use_vars, table.domain.class_var) 
    226226            new_domain.addmetas(table.domain.getmetas()) 
     
    236236        if self.intercept: 
    237237            if A is None: 
    238                 X = numpy.ones([n,1]) 
     238                X = numpy.ones([n, 1]) 
    239239            else: 
    240240                X = numpy.insert(A, 0, 1, axis=1) # adds a column of ones 
     241            m += 1 
    241242        else: 
    242243            X = A 
     
    259260            cov = pinv(dot(dot(X.T, W), X)) 
    260261        else: 
    261             cov = pinv(dot(dot(X.T, W), X) - self.ridge_lambda*numpy.eye(m+1)) 
    262             compute_stats = False # TO DO: find inferential properties of the estimators 
     262            cov = pinv(dot(dot(X.T, W), X) + self.ridge_lambda * numpy.eye(m)) 
     263            # TODO: find inferential properties of the estimators 
     264            compute_stats = False  
    263265        D = dot(dot(cov, X.T), W) 
    264266        coefficients = dot(D, y) 
     
    269271 
    270272            # standardized coefficients 
    271             std_coefficients = (sqrt(cov_x.diagonal()) / sigma_y) \ 
    272                                 * coefficients 
     273            std_coefficients = sqrt(cov_x.diagonal()) / sigma_y * coefficients 
    273274        else: 
    274275            std_coefficients = None 
    275276 
    276277        if compute_stats is False: 
    277             return LinearRegression(domain.class_var, domain, coefficients=coefficients, 
    278                                     std_coefficients=std_coefficients, intercept=self.intercept) 
     278            return LinearRegression(domain.class_var, domain, 
     279                coefficients=coefficients, std_coefficients=std_coefficients, 
     280                intercept=self.intercept) 
    279281             
    280282 
    281283        fitted = dot(X, coefficients) 
    282         residuals = [ins.get_class() - fitted[i] \ 
     284        residuals = [ins.get_class() - fitted[i] 
    283285                     for i, ins in enumerate(table)] 
    284286 
     
    292294        # coefficient of determination 
    293295        r2 = ssr / sst 
    294         r2adj = 1-(1-r2)*(n-1)/(n-m-1) 
    295         F = (ssr/m)/(sst-ssr/(n-m-1)) 
    296         df = n-2  
    297         sigma_square = sse/(n-m-1) 
     296        r2adj = 1 - (1 - r2) * (n - 1) / (n - m - 1) 
     297        F = (ssr / m) / (sst - ssr / (n - m - 1)) 
     298        df = n - 2 
     299        sigma_square = sse / (n - m - 1) 
    298300        # standard error of the regression estimator, t-scores and p-values 
    299         std_error = sqrt(sigma_square*pinv(dot(X.T, X)).diagonal()) 
    300         t_scores = coefficients/std_error 
    301         p_vals = [stats.betai(df*0.5,0.5,df/(df + t*t)) \ 
     301        std_error = sqrt(sigma_square * pinv(dot(X.T, X)).diagonal()) 
     302        t_scores = coefficients / std_error 
     303        p_vals = [stats.betai(df * 0.5, 0.5, df / (df + t * t)) 
    302304                  for t in t_scores] 
    303305 
     
    306308        dict_model = {} 
    307309        if self.intercept: 
    308             dict_model["Intercept"] = (coefficients[0],\ 
    309                                       std_error[0], \ 
    310                                       t_scores[0], \ 
    311                                       p_vals[0]) 
     310            dict_model["Intercept"] = (coefficients[0], std_error[0], 
     311                                       t_scores[0], p_vals[0]) 
    312312        for i, var in enumerate(domain.attributes): 
    313313            j = i + 1 if self.intercept else i 
    314             dict_model[var.name] = (coefficients[j], \ 
    315                                    std_error[j],\ 
    316                                    t_scores[j],\ 
    317                                    p_vals[j]) 
     314            dict_model[var.name] = (coefficients[j], std_error[j], 
     315                                    t_scores[j], p_vals[j]) 
    318316         
    319317        return LinearRegression(domain.class_var, domain, coefficients, F, 
    320                  std_error=std_error, t_scores=t_scores, p_vals=p_vals, dict_model=dict_model, 
    321                  fitted=fitted, residuals=residuals, m=m, n=n, mu_y=mu_y, 
    322                  r2=r2, r2adj=r2adj, sst=sst, sse=sse, ssr=ssr, 
    323                  std_coefficients=std_coefficients, intercept=self.intercept) 
     318                 std_error=std_error, t_scores=t_scores, p_vals=p_vals, 
     319                 dict_model=dict_model, fitted=fitted, residuals=residuals, 
     320                 m=m, n=n, mu_y=mu_y, r2=r2, r2adj=r2adj, sst=sst, sse=sse, 
     321                 ssr=ssr, std_coefficients=std_coefficients, 
     322                 intercept=self.intercept) 
    324323 
    325324deprecated_members({"ridgeLambda": "ridge_lambda", 
     
    414413    def __init__(self, class_var=None, domain=None, coefficients=None, F=None, 
    415414                 std_error=None, t_scores=None, p_vals=None, dict_model=None, 
    416                  fitted=None, residuals=None, m = None, n=None, mu_y=None, 
     415                 fitted=None, residuals=None, m=None, n=None, mu_y=None, 
    417416                 r2=None, r2adj=None, sst=None, sse=None, ssr=None, 
    418417                 std_coefficients=None, intercept=None): 
     
    442441        self.intercept = intercept 
    443442 
    444     def __call__(self, instance, \ 
     443    def __call__(self, instance, 
    445444                 result_type=Orange.classification.Classifier.GetValue): 
    446445        """ 
    447446        :param instance: data instance for which the value of the response 
    448             variable will be predicted 
    449         :type instance:  
     447                         variable will be predicted 
     448        :type instance: :obj:`~Orange.data.Instance` 
    450449        """         
    451450        ins = Orange.data.Instance(self.domain, instance) 
     
    457456        if self.intercept: 
    458457            if len(self.coefficients) > 1: 
    459                 y_hat = self.coefficients[0] + \ 
    460                        dot(self.coefficients[1:], ins[:-1]) 
     458                y_hat = self.coefficients[0] + dot(self.coefficients[1:], 
     459                                                   ins[:-1]) 
    461460            else: 
    462461                if len(ins) == 1: 
     
    470469        y_hat = self.class_var(y_hat) 
    471470        dist = Orange.statistics.distribution.Continuous(self.class_var) 
    472         dist[y_hat] = 1.0 
     471        dist[y_hat] = 1. 
    473472        if result_type == Orange.classification.Classifier.GetValue: 
    474473            return y_hat 
     
    488487        lines = [join(['%10s' % l for l in labels], ' ')] 
    489488 
    490         fmt = "%10s " + join(["%10.3f"]*4, " ") + " %5s" 
     489        fmt = "%10s " + join(["%10.3f"] * 4, " ") + " %5s" 
    491490        if not self.p_vals: 
    492491            raise ValueError("Model does not contain model statistics.") 
    493492        def get_star(p): 
    494             if p < 0.001: return  "*"*3 
    495             elif p < 0.01: return "*"*2 
     493            if p < 0.001: return  "*" * 3 
     494            elif p < 0.01: return "*" * 2 
    496495            elif p < 0.05: return "*" 
    497496            elif p < 0.1: return  "." 
     
    500499        if self.intercept == True: 
    501500            stars =  get_star(self.p_vals[0]) 
    502             lines.append(fmt % ('Intercept', self.coefficients[0],  
    503                          self.std_error[0], self.t_scores[0], self.p_vals[0], stars)) 
     501            lines.append(fmt % ('Intercept', self.coefficients[0], 
     502                                self.std_error[0], self.t_scores[0], 
     503                                self.p_vals[0], stars)) 
    504504            for i in range(len(self.domain.attributes)): 
    505                 stars = get_star(self.p_vals[i+1]) 
     505                stars = get_star(self.p_vals[i + 1]) 
    506506                lines.append(fmt % (self.domain.attributes[i].name, 
    507                              self.coefficients[i+1], self.std_error[i+1], 
    508                              self.t_scores[i+1], self.p_vals[i+1], stars)) 
     507                             self.coefficients[i + 1], self.std_error[i + 1], 
     508                             self.t_scores[i + 1], self.p_vals[i + 1], stars)) 
    509509        else: 
    510510            for i in range(len(self.domain.attributes)): 
     
    518518    def __str__(self): 
    519519        return self.to_string() 
    520          
    521  
    522520 
    523521 
     
    537535    if RSS1 <= RSS2 or p2 <= p1 or n <= p2 or RSS2 <= 0: 
    538536        return 1.0 
    539     F = ((RSS1-RSS2)/(p2-p1))/(RSS2/(n-p2)) 
    540     return stats.fprob(int(p2-p1), int(n-p2), F) 
     537    F = ((RSS1 - RSS2) / (p2 - p1)) / (RSS2 / (n - p2)) 
     538    return stats.fprob(int(p2 - p1), int(n - p2), F) 
    541539 
    542540 
     
    618616    c = LinearRegressionLearner(table) 
    619617    print c 
     618 
  • Orange/regression/pls.py

    r10367 r10420  
    1010`Partial least squares 
    1111<http://en.wikipedia.org/wiki/Partial_least_squares_regression>`_ 
    12 regression is a statistical method which can be used to predict 
    13 multiple response variables simultaniously. Implementation is based on 
    14 `Scikit learn python implementation 
     12regression is a statistical method for simultaneous prediction of 
     13multiple response variables. Orange's implementation is 
     14based on `Scikit learn python implementation 
    1515<https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/pls.py>`_. 
    1616 
     
    3434 
    3535.. autofunction:: svd_xy 
    36  
    3736 
    3837======== 
     
    4039======== 
    4140 
    42 To predict values for the first two data instances 
    43 use the following code:  
     41The following code predicts the values of output variables for the 
     42first two instances in ``data``. 
     43 
    4444 
    4545.. literalinclude:: code/pls-example.py 
    4646    :lines: 16-20 
    4747 
    48 Output:: 
     48:: 
    4949 
    5050    Actual     [<orange.Value 'Y1'='0.490'>, <orange.Value 'Y2'='1.237'>, <orange.Value 'Y3'='1.808'>, <orange.Value 'Y4'='0.422'>] 
     
    5454    Predicted  [<orange.Value 'Y1'='0.058'>, <orange.Value 'Y2'='-0.706'>, <orange.Value 'Y3'='-1.420'>, <orange.Value 'Y4'='0.599'>] 
    5555 
    56 To see the coefficient of the model (in this case they are stored in a matrix) 
    57 print the model: 
     56To see the coefficient of the model, print the model: 
    5857 
    5958.. literalinclude:: code/pls-example.py 
    6059    :lines: 22 
    6160 
    62 The ouptut looks like this:: 
     61:: 
    6362 
    6463    Regression coefficients: 
     
    6867          X3        0.230       -0.314       -0.880       -0.060  
    6968 
    70  
     69Note that coefficients are stored in a matrix since the model predicts 
     70values of multiple outputs. 
    7171""" 
    7272 
     
    8383 
    8484def normalize_matrix(X): 
    85     """ Normalizes matrix, i.e. subtracts column means 
    86     and divides them by column standard deviations. 
    87     Returns the standardized matrix, sample mean and 
    88     standard deviation 
     85    """ 
     86    Normalize a matrix column-wise: subtract the means and divide by 
     87    standard deviations. Returns the standardized matrix, sample mean 
     88    and standard deviation 
    8989 
    9090    :param X: data matrix 
     
    9999def nipals_xy(X, Y, mode="PLS", max_iter=500, tol=1e-06): 
    100100    """ 
    101     NIPALS algorithm. Returns the first left and rigth singular 
     101    NIPALS algorithm; returns the first left and rigth singular 
    102102    vectors of X'Y. 
    103103 
     
    108108    :type mode: string 
    109109 
    110     :param max_iter: maximal number of iterations (default 500) 
     110    :param max_iter: maximal number of iterations (default: 500) 
    111111    :type max_iter: int 
    112112 
    113     :param tol: tolerance parameter, if norm of difference 
     113    :param tol: tolerance parameter; if norm of difference 
    114114        between two successive left singular vectors is less than tol, 
    115115        iteration is stopped 
     
    155155 
    156156def svd_xy(X, Y): 
    157     """ Returns the first left and right singular 
     157    """ Return the first left and right singular 
    158158    vectors of X'Y. 
    159159 
     
    169169 
    170170def select_attrs(table, attributes, class_var=None, metas=None): 
    171     """ Select only ``attributes`` from the ``table``. 
     171    """ Select ``attributes`` from the ``table`` and return a new data table. 
    172172    """ 
    173173    domain = Orange.data.Domain(attributes, class_var) 
     
    178178 
    179179class PLSRegressionLearner(base.BaseRegressionLearner): 
    180     """ Fits the partial least squares regression model, 
    181     i.e. learns the regression parameters. The implementation is based on 
    182     `Scikit learn python implementation`_ 
     180    """ 
     181    Fit the partial least squares regression model, i.e. learn the 
     182    regression parameters. The implementation is based on `Scikit 
     183    learn python implementation`_ 
    183184     
    184185    The class is derived from 
    185     :class:`Orange.regression.base.BaseRegressionLearner` 
    186     which is used for preprocessing the data (continuization and imputation) 
     186    :class:`Orange.regression.base.BaseRegressionLearner` that is 
     187    used for preprocessing the data (continuization and imputation) 
    187188    before fitting the regression parameters 
    188189     
     
    196197        .. attribute:: n_comp 
    197198     
    198             number of components to keep. Default: 2 
     199            number of components to keep (default: 2) 
    199200 
    200201        .. attribute:: deflation_mode 
     
    209210        .. attribute:: algorithm 
    210211     
    211             The algorithm used to estimate the weights: 
     212            The algorithm for estimating the weights: 
    212213            "nipals" or "svd" (default) 
    213214 
     
    231232        :param x_vars, y_vars: List of input and response variables 
    232233            (:obj:`Orange.feature.Continuous` or 
    233             :obj:`Orange.feature.Discrete`). If None (default) it is 
     234            :obj:`Orange.feature.Discrete`). If ``None`` (default) it is 
    234235            assumed that the data domain provides information which variables 
    235236            are reponses and which are not. If data has 
     
    281282 
    282283    def fit(self, X, Y): 
    283         """ Fits all unknown parameters, i.e. 
     284        """ Fit all unknown parameters, i.e. 
    284285        weights, scores, loadings (for x and y) and regression coefficients. 
    285         Returns a dict with all of the parameters. 
    286          
     286        Return a dict with all of the parameters. 
    287287        """ 
    288288        # copy since this will contain the residuals (deflated) matrices 
     
    365365 
    366366class PLSRegression(Orange.classification.Classifier): 
    367     """ PLSRegression predicts value of the response variables 
     367    """ Predict values of the response variables 
    368368    based on the values of independent variables. 
    369369     
  • Orange/testing/regression/results_reference/linear-example.py.txt

    r9954 r10431  
    55Actual: 36.20, predicted: 27.94  
    66  Variable  Coeff Est  Std Error    t-value          p 
    7  Intercept     36.459      5.103      7.144      0.000   *** 
    8       CRIM     -0.108      0.033     -3.287      0.001    ** 
    9         ZN      0.046      0.014      3.382      0.001   *** 
    10      INDUS      0.021      0.061      0.334      0.738       
    11       CHAS      2.687      0.862      3.118      0.002    ** 
    12        NOX    -17.767      3.820     -4.651      0.000   *** 
    13         RM      3.810      0.418      9.116      0.000   *** 
     7 Intercept     36.459      5.109      7.137      0.000   *** 
     8      CRIM     -0.108      0.033     -3.283      0.001    ** 
     9        ZN      0.046      0.014      3.378      0.001   *** 
     10     INDUS      0.021      0.062      0.334      0.739       
     11      CHAS      2.687      0.862      3.115      0.002    ** 
     12       NOX    -17.767      3.824     -4.647      0.000   *** 
     13        RM      3.810      0.418      9.107      0.000   *** 
    1414       AGE      0.001      0.013      0.052      0.958       
    15        DIS     -1.476      0.199     -7.398      0.000   *** 
    16        RAD      0.306      0.066      4.613      0.000   *** 
    17        TAX     -0.012      0.004     -3.280      0.001    ** 
    18    PTRATIO     -0.953      0.131     -7.283      0.000   *** 
    19          B      0.009      0.003      3.467      0.001   *** 
    20      LSTAT     -0.525      0.051    -10.347      0.000   *** 
     15       DIS     -1.476      0.200     -7.390      0.000   *** 
     16       RAD      0.306      0.066      4.608      0.000   *** 
     17       TAX     -0.012      0.004     -3.277      0.001    ** 
     18   PTRATIO     -0.953      0.131     -7.275      0.000   *** 
     19         B      0.009      0.003      3.463      0.001   *** 
     20     LSTAT     -0.525      0.051    -10.337      0.000   *** 
    2121Signif. codes:  0 *** 0.001 ** 0.01 * 0.05 . 0.1 empty 1 
    2222  Variable  Coeff Est  Std Error    t-value          p 
    23  Intercept     36.341      5.067      7.171      0.000   *** 
    24      LSTAT     -0.523      0.047    -11.019      0.000   *** 
    25         RM      3.802      0.406      9.356      0.000   *** 
    26    PTRATIO     -0.947      0.129     -7.334      0.000   *** 
    27        DIS     -1.493      0.186     -8.037      0.000   *** 
    28        NOX    -17.376      3.535     -4.915      0.000   *** 
    29       CHAS      2.719      0.854      3.183      0.002    ** 
    30          B      0.009      0.003      3.475      0.001   *** 
    31         ZN      0.046      0.014      3.390      0.001   *** 
    32       CRIM     -0.108      0.033     -3.307      0.001    ** 
    33        RAD      0.300      0.063      4.726      0.000   *** 
    34        TAX     -0.012      0.003     -3.493      0.001   *** 
     23 Intercept     36.341      5.073      7.164      0.000   *** 
     24     LSTAT     -0.523      0.047    -11.008      0.000   *** 
     25        RM      3.802      0.407      9.347      0.000   *** 
     26   PTRATIO     -0.947      0.129     -7.326      0.000   *** 
     27       DIS     -1.493      0.186     -8.029      0.000   *** 
     28       NOX    -17.376      3.539     -4.910      0.000   *** 
     29      CHAS      2.719      0.855      3.179      0.002    ** 
     30         B      0.009      0.003      3.471      0.001   *** 
     31        ZN      0.046      0.014      3.387      0.001   *** 
     32      CRIM     -0.108      0.033     -3.304      0.001    ** 
     33       RAD      0.300      0.063      4.721      0.000   *** 
     34       TAX     -0.012      0.003     -3.489      0.001   *** 
    3535Signif. codes:  0 *** 0.001 ** 0.01 * 0.05 . 0.1 empty 1 
  • Orange/testing/regression/results_reference/som-classifier.py.txt

    r9954 r10464  
    33Iris-versicolor originally Iris-versicolor 
    44Iris-setosa     originally Iris-setosa     
    5 Iris-versicolor originally Iris-versicolor 
     5Iris-virginica originally Iris-versicolor 
  • Orange/testing/regression/results_reference/som-mapping.py.txt

    r9954 r10464  
    11Node    Instances 
    2 (0, 0)  21 
    3 (0, 1)  1 
    4 (0, 2)  23 
    5 (1, 0)  22 
     2(0, 0)  31 
     3(0, 1)  7 
     4(0, 2)  0 
     5(1, 0)  24 
    66(1, 1)  7 
    7 (1, 2)  6 
    8 (2, 0)  32 
    9 (2, 1)  16 
    10 (2, 2)  22 
     7(1, 2)  50 
     8(2, 0)  10 
     9(2, 1)  21 
     10(2, 2)  0 
    1111 
    12 Data instances in cell (1, 2): 
    13 [4.9, 2.4, 3.3, 1.0, 'Iris-versicolor'] 
    14 [5.0, 2.0, 3.5, 1.0, 'Iris-versicolor'] 
    15 [5.6, 2.9, 3.6, 1.3, 'Iris-versicolor'] 
    16 [5.7, 2.6, 3.5, 1.0, 'Iris-versicolor'] 
    17 [5.5, 2.4, 3.7, 1.0, 'Iris-versicolor'] 
    18 [5.0, 2.3, 3.3, 1.0, 'Iris-versicolor'] 
     12Data instances in cell (0, 1): 
     13[6.9, 3.1, 4.9, 1.5, 'Iris-versicolor'] 
     14[6.7, 3.0, 5.0, 1.7, 'Iris-versicolor'] 
     15[6.3, 2.9, 5.6, 1.8, 'Iris-virginica'] 
     16[6.5, 3.2, 5.1, 2.0, 'Iris-virginica'] 
     17[6.4, 2.7, 5.3, 1.9, 'Iris-virginica'] 
     18[6.1, 2.6, 5.6, 1.4, 'Iris-virginica'] 
     19[6.5, 3.0, 5.2, 2.0, 'Iris-virginica'] 
  • Orange/testing/regression/results_reference/svm-easy.py.txt

    r10029 r10435  
    11Name     CA        AUC 
    2 svm easy 0.84      0.97 
    3 svm      0.79      0.96 
     2svm easy 0.83      0.96 
     3svm      0.76      0.95 
  • Orange/testing/regression/results_tests_20/modules_som1.py.txt

    r9951 r10464  
    11node: 0 0 
    2     [5.1, 3.5, 1.4, 0.3, 'Iris-setosa'] 
    3     [5.0, 3.5, 1.3, 0.3, 'Iris-setosa'] 
     2    [5.8, 4.0, 1.2, 0.2, 'Iris-setosa'] 
     3    [5.7, 4.4, 1.5, 0.4, 'Iris-setosa'] 
    44node: 0 1 
    5     [5.0, 3.6, 1.4, 0.2, 'Iris-setosa'] 
    65node: 0 2 
    7     [5.1, 3.7, 1.5, 0.4, 'Iris-setosa'] 
     6    [5.7, 3.8, 1.7, 0.3, 'Iris-setosa'] 
    87node: 0 3 
    9     [5.1, 3.8, 1.5, 0.3, 'Iris-setosa'] 
    10     [5.1, 3.8, 1.6, 0.2, 'Iris-setosa'] 
    118node: 0 4 
     9    [5.4, 3.4, 1.7, 0.2, 'Iris-setosa'] 
    1210node: 0 5 
    13     [5.2, 4.1, 1.5, 0.1, 'Iris-setosa'] 
    1411node: 0 6 
    15     [5.4, 3.9, 1.3, 0.4, 'Iris-setosa'] 
     12    [4.9, 2.5, 4.5, 1.7, 'Iris-virginica'] 
    1613node: 0 7 
    1714node: 0 8 
    18     [5.4, 3.7, 1.5, 0.2, 'Iris-setosa'] 
    19     [5.5, 3.5, 1.3, 0.2, 'Iris-setosa'] 
    20     [5.3, 3.7, 1.5, 0.2, 'Iris-setosa'] 
     15    [5.7, 2.8, 4.5, 1.3, 'Iris-versicolor'] 
    2116node: 0 9 
    2217node: 0 10 
    23     [5.1, 3.5, 1.4, 0.2, 'Iris-setosa'] 
    24     [5.2, 3.5, 1.5, 0.2, 'Iris-setosa'] 
    25     [5.2, 3.4, 1.4, 0.2, 'Iris-setosa'] 
     18    [5.4, 3.0, 4.5, 1.5, 'Iris-versicolor'] 
    2619node: 0 11 
    2720node: 0 12 
    28     [5.1, 3.4, 1.5, 0.2, 'Iris-setosa'] 
     21    [6.0, 3.4, 4.5, 1.6, 'Iris-versicolor'] 
    2922node: 0 13 
    30     [5.0, 3.4, 1.5, 0.2, 'Iris-setosa'] 
     23    [5.9, 3.2, 4.8, 1.8, 'Iris-versicolor'] 
    3124node: 0 14 
    32     [5.0, 3.3, 1.4, 0.2, 'Iris-setosa'] 
     25    [5.9, 3.0, 5.1, 1.8, 'Iris-virginica'] 
    3326node: 0 15 
    34     [5.0, 3.2, 1.2, 0.2, 'Iris-setosa'] 
     27    [5.8, 2.7, 5.1, 1.9, 'Iris-virginica'] 
     28    [5.8, 2.7, 5.1, 1.9, 'Iris-virginica'] 
    3529node: 0 16 
    36     [4.7, 3.2, 1.3, 0.2, 'Iris-setosa'] 
    3730node: 0 17 
    38     [4.4, 3.2, 1.3, 0.2, 'Iris-setosa'] 
    39     [4.6, 3.2, 1.4, 0.2, 'Iris-setosa'] 
     31    [5.8, 2.8, 5.1, 2.4, 'Iris-virginica'] 
    4032node: 0 18 
    41     [4.6, 3.4, 1.4, 0.3, 'Iris-setosa'] 
     33    [6.2, 3.4, 5.4, 2.3, 'Iris-virginica'] 
    4234node: 0 19 
    43     [4.6, 3.6, 1.0, 0.2, 'Iris-setosa'] 
     35    [6.3, 3.4, 5.6, 2.4, 'Iris-virginica'] 
    4436node: 1 0 
    45     [5.0, 3.4, 1.6, 0.4, 'Iris-setosa'] 
     37    [5.4, 3.9, 1.3, 0.4, 'Iris-setosa'] 
     38    [5.5, 4.2, 1.4, 0.2, 'Iris-setosa'] 
    4639node: 1 1 
    47     [5.1, 3.3, 1.7, 0.5, 'Iris-setosa'] 
    48     [5.0, 3.5, 1.6, 0.6, 'Iris-setosa'] 
     40    [5.4, 3.9, 1.7, 0.4, 'Iris-setosa'] 
    4941node: 1 2 
    5042node: 1 3 
    5143node: 1 4 
    52     [5.4, 3.9, 1.7, 0.4, 'Iris-setosa'] 
     44    [5.4, 3.4, 1.5, 0.4, 'Iris-setosa'] 
     45node: 1 5 
     46node: 1 6 
     47node: 1 7 
     48    [5.5, 2.6, 4.4, 1.2, 'Iris-versicolor'] 
     49node: 1 8 
     50node: 1 9 
     51    [5.6, 3.0, 4.5, 1.5, 'Iris-versicolor'] 
     52node: 1 10 
     53node: 1 11 
     54    [6.1, 3.0, 4.6, 1.4, 'Iris-versicolor'] 
     55node: 1 12 
     56node: 1 13 
     57    [6.1, 3.0, 4.9, 1.8, 'Iris-virginica'] 
     58    [6.0, 3.0, 4.8, 1.8, 'Iris-virginica'] 
     59node: 1 14 
     60node: 1 15 
     61    [5.7, 2.5, 5.0, 2.0, 'Iris-virginica'] 
     62node: 1 16 
     63node: 1 17 
     64node: 1 18 
     65node: 1 19 
     66    [6.3, 3.3, 6.0, 2.5, 'Iris-virginica'] 
     67node: 2 0 
     68    [5.2, 4.1, 1.5, 0.1, 'Iris-setosa'] 
     69node: 2 1 
     70node: 2 2 
    5371    [5.1, 3.8, 1.9, 0.4, 'Iris-setosa'] 
    54 node: 1 5 
    55     [5.5, 4.2, 1.4, 0.2, 'Iris-setosa'] 
    56 node: 1 6 
    57     [5.8, 4.0, 1.2, 0.2, 'Iris-setosa'] 
    58     [5.7, 4.4, 1.5, 0.4, 'Iris-setosa'] 
    59 node: 1 7 
    60 node: 1 8 
    61     [5.7, 3.8, 1.7, 0.3, 'Iris-setosa'] 
    62 node: 1 9 
    63 node: 1 10 
    64     [5.4, 3.4, 1.7, 0.2, 'Iris-setosa'] 
    65     [5.4, 3.4, 1.5, 0.4, 'Iris-setosa'] 
    66 node: 1 11 
    67 node: 1 12 
     72node: 2 3 
     73    [5.4, 3.7, 1.5, 0.2, 'Iris-setosa'] 
     74    [5.3, 3.7, 1.5, 0.2, 'Iris-setosa'] 
     75node: 2 4 
     76    [5.5, 3.5, 1.3, 0.2, 'Iris-setosa'] 
     77node: 2 5 
     78node: 2 6 
     79    [5.2, 2.7, 3.9, 1.4, 'Iris-versicolor'] 
     80node: 2 7 
     81node: 2 8 
     82    [5.6, 2.7, 4.2, 1.3, 'Iris-versicolor'] 
     83node: 2 9 
     84node: 2 10 
     85    [6.0, 2.9, 4.5, 1.5, 'Iris-versicolor'] 
     86node: 2 11 
     87node: 2 12 
     88    [6.1, 2.9, 4.7, 1.4, 'Iris-versicolor'] 
     89    [6.1, 2.8, 4.7, 1.2, 'Iris-versicolor'] 
     90node: 2 13 
     91node: 2 14 
     92    [6.2, 2.8, 4.8, 1.8, 'Iris-virginica'] 
     93node: 2 15 
     94node: 2 16 
     95    [5.6, 2.8, 4.9, 2.0, 'Iris-virginica'] 
     96node: 2 17 
     97node: 2 18 
     98    [6.4, 2.8, 5.6, 2.1, 'Iris-virginica'] 
     99    [6.4, 2.8, 5.6, 2.2, 'Iris-virginica'] 
     100node: 2 19 
     101    [6.5, 3.0, 5.8, 2.2, 'Iris-virginica'] 
     102node: 3 0 
     103    [5.1, 3.8, 1.5, 0.3, 'Iris-setosa'] 
     104    [5.1, 3.8, 1.6, 0.2, 'Iris-setosa'] 
     105node: 3 1 
     106node: 3 2 
     107    [5.2, 3.5, 1.5, 0.2, 'Iris-setosa'] 
     108    [5.2, 3.4, 1.4, 0.2, 'Iris-setosa'] 
     109node: 3 3 
     110node: 3 4 
     111    [5.1, 3.3, 1.7, 0.5, 'Iris-setosa'] 
     112    [5.0, 3.5, 1.6, 0.6, 'Iris-setosa'] 
     113node: 3 5 
     114node: 3 6 
     115    [5.5, 2.5, 4.0, 1.3, 'Iris-versicolor'] 
     116node: 3 7 
     117    [5.7, 2.8, 4.1, 1.3, 'Iris-versicolor'] 
     118node: 3 8 
     119    [5.6, 3.0, 4.1, 1.3, 'Iris-versicolor'] 
     120    [5.7, 3.0, 4.2, 1.2, 'Iris-versicolor'] 
     121    [5.7, 2.9, 4.2, 1.3, 'Iris-versicolor'] 
     122node: 3 9 
     123    [5.9, 3.0, 4.2, 1.5, 'Iris-versicolor'] 
     124node: 3 10 
     125    [6.2, 2.9, 4.3, 1.3, 'Iris-versicolor'] 
     126node: 3 11 
     127    [6.7, 3.1, 4.4, 1.4, 'Iris-versicolor'] 
     128node: 3 12 
     129    [6.4, 3.2, 4.5, 1.5, 'Iris-versicolor'] 
     130node: 3 13 
     131    [6.3, 3.3, 4.7, 1.6, 'Iris-versicolor'] 
     132node: 3 14 
     133node: 3 15 
     134    [6.5, 3.2, 5.1, 2.0, 'Iris-virginica'] 
     135    [6.5, 3.0, 5.2, 2.0, 'Iris-virginica'] 
     136node: 3 16 
     137    [6.4, 3.2, 5.3, 2.3, 'Iris-virginica'] 
     138node: 3 17 
     139node: 3 18 
     140    [6.7, 3.1, 5.6, 2.4, 'Iris-virginica'] 
     141node: 3 19 
     142    [6.7, 3.3, 5.7, 2.5, 'Iris-virginica'] 
     143node: 4 0 
     144    [5.1, 3.7, 1.5, 0.4, 'Iris-setosa'] 
     145node: 4 1 
     146    [5.0, 3.6, 1.4, 0.2, 'Iris-setosa'] 
     147node: 4 2 
     148    [5.1, 3.5, 1.4, 0.2, 'Iris-setosa'] 
     149node: 4 3 
     150    [5.1, 3.4, 1.5, 0.2, 'Iris-setosa'] 
     151node: 4 4 
     152    [5.0, 3.4, 1.6, 0.4, 'Iris-setosa'] 
     153node: 4 5 
     154node: 4 6 
     155    [5.5, 2.3, 4.0, 1.3, 'Iris-versicolor'] 
     156node: 4 7 
     157node: 4 8 
     158node: 4 9 
     159node: 4 10 
     160node: 4 11 
     161node: 4 12 
     162    [6.6, 3.0, 4.4, 1.4, 'Iris-versicolor'] 
     163node: 4 13 
     164node: 4 14 
     165    [6.7, 3.1, 4.7, 1.5, 'Iris-versicolor'] 
     166node: 4 15 
     167    [6.7, 3.0, 5.0, 1.7, 'Iris-versicolor'] 
     168node: 4 16 
     169node: 4 17 
     170    [6.7, 3.0, 5.2, 2.3, 'Iris-virginica'] 
     171node: 4 18 
     172node: 4 19 
     173node: 5 0 
     174node: 5 1 
     175    [5.1, 3.5, 1.4, 0.3, 'Iris-setosa'] 
     176    [5.0, 3.5, 1.3, 0.3, 'Iris-setosa'] 
     177node: 5 2 
     178node: 5 3 
     179    [5.0, 3.4, 1.5, 0.2, 'Iris-setosa'] 
     180node: 5 4 
    68181    [4.8, 3.4, 1.6, 0.2, 'Iris-setosa'] 
     182node: 5 5 
     183node: 5 6 
     184node: 5 7 
     185    [5.6, 2.9, 3.6, 1.3, 'Iris-versicolor'] 
     186node: 5 8 
     187    [5.8, 2.7, 3.9, 1.2, 'Iris-versicolor'] 
     188node: 5 9 
     189    [6.1, 2.8, 4.0, 1.3, 'Iris-versicolor'] 
     190node: 5 10 
     191    [6.4, 2.9, 4.3, 1.3, 'Iris-versicolor'] 
     192node: 5 11 
     193    [6.5, 2.8, 4.6, 1.5, 'Iris-versicolor'] 
     194node: 5 12 
     195    [6.6, 2.9, 4.6, 1.3, 'Iris-versicolor'] 
     196node: 5 13 
     197    [6.8, 2.8, 4.8, 1.4, 'Iris-versicolor'] 
     198node: 5 14 
     199    [7.0, 3.2, 4.7, 1.4, 'Iris-versicolor'] 
     200    [6.9, 3.1, 4.9, 1.5, 'Iris-versicolor'] 
     201node: 5 15 
     202node: 5 16 
     203    [6.9, 3.1, 5.1, 2.3, 'Iris-virginica'] 
     204node: 5 17 
     205    [6.8, 3.0, 5.5, 2.1, 'Iris-virginica'] 
     206    [6.9, 3.1, 5.4, 2.1, 'Iris-virginica'] 
     207node: 5 18 
     208    [6.9, 3.2, 5.7, 2.3, 'Iris-virginica'] 
     209node: 5 19 
     210    [6.7, 3.3, 5.7, 2.1, 'Iris-virginica'] 
     211    [6.8, 3.2, 5.9, 2.3, 'Iris-virginica'] 
     212node: 6 0 
     213    [4.6, 3.6, 1.0, 0.2, 'Iris-setosa'] 
     214node: 6 1 
     215    [4.6, 3.4, 1.4, 0.3, 'Iris-setosa'] 
     216node: 6 2 
     217node: 6 3 
     218    [5.0, 3.2, 1.2, 0.2, 'Iris-setosa'] 
     219    [5.0, 3.3, 1.4, 0.2, 'Iris-setosa'] 
     220node: 6 4 
     221node: 6 5 
     222node: 6 6 
     223node: 6 7 
     224    [5.7, 2.6, 3.5, 1.0, 'Iris-versicolor'] 
     225    [5.5, 2.4, 3.7, 1.0, 'Iris-versicolor'] 
     226node: 6 8 
     227    [5.6, 2.5, 3.9, 1.1, 'Iris-versicolor'] 
     228node: 6 9 
     229    [5.8, 2.7, 4.1, 1.0, 'Iris-versicolor'] 
     230    [5.8, 2.6, 4.0, 1.2, 'Iris-versicolor'] 
     231node: 6 10 
     232node: 6 11 
     233node: 6 12 
     234node: 6 13 
     235    [6.0, 2.7, 5.1, 1.6, 'Iris-versicolor'] 
     236node: 6 14 
     237    [6.3, 2.8, 5.1, 1.5, 'Iris-virginica'] 
     238node: 6 15 
     239node: 6 16 
     240node: 6 17 
     241    [7.2, 3.2, 6.0, 1.8, 'Iris-virginica'] 
     242node: 6 18 
     243    [7.1, 3.0, 5.9, 2.1, 'Iris-virginica'] 
     244node: 6 19 
     245node: 7 0 
     246    [4.4, 3.2, 1.3, 0.2, 'Iris-setosa'] 
     247node: 7 1 
     248    [4.6, 3.1, 1.5, 0.2, 'Iris-setosa'] 
     249    [4.6, 3.2, 1.4, 0.2, 'Iris-setosa'] 
     250node: 7 2 
     251    [4.7, 3.2, 1.3, 0.2, 'Iris-setosa'] 
     252node: 7 3 
     253node: 7 4 
    69254    [4.8, 3.4, 1.9, 0.2, 'Iris-setosa'] 
    70 node: 1 13 
    71255    [4.7, 3.2, 1.6, 0.2, 'Iris-setosa'] 
    72 node: 1 14 
     256node: 7 5 
     257node: 7 6 
     258node: 7 7 
     259    [5.5, 2.4, 3.8, 1.1, 'Iris-versicolor'] 
     260node: 7 8 
     261node: 7 9 
     262node: 7 10 
     263    [6.0, 2.2, 5.0, 1.5, 'Iris-virginica'] 
     264node: 7 11 
     265    [6.3, 2.5, 4.9, 1.5, 'Iris-versicolor'] 
     266node: 7 12 
     267node: 7 13 
     268node: 7 14 
     269node: 7 15 
     270node: 7 16 
     271    [7.2, 3.0, 5.8, 1.6, 'Iris-virginica'] 
     272node: 7 17 
     273    [7.4, 2.8, 6.1, 1.9, 'Iris-virginica'] 
     274node: 7 18 
     275    [7.7, 3.0, 6.1, 2.3, 'Iris-virginica'] 
     276node: 7 19 
     277    [7.2, 3.6, 6.1, 2.5, 'Iris-virginica'] 
     278node: 8 0 
     279    [4.3, 3.0, 1.1, 0.1, 'Iris-setosa'] 
     280node: 8 1 
     281    [4.4, 2.9, 1.4, 0.2, 'Iris-setosa'] 
     282    [4.4, 3.0, 1.3, 0.2, 'Iris-setosa'] 
     283node: 8 2 
     284node: 8 3 
     285    [4.8, 3.0, 1.4, 0.1, 'Iris-setosa'] 
     286    [4.8, 3.0, 1.4, 0.3, 'Iris-setosa'] 
     287node: 8 4 
    73288    [4.8, 3.1, 1.6, 0.2, 'Iris-setosa'] 
    74 node: 1 15 
     289node: 8 5 
     290node: 8 6 
     291    [5.1, 2.5, 3.0, 1.1, 'Iris-versicolor'] 
     292node: 8 7 
     293node: 8 8 
     294node: 8 9 
     295    [6.0, 2.2, 4.0, 1.0, 'Iris-versicolor'] 
     296node: 8 10 
     297node: 8 11 
     298node: 8 12 
     299    [6.3, 2.7, 4.9, 1.8, 'Iris-virginica'] 
     300node: 8 13 
     301node: 8 14 
     302    [6.1, 2.6, 5.6, 1.4, 'Iris-virginica'] 
     303node: 8 15 
     304node: 8 16 
     305    [6.7, 2.5, 5.8, 1.8, 'Iris-virginica'] 
     306node: 8 17 
     307    [7.3, 2.9, 6.3, 1.8, 'Iris-virginica'] 
     308node: 8 18 
     309node: 8 19 
     310node: 9 0 
     311    [4.5, 2.3, 1.3, 0.3, 'Iris-setosa'] 
     312node: 9 1 
     313node: 9 2 
     314node: 9 3 
     315    [4.9, 3.0, 1.4, 0.2, 'Iris-setosa'] 
     316node: 9 4 
    75317    [4.9, 3.1, 1.5, 0.1, 'Iris-setosa'] 
    76318    [5.0, 3.0, 1.6, 0.2, 'Iris-setosa'] 
    77319    [4.9, 3.1, 1.5, 0.1, 'Iris-setosa'] 
    78320    [4.9, 3.1, 1.5, 0.1, 'Iris-setosa'] 
    79 node: 1 16 
    80     [4.9, 3.0, 1.4, 0.2, 'Iris-setosa'] 
    81     [4.8, 3.0, 1.4, 0.1, 'Iris-setosa'] 
    82 node: 1 17 
    83     [4.6, 3.1, 1.5, 0.2, 'Iris-setosa'] 
    84     [4.8, 3.0, 1.4, 0.3, 'Iris-setosa'] 
    85 node: 1 18 
    86     [4.4, 2.9, 1.4, 0.2, 'Iris-setosa'] 
    87 node: 1 19 
    88     [4.3, 3.0, 1.1, 0.1, 'Iris-setosa'] 
    89     [4.4, 3.0, 1.3, 0.2, 'Iris-setosa'] 
    90 node: 2 0 
    91     [5.7, 2.6, 3.5, 1.0, 'Iris-versicolor'] 
    92 node: 2 1 
    93 node: 2 2 
    94     [5.5, 2.4, 3.7, 1.0, 'Iris-versicolor'] 
    95 node: 2 3 
    96     [5.5, 2.4, 3.8, 1.1, 'Iris-versicolor'] 
    97 node: 2 4 
    98     [5.6, 2.5, 3.9, 1.1, 'Iris-versicolor'] 
    99 node: 2 5 
    100 node: 2 6 
    101     [5.1, 2.5, 3.0, 1.1, 'Iris-versicolor'] 
    102 node: 2 7 
    103 node: 2 8 
     321node: 9 5 
     322node: 9 6 
    104323    [4.9, 2.4, 3.3, 1.0, 'Iris-versicolor'] 
    105324    [5.0, 2.3, 3.3, 1.0, 'Iris-versicolor'] 
    106 node: 2 9 
    107 node: 2 10 
     325node: 9 7 
    108326    [5.0, 2.0, 3.5, 1.0, 'Iris-versicolor'] 
    109 node: 2 11 
    110 node: 2 12 
    111     [4.5, 2.3, 1.3, 0.3, 'Iris-setosa'] 
    112 node: 2 13 
    113 node: 2 14 
    114 node: 2 15 
    115 node: 2 16 
    116 node: 2 17 
    117 node: 2 18 
    118 node: 2 19 
    119 node: 3 0 
    120     [5.6, 2.9, 3.6, 1.3, 'Iris-versicolor'] 
    121 node: 3 1 
    122 node: 3 2 
    123     [5.6, 3.0, 4.1, 1.3, 'Iris-versicolor'] 
    124     [5.7, 3.0, 4.2, 1.2, 'Iris-versicolor'] 
    125 node: 3 3 
    126     [5.7, 2.9, 4.2, 1.3, 'Iris-versicolor'] 
    127     [5.7, 2.8, 4.1, 1.3, 'Iris-versicolor'] 
    128 node: 3 4 
    129 node: 3 5 
    130     [5.9, 3.0, 4.2, 1.5, 'Iris-versicolor'] 
    131 node: 3 6 
    132     [6.1, 2.8, 4.0, 1.3, 'Iris-versicolor'] 
    133 node: 3 7 
    134     [5.8, 2.7, 3.9, 1.2, 'Iris-versicolor'] 
    135 node: 3 8 
    136     [5.8, 2.7, 4.1, 1.0, 'Iris-versicolor'] 
    137     [5.8, 2.6, 4.0, 1.2, 'Iris-versicolor'] 
    138 node: 3 9 
    139 node: 3 10 
    140 node: 3 11 
    141     [5.5, 2.3, 4.0, 1.3, 'Iris-versicolor'] 
    142     [5.5, 2.5, 4.0, 1.3, 'Iris-versicolor'] 
    143 node: 3 12 
    144     [5.2, 2.7, 3.9, 1.4, 'Iris-versicolor'] 
    145 node: 3 13 
    146 node: 3 14 
    147 node: 3 15 
    148     [6.0, 2.2, 4.0, 1.0, 'Iris-versicolor'] 
    149 node: 3 16 
     327node: 9 8 
     328node: 9 9 
     329node: 9 10 
    150330    [6.2, 2.2, 4.5, 1.5, 'Iris-versicolor'] 
    151331    [6.3, 2.3, 4.4, 1.3, 'Iris-versicolor'] 
    152 node: 3 17 
    153 node: 3 18 
    154 node: 3 19 
     332node: 9 11 
     333node: 9 12 
     334    [6.3, 2.5, 5.0, 1.9, 'Iris-virginica'] 
     335node: 9 13 
     336    [6.4, 2.7, 5.3, 1.9, 'Iris-virginica'] 
     337node: 9 14 
     338    [6.3, 2.9, 5.6, 1.8, 'Iris-virginica'] 
     339node: 9 15 
     340    [6.5, 3.0, 5.5, 1.8, 'Iris-virginica'] 
     341    [6.4, 3.1, 5.5, 1.8, 'Iris-virginica'] 
     342node: 9 16 
     343node: 9 17 
     344    [7.6, 3.0, 6.6, 2.1, 'Iris-virginica'] 
    155345    [7.7, 2.6, 6.9, 2.3, 'Iris-virginica'] 
    156346    [7.7, 2.8, 6.7, 2.0, 'Iris-virginica'] 
    157 node: 4 0 
    158     [5.4, 3.0, 4.5, 1.5, 'Iris-versicolor'] 
    159 node: 4 1 
    160     [5.6, 3.0, 4.5, 1.5, 'Iris-versicolor'] 
    161 node: 4 2 
    162     [5.7, 2.8, 4.5, 1.3, 'Iris-versicolor'] 
    163 node: 4 3 
    164 node: 4 4 
    165     [6.0, 2.9, 4.5, 1.5, 'Iris-versicolor'] 
    166 node: 4 5 
    167     [6.1, 3.0, 4.6, 1.4, 'Iris-versicolor'] 
    168 node: 4 6 
    169     [6.1, 2.9, 4.7, 1.4, 'Iris-versicolor'] 
    170 node: 4 7 
    171     [6.1, 2.8, 4.7, 1.2, 'Iris-versicolor'] 
    172 node: 4 8 
    173     [5.6, 2.7, 4.2, 1.3, 'Iris-versicolor'] 
    174 node: 4 9 
    175 node: 4 10 
    176 node: 4 11 
    177     [5.5, 2.6, 4.4, 1.2, 'Iris-versicolor'] 
    178 node: 4 12 
    179     [6.0, 2.2, 5.0, 1.5, 'Iris-virginica'] 
    180 node: 4 13 
    181 node: 4 14 
    182 node: 4 15 
    183     [6.3, 2.5, 4.9, 1.5, 'Iris-versicolor'] 
    184 node: 4 16 
    185 node: 4 17 
    186     [6.7, 2.5, 5.8, 1.8, 'Iris-virginica'] 
    187 node: 4 18 
    188 node: 4 19 
    189 node: 5 0 
    190     [4.9, 2.5, 4.5, 1.7, 'Iris-virginica'] 
    191 node: 5 1 
    192 node: 5 2 
    193     [5.9, 3.0, 5.1, 1.8, 'Iris-virginica'] 
    194 node: 5 3 
    195 node: 5 4 
    196     [5.9, 3.2, 4.8, 1.8, 'Iris-versicolor'] 
    197 node: 5 5 
    198     [6.0, 3.0, 4.8, 1.8, 'Iris-virginica'] 
    199 node: 5 6 
    200     [6.1, 3.0, 4.9, 1.8, 'Iris-virginica'] 
    201 node: 5 7 
    202     [6.2, 2.8, 4.8, 1.8, 'Iris-virginica'] 
    203 node: 5 8 
    204     [6.3, 2.7, 4.9, 1.8, 'Iris-virginica'] 
    205 node: 5 9 
    206     [6.3, 2.5, 5.0, 1.9, 'Iris-virginica'] 
    207 node: 5 10 
    208 node: 5 11 
    209     [6.0, 2.7, 5.1, 1.6, 'Iris-versicolor'] 
    210 node: 5 12 
    211 node: 5 13 
    212     [6.1, 2.6, 5.6, 1.4, 'Iris-virginica'] 
    213 node: 5 14 
    214 node: 5 15 
    215     [7.4, 2.8, 6.1, 1.9, 'Iris-virginica'] 
    216 node: 5 16 
    217 node: 5 17 
    218     [7.3, 2.9, 6.3, 1.8, 'Iris-virginica'] 
    219 node: 5 18 
    220 node: 5 19 
    221     [7.6, 3.0, 6.6, 2.1, 'Iris-virginica'] 
    222 node: 6 0 
    223     [5.6, 2.8, 4.9, 2.0, 'Iris-virginica'] 
    224 node: 6 1 
    225 node: 6 2 
    226     [5.7, 2.5, 5.0, 2.0, 'Iris-virginica'] 
    227 node: 6 3 
    228 node: 6 4 
    229     [5.8, 2.7, 5.1, 1.9, 'Iris-virginica'] 
    230     [5.8, 2.7, 5.1, 1.9, 'Iris-virginica'] 
    231 node: 6 5 
    232 node: 6 6 
    233     [6.4, 2.7, 5.3, 1.9, 'Iris-virginica'] 
    234 node: 6 7 
    235 node: 6 8 
    236     [6.3, 2.8, 5.1, 1.5, 'Iris-virginica'] 
    237 node: 6 9 
    238 node: 6 10 
    239     [7.2, 3.0, 5.8, 1.6, 'Iris-virginica'] 
    240 node: 6 11 
    241 node: 6 12 
    242     [7.2, 3.2, 6.0, 1.8, 'Iris-virginica'] 
    243 node: 6 13 
    244 node: 6 14 
    245     [7.1, 3.0, 5.9, 2.1, 'Iris-virginica'] 
    246 node: 6 15 
    247 node: 6 16 
    248     [7.7, 3.0, 6.1, 2.3, 'Iris-virginica'] 
    249 node: 6 17 
    250 node: 6 18 
    251 node: 6 19 
    252 node: 7 0 
    253     [5.8, 2.8, 5.1, 2.4, 'Iris-virginica'] 
    254 node: 7 1 
    255 node: 7 2 
    256     [6.8, 3.0, 5.5, 2.1, 'Iris-virginica'] 
    257     [6.9, 3.1, 5.4, 2.1, 'Iris-virginica'] 
    258 node: 7 3 
    259 node: 7 4 
    260     [6.9, 3.1, 5.1, 2.3, 'Iris-virginica'] 
    261 node: 7 5 
    262 node: 7 6 
    263     [6.7, 3.0, 5.2, 2.3, 'Iris-virginica'] 
    264 node: 7 7 
    265 node: 7 8 
    266     [6.5, 3.0, 5.2, 2.0, 'Iris-virginica'] 
    267 node: 7 9 
    268 node: 7 10 
    269     [6.5, 3.2, 5.1, 2.0, 'Iris-virginica'] 
    270 node: 7 11 
    271 node: 7 12 
    272     [6.7, 3.0, 5.0, 1.7, 'Iris-versicolor'] 
    273 node: 7 13 
    274 node: 7 14 
    275     [6.8, 2.8, 4.8, 1.4, 'Iris-versicolor'] 
    276 node: 7 15 
    277 node: 7 16 
    278     [7.2, 3.6, 6.1, 2.5, 'Iris-virginica'] 
    279 node: 7 17 
    280 node: 7 18 
     347node: 9 18 
     348node: 9 19 
     349    [7.7, 3.8, 6.7, 2.2, 'Iris-virginica'] 
    281350    [7.9, 3.8, 6.4, 2.0, 'Iris-virginica'] 
    282 node: 7 19 
    283     [7.7, 3.8, 6.7, 2.2, 'Iris-virginica'] 
    284 node: 8 0 
    285     [6.3, 2.9, 5.6, 1.8, 'Iris-virginica'] 
    286 node: 8 1 
    287     [6.4, 2.8, 5.6, 2.1, 'Iris-virginica'] 
    288 node: 8 2 
    289     [6.4, 2.8, 5.6, 2.2, 'Iris-virginica'] 
    290 node: 8 3 
    291     [6.5, 3.0, 5.8, 2.2, 'Iris-virginica'] 
    292 node: 8 4 
    293 node: 8 5 
    294     [6.9, 3.2, 5.7, 2.3, 'Iris-virginica'] 
    295 node: 8 6 
    296 node: 8 7 
    297     [6.7, 3.1, 5.6, 2.4, 'Iris-virginica'] 
    298     [6.7, 3.3, 5.7, 2.5, 'Iris-virginica'] 
    299 node: 8 8 
    300 node: 8 9 
    301     [6.4, 3.2, 5.3, 2.3, 'Iris-virginica'] 
    302 node: 8 10 
    303 node: 8 11 
    304     [6.7, 3.1, 4.7, 1.5, 'Iris-versicolor'] 
    305 node: 8 12 
    306 node: 8 13 
    307     [6.9, 3.1, 4.9, 1.5, 'Iris-versicolor'] 
    308 node: 8 14 
    309 node: 8 15 
    310     [7.0, 3.2, 4.7, 1.4, 'Iris-versicolor'] 
    311 node: 8 16 
    312 node: 8 17 
    313     [6.6, 2.9, 4.6, 1.3, 'Iris-versicolor'] 
    314 node: 8 18 
    315 node: 8 19 
    316     [6.5, 2.8, 4.6, 1.5, 'Iris-versicolor'] 
    317 node: 9 0 
    318     [6.5, 3.0, 5.5, 1.8, 'Iris-virginica'] 
    319     [6.4, 3.1, 5.5, 1.8, 'Iris-virginica'] 
    320 node: 9 1 
    321 node: 9 2 
    322     [6.7, 3.3, 5.7, 2.1, 'Iris-virginica'] 
    323 node: 9 3 
    324 node: 9 4 
    325     [6.8, 3.2, 5.9, 2.3, 'Iris-virginica'] 
    326 node: 9 5 
    327 node: 9 6 
    328     [6.3, 3.3, 6.0, 2.5, 'Iris-virginica'] 
    329 node: 9 7 
    330 node: 9 8 
    331     [6.3, 3.4, 5.6, 2.4, 'Iris-virginica'] 
    332 node: 9 9 
    333     [6.2, 3.4, 5.4, 2.3, 'Iris-virginica'] 
    334 node: 9 10 
    335 node: 9 11 
    336 node: 9 12 
    337     [6.0, 3.4, 4.5, 1.6, 'Iris-versicolor'] 
    338 node: 9 13 
    339     [6.3, 3.3, 4.7, 1.6, 'Iris-versicolor'] 
    340 node: 9 14 
    341     [6.4, 3.2, 4.5, 1.5, 'Iris-versicolor'] 
    342 node: 9 15 
    343 node: 9 16 
    344     [6.2, 2.9, 4.3, 1.3, 'Iris-versicolor'] 
    345 node: 9 17 
    346     [6.4, 2.9, 4.3, 1.3, 'Iris-versicolor'] 
    347 node: 9 18 
    348     [6.6, 3.0, 4.4, 1.4, 'Iris-versicolor'] 
    349 node: 9 19 
    350     [6.7, 3.1, 4.4, 1.4, 'Iris-versicolor'] 
  • Orange/testing/unit/tests/test_evaluation_scoring.py

    r10293 r10429  
    4545        ds = data.Table("iris") 
    4646        test_results = testing.cross_validation([self.learner], ds, folds=5) 
    47         auc = scoring.AUC.by_pairs(test_results) 
     47        auc = scoring.AUC(test_results, multiclass=scoring.AUC.ByPairs) 
    4848 
    4949        self.assertEqual(len(auc), 1) 
     
    5252        ds = data.Table("iris") 
    5353        test_results = testing.cross_validation([self.learner], ds, folds=5) 
    54         auc = scoring.AUC.by_weighted_pairs(test_results) 
     54        auc = scoring.AUC(test_results, multiclass=scoring.AUC.ByWeightedPairs) 
    5555 
    5656        self.assertEqual(len(auc), 1) 
     
    5959        ds = data.Table("iris") 
    6060        test_results = testing.cross_validation([self.learner], ds, folds=5) 
    61         auc = scoring.AUC.one_against_all(test_results) 
     61        auc = scoring.AUC(test_results, multiclass=scoring.AUC.OneAgainstAll) 
    6262 
    6363        self.assertEqual(len(auc), 1) 
     
    6666        ds = data.Table("iris") 
    6767        test_results = testing.cross_validation([self.learner], ds, folds=5) 
    68         auc = scoring.AUC.weighted_one_against_all(test_results) 
     68        auc = scoring.AUC(test_results, multiclass=scoring.AUC.WeightedOneAgainstAll) 
    6969 
    7070        self.assertEqual(len(auc), 1) 
     
    7373        ds = data.Table("iris") 
    7474        test_results = testing.cross_validation([self.learner], ds, folds=5) 
    75         auc = scoring.AUC.single_class(test_results) 
    76         self.assertEqual(len(auc), 1) 
    77         auc = scoring.AUC.single_class(test_results, 0) 
    78         self.assertEqual(len(auc), 1) 
    79         auc = scoring.AUC.single_class(test_results, 1) 
    80         self.assertEqual(len(auc), 1) 
    81         auc = scoring.AUC.single_class(test_results, 2) 
     75        auc = scoring.AUC_for_single_class(test_results) 
     76        self.assertEqual(len(auc), 1) 
     77        auc = scoring.AUC_for_single_class(test_results, 0) 
     78        self.assertEqual(len(auc), 1) 
     79        auc = scoring.AUC_for_single_class(test_results, 1) 
     80        self.assertEqual(len(auc), 1) 
     81        auc = scoring.AUC_for_single_class(test_results, 2) 
    8282        self.assertEqual(len(auc), 1) 
    8383 
     
    8585        ds = data.Table("iris") 
    8686        test_results = testing.cross_validation([self.learner], ds, folds=5) 
    87         auc = scoring.AUC.pair(test_results, 0, 1) 
    88         self.assertEqual(len(auc), 1) 
    89         auc = scoring.AUC.pair(test_results, 0, 2) 
    90         self.assertEqual(len(auc), 1) 
    91         auc = scoring.AUC.pair(test_results, 1, 2) 
     87        auc = scoring.AUC_for_pair_of_classes(test_results, 0, 1) 
     88        self.assertEqual(len(auc), 1) 
     89        auc = scoring.AUC_for_pair_of_classes(test_results, 0, 2) 
     90        self.assertEqual(len(auc), 1) 
     91        auc = scoring.AUC_for_pair_of_classes(test_results, 1, 2) 
    9292        self.assertEqual(len(auc), 1) 
    9393 
     
    9595        ds = data.Table("iris") 
    9696        test_results = testing.cross_validation([self.learner], ds, folds=5) 
    97         auc = scoring.AUC.matrix(test_results) 
     97        auc = scoring.AUC_matrix(test_results) 
    9898        self.assertEqual(len(auc), 1) 
    9999        self.assertEqual(len(auc[0]), 3) 
     
    170170        self.assertTrue(hasattr(cm[0], "TP")) 
    171171 
    172  
    173 class TestConfusionMatrix(unittest.TestCase): 
    174     def test_construct_confusion_matrix_from_multiclass(self): 
    175         learner = random_learner 
    176         ds = data.Table("iris") 
    177         pt = testing.proportion_test([learner], ds, times=1) 
    178         cm = scoring.confusion_matrices(pt) 
    179  
    180         self.assertTrue(isinstance(cm[0], list)) 
    181  
    182  
    183     def test_construct_confusion_matrix_from_biclass(self): 
    184         learner = random_learner 
    185         ds = data.Table("monks-1") 
    186         pt = testing.proportion_test([learner], ds, times=1) 
    187         cm = scoring.confusion_matrices(pt, class_index=1) 
    188  
    189         self.assertTrue(hasattr(cm[0], "TP")) 
     172class CMScoreTest(object): 
     173    def test_with_test_results_on_biclass(self): 
     174        learner = random_learner 
     175        ds = data.Table("monks-1") 
     176        pt = testing.proportion_test([learner], ds, times=1) 
     177        scores = self.score(pt) 
     178        self.assertIsInstance(scores, list) 
     179 
     180    def test_with_test_results_on_multiclass(self): 
     181        learner = random_learner 
     182        ds = data.Table("iris") 
     183        pt = testing.proportion_test([learner], ds, times=1) 
     184 
     185        scores = self.score(pt) 
     186        self.assertIsInstance(scores, list) 
     187 
     188    def test_with_confusion_matrices_on_biclass(self): 
     189        learner = random_learner 
     190        ds = data.Table("monks-1") 
     191        pt = testing.proportion_test([learner], ds, times=1) 
     192        cm = scoring.confusion_matrices(pt, class_index=1) 
     193        scores = self.score(cm) 
     194        self.assertIsInstance(scores, list) 
     195 
     196    def test_with_confusion_matrices_on_multiclass(self): 
     197        learner = random_learner 
     198        ds = data.Table("iris") 
     199        pt = testing.proportion_test([learner], ds, times=1) 
     200        cm = scoring.confusion_matrices(pt, class_index=1) 
     201        scores = self.score(cm) 
     202        self.assertIsInstance(scores, list) 
     203 
     204    def test_with_confusion_matrix_on_biclass(self): 
     205        learner = random_learner 
     206        ds = data.Table("monks-1") 
     207        pt = testing.proportion_test([learner], ds, times=1) 
     208        cm = scoring.confusion_matrices(pt, class_index=1) 
     209        scores = self.score(cm[0]) 
     210        self.assertIsInstance(scores, float) 
     211 
     212    def test_with_confusion_matrix_on_multiclass(self): 
     213        learner = random_learner 
     214        ds = data.Table("iris") 
     215        pt = testing.proportion_test([learner], ds, times=1) 
     216        cm = scoring.confusion_matrices(pt, class_index=1) 
     217        scores = self.score(cm[0]) 
     218        self.assertIsInstance(scores, float) 
     219 
     220 
     221class TestSensitivity(CMScoreTest, unittest.TestCase): 
     222    @property 
     223    def score(self): 
     224        return scoring.Sensitivity 
     225 
     226class TestSpecificity(CMScoreTest, unittest.TestCase): 
     227    @property 
     228    def score(self): 
     229        return scoring.Specificity 
     230 
     231class TestPrecision(CMScoreTest, unittest.TestCase): 
     232    @property 
     233    def score(self): 
     234        return scoring.Precision 
     235 
     236class TestRecall(CMScoreTest, unittest.TestCase): 
     237    @property 
     238    def score(self): 
     239        return scoring.Recall 
     240 
     241class TestPPV(CMScoreTest, unittest.TestCase): 
     242    @property 
     243    def score(self): 
     244        return scoring.PPV 
     245 
     246class TestNPV(CMScoreTest, unittest.TestCase): 
     247    @property 
     248    def score(self): 
     249        return scoring.NPV 
     250 
     251class TestF1(CMScoreTest, unittest.TestCase): 
     252    @property 
     253    def score(self): 
     254        return scoring.F1 
     255 
     256class TestFalpha(CMScoreTest, unittest.TestCase): 
     257    @property 
     258    def score(self): 
     259        return scoring.Falpha 
     260 
     261class TestMCC(CMScoreTest, unittest.TestCase): 
     262    @property 
     263    def score(self): 
     264        return scoring.MCC 
    190265 
    191266if __name__ == '__main__': 
  • Orange/testing/unit/tests/test_lasso.py

    r10278 r10434  
    88    import unittest 
    99 
    10 @datasets_driven(datasets=testing.REGRESSION_DATASETS) 
     10@datasets_driven(datasets=["housing", "servo"]) 
    1111class TestLassoRegressionLearner(testing.LearnerTestCase): 
    1212 
  • Orange/testing/unit/tests/test_table.py

    r10278 r10461  
     1# -*- coding: utf-8 -*- 
    12""" Orange.data.Table related unit-tests 
    23""" 
     4 
     5 
    36try: 
    47    import unittest2 as unittest 
     
    3942#        self.assertEqual(table.domain.class_var, table_clone.domain.class_var) 
    4043        self.assertEqual(native(table), native(table_clone), "Native representation is not equal!") 
     44         
     45     
    4146 
    4247 
     
    7984 
    8085 
     86@testing.datasets_driven 
     87class TestUnicodeFilenames(unittest.TestCase): 
     88     
     89    @testing.test_on_data 
     90    def test_tab_on(self, name): 
     91        """ Test the loading and saving to/from unicode (utf-8) filenames. 
     92        """ 
     93        table = Orange.data.Table(name) 
     94        with tempfile.NamedTemporaryFile(suffix=u"ü-š-ç.tab") as f: 
     95            table.save(f.name) 
     96            f.flush() 
     97            table1 = Orange.data.Table(f.name) 
     98         
     99    @testing.test_on_datasets(datasets=testing.CLASSIFICATION_DATASETS + \ 
     100                              testing.REGRESSION_DATASETS) 
     101    def test_txt_on(self, name): 
     102        """ Test the loading and saving to/from unicode (utf-8) filenames. 
     103        """ 
     104        table = Orange.data.Table(name) 
     105        with tempfile.NamedTemporaryFile(suffix=u"ü-š-ç.txt") as f: 
     106            table.save(f.name) 
     107            f.flush() 
     108            table1 = Orange.data.Table(f.name) 
     109             
     110    @testing.test_on_datasets(datasets=testing.CLASSIFICATION_DATASETS + \ 
     111                              testing.REGRESSION_DATASETS) 
     112    def test_arff_on(self, name): 
     113        """ Test the loading and saving to/from unicode (utf-8) filenames. 
     114        """ 
     115        table = Orange.data.Table(name) 
     116        with tempfile.NamedTemporaryFile(suffix=u"ü-š-ç.arff") as f: 
     117            table.save(f.name) 
     118            f.flush() 
     119            table1 = Orange.data.Table(f.name) 
     120             
     121    def test_basket(self): 
     122        """ Test the loading and saving to/from unicode (utf-8) filenames. 
     123        """ 
     124        table = Orange.data.Table("inquisition.basket") 
     125        with tempfile.NamedTemporaryFile(suffix=u"ü-š-ç.basket") as f: 
     126            table.save(f.name) 
     127            f.flush() 
     128            table1 = Orange.data.Table(f.name) 
     129         
    81130 
    82131 
  • docs/extend-widgets/rst/conf.py

    r9917 r10437  
    1717# add these directories to sys.path here. If the directory is relative to the 
    1818# documentation root, use os.path.abspath to make it absolute, like shown here. 
    19 sys.path.append(os.path.abspath('../../../orange')) 
     19sys.path.append(os.path.abspath('../../../')) 
    2020import Orange 
    2121 
  • docs/reference/rst/Orange.clustering.rst

    r10166 r10421  
    33########################### 
    44 
    5 .. automodule:: Orange.clustering 
     5.. py:currentmodule:: Orange.clustering 
     6 
     7.. index:: clustering 
     8 
     9Orange offers three clustering methods: k-means clustering, hierarchical clustering with different link functions, and consensus clustering, which is still much under development. 
    610 
    711.. toctree:: 
  • docs/reference/rst/Orange.evaluation.scoring.rst

    r10343 r10426  
    2727be passed as well. 
    2828 
    29 .. autoclass:: CA 
    30 .. autofunction:: sens 
    31 .. autofunction:: spec 
     29.. autofunction:: CA 
     30.. autofunction:: Sensitivity 
     31.. autofunction:: Specificity 
    3232.. autofunction:: PPV 
    3333.. autofunction:: NPV 
    34 .. autofunction:: precision 
    35 .. autofunction:: recall 
     34.. autofunction:: Precision 
     35.. autofunction:: Recall 
    3636.. autofunction:: F1 
    3737.. autofunction:: Falpha 
     
    4848.. autofunction:: Brier_score 
    4949 
    50 .. autoclass:: AUC 
    51     :members: by_weighted_pairs, by_pairs, 
    52               weighted_one_against_all, one_against_all, single_class, pair, 
    53               matrix 
    54  
     50.. autofunction:: AUC 
     51.. autofunction:: AUC_for_single_class 
     52.. autofunction:: AUC_matrix 
    5553.. autofunction:: AUCWilcoxon 
    5654 
  • docs/reference/rst/Orange.multilabel.rst

    r9928 r10417  
    66.org/wiki/Multi-label_classification>`_ is a machine learning prediction 
    77problem in which multiple binary variables (i.e. labels) are being predicted. 
    8 Orange supports such a task, although the set of available methods is 
    9 currently rather limited. 
     8Orange offers a limited number of methods for this task. 
    109 
    1110Multi-label data is represented as :ref:`multi-target data <multiple-classes>` 
     
    1413using :ref:`multiclass directive <tab-delimited>`. 
    1514 
    16 .. automodule:: Orange.multilabel 
    17  
    18 .. toctree:: 
    19    :maxdepth: 1 
    20  
    21    Orange.multilabel.br 
    22    Orange.multilabel.lp 
    23    Orange.multilabel.multiknn 
    24    Orange.multilabel.mlknn 
    25    Orange.multilabel.brknn 
     15.. automodule:: Orange.multilabel.br 
     16.. automodule:: Orange.multilabel.lp 
     17.. automodule:: Orange.multilabel.multiknn 
     18.. automodule:: Orange.multilabel.mlknn 
     19.. automodule:: Orange.multilabel.brknn 
  • docs/reference/rst/code/som-mapping.py

    r10322 r10455  
    1717print "\n".join(["%s  %d" % (str(n.pos), len(n.examples)) for n in map]) 
    1818 
    19 i, j = 1, 2 
     19i, j = 0, 1 
    2020print 
    2121print "Data instances in cell (%d, %d):" % (i, j) 
  • docs/reference/rst/code/statExamples.py

    r9945 r10429  
    6868 
    6969cm = Orange.evaluation.scoring.confusion_matrices(res) 
     70sensitivities = Orange.evaluation.scoring.sens(cm) 
     71specificities = Orange.evaluation.scoring.spec(cm) 
    7072print 
    7173print "Sensitivity and specificity for 'voting'" 
    7274print "method\tsens\tspec" 
    7375for l in range(len(learners)): 
    74     print "%s\t%5.3f\t%5.3f" % (learners[l].name, Orange.evaluation.scoring.sens(cm[l]), Orange.evaluation.scoring.spec(cm[l])) 
     76    print "%s\t%5.3f\t%5.3f" % (learners[l].name, sensitivities[l], specificities[l]) 
    7577 
    7678cm = Orange.evaluation.scoring.confusion_matrices(resVeh, vehicle.domain.class_var.values.index("van")) 
     79sensitivities = Orange.evaluation.scoring.sens(cm) 
     80specificities = Orange.evaluation.scoring.spec(cm) 
    7781print 
    7882print "Sensitivity and specificity for 'vehicle=van'" 
    7983print "method\tsens\tspec" 
    8084for l in range(len(learners)): 
    81     print "%s\t%5.3f\t%5.3f" % (learners[l].name, Orange.evaluation.scoring.sens(cm[l]), Orange.evaluation.scoring.spec(cm[l])) 
     85    print "%s\t%5.3f\t%5.3f" % (learners[l].name, sensitivities[l], specificities[l]) 
    8286 
    8387print 
  • docs/reference/rst/code/svm-easy.py

    r9823 r10435  
    1010from Orange.evaluation import testing, scoring 
    1111 
    12 results = testing.cross_validation(learners, vehicle, folds=5) 
     12results = testing.proportion_test(learners, vehicle, times=1) 
    1313print "Name     CA        AUC" 
    1414for learner,CA,AUC in zip(learners, scoring.CA(results), scoring.AUC(results)): 
  • docs/widgets/rst/index.rst

    r10409 r10419  
    2020      - |PurgeDomain_icon| `Purge Domain`_ 
    2121      - |MergeData_icon| `Merge Data`_ 
    22     * - |Concat_icon| `Concat`_ 
     22    * - |Concat_icon| `Concatenate`_ 
    2323      - |DataSampler_icon| `Data Sampler`_ 
    2424      - |SelectData_icon| `Select Data`_ 
    2525    * - |Save_icon| `Save`_ 
    2626      - |Discretize_icon| `Discretize`_ 
    27       - |Cont_icon| `Cont`_ 
     27      - |Cont_icon| `Continuize`_ 
    2828    * - |Impute_icon| `Impute`_ 
    2929      - |Outliers_icon| `Outliers`_ 
     
    3636.. _`Merge Data`: _static/Data/MergeData.htm 
    3737 
    38 .. _`Concat`: _static/Data/Concatenate.htm 
     38.. _`Concatenate`: _static/Data/Concatenate.htm 
    3939 
    4040.. _`Data Sampler`: _static/Data/DataSampler.htm 
     
    4646.. _`Discretize`: _static/Data/Discretize.htm 
    4747 
    48 .. _`Cont`: _static/Data/Continuize.htm 
     48.. _`Continuize`: _static/Data/Continuize.htm 
    4949 
    5050.. _`Impute`: _static/Data/Impute.htm 
     
    146146     
    147147    * - |Distributions_icon| `Distributions`_ 
    148       - |ScatterPlot_icon| `ScatterPlot`_ 
    149       - |AttributeStatistics_icon| `AttrStat`_ 
     148      - |ScatterPlot_icon| `Scatter Plot`_ 
     149      - |AttributeStatistics_icon| `Attribute Statistics`_ 
    150150    * - |LinearProjection_icon| `Linear Projection`_ 
    151151      - |Radviz_icon| `Radviz`_ 
    152       - |PolyViz_icons| `PolyViz`_ 
     152      - |Polyviz_icon| `Polyviz`_ 
    153153    * - |ParallelCoords_icon| `Parallel Coordinates`_ 
    154154      - |SurveyPlot_icon| `Survey Plot`_ 
     
    160160.. _`Distributions`: _static/Visualize/Distributions.htm 
    161161 
    162 .. _`ScatterPlot`: _static/Visualize/ScatterPlot.htm 
    163  
    164 .. _`AttrStat`: _static/Visualize/AttributeStatistics.htm 
     162.. _`Scatter Plot`: _static/Visualize/Scatterplot.htm 
     163 
     164.. _`Attribute Statistics`: _static/Visualize/AttributeStatistics.htm 
    165165 
    166166.. _`Linear Projection`: _static/Visualize/LinearProjection.htm 
     
    168168.. _`Radviz`: _static/Visualize/Radviz.htm 
    169169 
    170 .. _`PolyViz`: _static/Visualize/PolyViz.htm 
     170.. _`Polyviz`: _static/Visualize/Polyviz.htm 
    171171 
    172172.. _`Parallel Coordinates`: _static/Visualize/ParallelCoordinates.htm 
     
    209209    :height: 48 
    210210     
    211 .. |PolyViz_icons| image:: ../../../Orange/OrangeWidgets/Visualize/icons/PolyViz_48.png 
     211.. |Polyviz_icon| image:: ../../../Orange/OrangeWidgets/Visualize/icons/Polyviz_48.png 
    212212    :align: middle 
    213213    :alt: Poly Viz 
     
    448448     
    449449    * - |ConfusionMatrix_icon| `Confusion Matrix`_   
    450       - |ROCAnalisys_icon| `ROC Analisys`_ 
     450      - |ROCAnalysis_icon| `ROC Analysis`_ 
    451451      - |LiftCurve_icon| `Lift Curve`_ 
    452452    * - |CalibrationPlot_icon| `Calibration Plot`_ 
     
    456456.. _`Confusion Matrix`: _static/Evaluate/ConfusionMatrix.htm 
    457457 
    458 .. _`ROC Analisys`: _static/Evaluate/ROCAnalisys.htm 
     458.. _`ROC Analysis`: _static/Evaluate/ROCAnalysis.htm 
    459459 
    460460.. _`Lift Curve`: _static/Evaluate/LiftCurve.htm 
     
    472472    :height: 48 
    473473 
    474 .. |ROCAnalisys_icon| image:: ../../../Orange/OrangeWidgets/Evaluate/icons/ROCAnalysis_48.png  
     474.. |ROCAnalysis_icon| image:: ../../../Orange/OrangeWidgets/Evaluate/icons/ROCAnalysis_48.png  
    475475    :align: middle 
    476476    :alt: Pade 
     
    545545    :height: 48 
    546546 
    547 .. |ItemSets_icon| image:: ../../../Orange/OrangeWidgets/Associate/icons/ItemSets_48.png 
     547.. |ItemSets_icon| image:: ../../../Orange/OrangeWidgets/Associate/icons/Itemsets_48.png 
    548548    :align: middle 
    549549    :alt: Item Sets 
     
    551551    :height: 48 
    552552 
    553 .. |ItemSetsExplorer_icon| image:: ../../../Orange/OrangeWidgets/Associate/icons/ItemSetsExplorer_48.png 
     553.. |ItemSetsExplorer_icon| image:: ../../../Orange/OrangeWidgets/Associate/icons/ItemsetsExplorer_48.png 
    554554    :align: middle 
    555555    :alt: Item Sets Explorer 
  • setup.py

    r10391 r10471  
    11#!usr/bin/env python 
     2"""Orange: Machine learning and interactive data mining toolbox. 
     3 
     4Orange is a scriptable environment for fast prototyping of new 
     5algorithms and testing schemes. It is a collection of Python packages 
     6that sit over the core library and implement some functionality for 
     7which execution time is not crucial and which is easier done in Python 
     8than in C++. This includes a variety of tasks such as attribute subset, 
     9bagging and boosting, and alike. 
     10 
     11Orange also includes a set of graphical widgets that use methods from 
     12core library and Orange modules. Through visual programming, widgets 
     13can be assembled together into an application by a visual programming 
     14tool called Orange Canvas. 
     15""" 
     16 
     17DOCLINES = __doc__.split("\n") 
    218 
    319import os, sys         
     
    1834from distutils.msvccompiler import MSVCCompiler 
    1935from distutils.unixccompiler import UnixCCompiler 
    20   
     36import subprocess 
     37 
     38CLASSIFIERS = """\ 
     39Development Status :: 4 - Beta 
     40Programming Language :: Python 
     41License :: OSI Approved :: GNU General Public License (GPL) 
     42Operating System :: POSIX 
     43Operating System :: Microsoft :: Windows 
     44Topic :: Scientific/Engineering :: Artificial Intelligence 
     45Topic :: Scientific/Engineering :: Visualization 
     46Intended Audience :: Education 
     47Intended Audience :: Science/Research 
     48""" 
     49 
     50KEYWORDS = """\ 
     51data mining 
     52machine learning 
     53artificial intelligence 
     54""" 
     55 
     56NAME                = 'Orange' 
     57DESCRIPTION         = DOCLINES[0] 
     58LONG_DESCRIPTION    = "\n".join(DOCLINES[2:]) 
     59URL                 = "http://orange.biolab.si" 
     60DOWNLOAD_URL        = "https://bitbucket.org/biolab/orange/downloads" 
     61LICENSE             = 'GNU General Public License (GPL)' 
     62CLASSIFIERS         = filter(None, CLASSIFIERS.split('\n')) 
     63AUTHOR              = "Bioinformatics Laboratory, FRI UL" 
     64AUTHOR_EMAIL        = "orange@fri.uni-lj.si" 
     65KEYWORDS            = filter(None, KEYWORDS.split('\n')) 
     66MAJOR               = 2 
     67MINOR               = 5 
     68MICRO               = 0 
     69ISRELEASED          = False 
     70VERSION             = '%d.%d.%da5' % (MAJOR, MINOR, MICRO) 
     71 
    2172if have_setuptools: 
    2273    setuptools_args = {"zip_safe": False, 
     
    541592                      libraries=libraries 
    542593                      ) 
    543      
    544 import fnmatch 
    545 matches = [] 
    546  
    547 #Recursively find '__init__.py's 
    548 for root, dirnames, filenames in os.walk('Orange'):  
    549  
    550   for filename in fnmatch.filter(filenames, '__init__.py'): 
    551       matches.append(os.path.join(root, filename)) 
    552 packages = [os.path.dirname(pkg).replace(os.path.sep, '.') for pkg in matches] 
    553  
    554  
    555 default_version = "2.5a4" 
    556 ############################################ 
    557 # Try to get the hg revision. Do 
    558 #     $ hg parent --template="2.5a3-r{rev} > version 
    559 # before running setup.py (note the example shown does  
    560 # not conform to StrictVersion needed by bdist_msi).  
    561 ############################################ 
    562 if os.path.exists("version"): 
    563     f = open("version") 
    564     version = f.read() 
    565 else: 
    566     version = default_version 
    567      
    568  
    569 setup(cmdclass={"build_ext": pyxtract_build_ext, 
    570                 "install_lib": my_install_lib, 
    571                 "install": my_install}, 
    572       name ="Orange", 
    573       version = version, 
    574       description = "Machine learning and interactive data mining toolbox.", 
    575       author = "Bioinformatics Laboratory, FRI UL", 
    576       author_email = "orange@fri.uni-lj.si", 
    577       url = "http://orange.biolab.si", 
    578       download_url = "https://bitbucket.org/biolab/orange/downloads", 
    579       packages = packages + ["Orange.OrangeCanvas", 
    580                              "Orange.OrangeWidgets", 
    581                              "Orange.OrangeWidgets.Associate", 
    582                              "Orange.OrangeWidgets.Classify", 
    583                              "Orange.OrangeWidgets.Data", 
    584                              "Orange.OrangeWidgets.Evaluate", 
    585                              "Orange.OrangeWidgets.Prototypes", 
    586                              "Orange.OrangeWidgets.Regression", 
    587                              "Orange.OrangeWidgets.Unsupervised", 
    588                              "Orange.OrangeWidgets.Visualize", 
    589                              "Orange.OrangeWidgets.Visualize Qt", 
    590                              "Orange.OrangeWidgets.plot", 
    591                              "Orange.OrangeWidgets.plot.primitives", 
    592                              ], 
    593        
    594       package_data = { 
    595           "Orange" : ["orangerc.cfg", "doc/datasets/*.tab", "doc/datasets/*.csv", "doc/datasets/*.basket", 
    596                       "doc/networks/*.net", "doc/networks/*.tab", 
    597                       "doc/style.css", "doc/widgets/*/*.*", 
    598                       "testing/regression/tests_20/*.tab", 
    599                       "testing/regression/tests_20/*.net", 
    600                       "testing/regression/tests_20/*.basket", 
    601                       "testing/regression/tests_20/*.csv"], 
    602           "Orange.OrangeCanvas": ["icons/*.png", "orngCanvas.pyw", "WidgetTabs.txt"], 
    603           "Orange.OrangeWidgets":["icons/*.png", "icons/backgrounds/*.png", "report/index.html"], 
    604           "Orange.OrangeWidgets.Associate": ["icons/*.png"], 
    605           "Orange.OrangeWidgets.Classify": ["icons/*.png"], 
    606           "Orange.OrangeWidgets.Data": ["icons/*.png"], 
    607           "Orange.OrangeWidgets.Evaluate": ["icons/*.png"], 
    608           "Orange.OrangeWidgets.Prototypes": ["icons/*.png"], 
    609           "Orange.OrangeWidgets.Regression": ["icons/*.png"], 
    610           "Orange.OrangeWidgets.Unsupervised": ["icons/*.png"], 
    611           "Orange.OrangeWidgets.Visualize": ["icons/*.png"], 
    612           "Orange.OrangeWidgets.Visualize Qt": ["icons/*.png"], 
    613           "Orange.OrangeWidgets.plot": ["*.gs", "*.vs"], 
    614           "Orange.OrangeWidgets.plot.primitives": ["*.obj"], 
    615           }, 
    616       ext_modules = [include_ext, orange_ext, orangeom_ext, 
    617                      orangene_ext, corn_ext, statc_ext], 
    618       scripts = ["bin/orange-canvas"], 
    619       license = "GNU General Public License (GPL)", 
    620       keywords = ["data mining", "machine learning", "artificial intelligence"], 
    621       classifiers = ["Development Status :: 4 - Beta", 
    622                      "Programming Language :: Python", 
    623                      "License :: OSI Approved :: GNU General Public License (GPL)", 
    624                      "Operating System :: POSIX", 
    625                      "Operating System :: Microsoft :: Windows", 
    626                      "Topic :: Scientific/Engineering :: Artificial Intelligence", 
    627                      "Topic :: Scientific/Engineering :: Visualization", 
    628                      "Intended Audience :: Education", 
    629                      "Intended Audience :: Science/Research" 
    630                      ], 
    631       long_description="""\ 
    632 Orange data mining library 
    633 ========================== 
    634  
    635 Orange is a scriptable environment for fast prototyping of new 
    636 algorithms and testing schemes. It is a collection of Python packages 
    637 that sit over the core library and implement some functionality for 
    638 which execution time is not crucial and which is easier done in Python 
    639 than in C++. This includes a variety of tasks such as attribute subset, 
    640 bagging and boosting, and alike. 
    641  
    642 Orange also includes a set of graphical widgets that use methods from  
    643 core library and Orange modules. Through visual programming, widgets 
    644 can be assembled together into an application by a visual programming 
    645 tool called Orange Canvas. 
    646 """, 
    647       **setuptools_args) 
    648        
    649  
     594 
     595 
     596import __builtin__ as builtins 
     597 
     598# We are setting a global variable so that the main Orange __init__ can detect 
     599# if it is being loaded by the setup routine, to avoid attempting to 
     600# load components that aren't built yet. 
     601builtins.__ORANGE_SETUP__ = True 
     602 
     603def get_packages(): 
     604    import fnmatch 
     605    matches = [] 
     606 
     607    #Recursively find '__init__.py's 
     608    for root, dirnames, filenames in os.walk('Orange'): 
     609      # Add packages for Orange 
     610      for filename in fnmatch.filter(filenames, '__init__.py'): 
     611          matches.append(os.path.join(root, filename)) 
     612    return [os.path.dirname(pkg).replace(os.path.sep, '.') for pkg in matches] 
     613 
     614def get_package_data(): 
     615    package_data = { 
     616        "Orange": 
     617            ["orangerc.cfg", "doc/style.css", "doc/widgets/*/*.*"] +\ 
     618             all_with_extension(path="doc/datasets", extensions=("tab", "csv", "basket")) +\ 
     619             all_with_extension(path="doc/networks", extensions=("net", "tab")) +\ 
     620             all_with_extension(path="testing/regression/tests_20", extensions=("net", "tab", "basket", "csv")), 
     621        "Orange.OrangeCanvas": ["icons/*.png", "orngCanvas.pyw", "WidgetTabs.txt"], 
     622        "Orange.OrangeWidgets": ["icons/*.png", "icons/backgrounds/*.png", "report/index.html"], 
     623        "Orange.OrangeWidgets.Associate": ["icons/*.png"], 
     624        "Orange.OrangeWidgets.Classify": ["icons/*.png"], 
     625        "Orange.OrangeWidgets.Data": ["icons/*.png"], 
     626        "Orange.OrangeWidgets.Evaluate": ["icons/*.png"], 
     627        "Orange.OrangeWidgets.Prototypes": ["icons/*.png"], 
     628        "Orange.OrangeWidgets.Regression": ["icons/*.png"], 
     629        "Orange.OrangeWidgets.Unsupervised": ["icons/*.png"], 
     630        "Orange.OrangeWidgets.Visualize": ["icons/*.png"], 
     631        "Orange.OrangeWidgets.Visualize Qt": ["icons/*.png"], 
     632        "Orange.OrangeWidgets.plot": ["*.gs", "*.vs"], 
     633        "Orange.OrangeWidgets.plot.primitives": ["*.obj"], 
     634    } 
     635 
     636    return package_data 
     637 
     638def all_with_extension(path, extensions): 
     639    return [os.path.join(path, "*.%s"%extension) for extension in extensions] 
     640 
     641def hg_revision(): 
     642    # Copied from numpy setup.py and modified to work with hg 
     643    def _minimal_ext_cmd(cmd): 
     644        # construct minimal environment 
     645        env = {} 
     646        for k in ['SYSTEMROOT', 'PATH']: 
     647            v = os.environ.get(k) 
     648            if v is not None: 
     649                env[k] = v 
     650        # LANGUAGE is used on win32 
     651        env['LANGUAGE'] = 'C' 
     652        env['LANG'] = 'C' 
     653        env['LC_ALL'] = 'C' 
     654        out = subprocess.Popen(cmd, stdout = subprocess.PIPE, env=env).communicate()[0] 
     655        return out 
     656 
     657    try: 
     658        out = _minimal_ext_cmd(['hg', 'ide', '-i']) 
     659        HG_REVISION = str(out.strip().decode('ascii')) 
     660    except OSError: 
     661        HG_REVISION = "Unknown" 
     662 
     663    return HG_REVISION 
     664 
     665def write_version_py(filename='Orange/version.py'): 
     666    # Copied from numpy setup.py 
     667    cnt = """ 
     668# THIS FILE IS GENERATED FROM ORANGE SETUP.PY 
     669short_version = '%(version)s' 
     670version = '%(version)s' 
     671full_version = '%(full_version)s' 
     672hg_revision = '%(hg_revision)s' 
     673release = %(isrelease)s 
     674 
     675if not release: 
     676    version = full_version 
     677""" 
     678    global VERSION 
     679     
     680    FULLVERSION = VERSION 
     681    if os.path.exists('.hg'): 
     682        HG_REVISION = hg_revision() 
     683    elif os.path.exists('Orange/version.py'): 
     684        # must be a source distribution, use existing version file 
     685        import imp 
     686        version = imp.load_source("Orange.version", "Orange/version.py") 
     687        HG_REVISION = version.hg_revision 
     688    else: 
     689        HG_REVISION = "Unknown" 
     690 
     691    if not ISRELEASED: 
     692        FULLVERSION += '.dev-' + HG_REVISION[:7] 
     693 
     694    a = open(filename, 'w') 
     695    try: 
     696        a.write(cnt % {'version': VERSION, 
     697                       'full_version' : FULLVERSION, 
     698                       'hg_revision' : HG_REVISION, 
     699                       'isrelease': str(ISRELEASED)}) 
     700    finally: 
     701        a.close() 
     702     
     703    if not ISRELEASED: 
     704        VERSION = FULLVERSION  
     705 
     706def setup_package(): 
     707    write_version_py() 
     708    setup(name = NAME, 
     709          description = DESCRIPTION, 
     710          version = VERSION, 
     711          author = AUTHOR, 
     712          author_email = AUTHOR_EMAIL, 
     713          url = URL, 
     714          download_url = DOWNLOAD_URL, 
     715          classifiers = CLASSIFIERS, 
     716          long_description=LONG_DESCRIPTION, 
     717          license = LICENSE, 
     718          keywords = KEYWORDS, 
     719 
     720          cmdclass={"build_ext": pyxtract_build_ext, 
     721                    "install_lib": my_install_lib, 
     722                    "install": my_install}, 
     723          packages = get_packages(), 
     724          package_data = get_package_data(), 
     725          ext_modules = [include_ext, orange_ext, orangeom_ext, 
     726                         orangene_ext, corn_ext, statc_ext], 
     727          scripts = ["bin/orange-canvas"], 
     728          **setuptools_args) 
     729 
     730if __name__ == '__main__': 
     731    setup_package() 
  • source/orange/lib_io.cpp

    r10220 r10460  
    3838PyObject *encodeStatus(const vector<int> &Status);  // in cls_misc.cpp 
    3939PyObject *encodeStatus(const vector<pair<int, int> > &metaStatus); 
     40 
     41 
     42/* Same as sys.getfilesystemencoding() 
     43 * (the returned pointer points to a PyString_Object internal buffer 
     44 * and should not be modified). 
     45 */ 
     46char* getFileSystemEncoding() 
     47{ 
     48    PyObject *fsencoding = PySys_GetObject("getfilesystemencoding"); // Borrowed ref 
     49    fsencoding = PyObject_CallObject(fsencoding, NULL); // This should be a string. 
     50    assert(PyString_Check(fsencoding)); 
     51    return PyString_AsString(fsencoding); 
     52} 
    4053 
    4154/* ************ FILE EXAMPLE GENERATORS ************ */ 
     
    216229{ PyTRY 
    217230    char *filename; 
     231    bool free_filename = false; 
    218232    PExampleGenerator gen; 
    219233 
    220234    if (!PyArg_ParseTuple(args, "sO&", &filename, pt_ExampleGenerator, &gen)) 
    221       PYERROR(PyExc_TypeError, "string and example generator expected", PYNULL); 
     235    { 
     236        char *encoding = getFileSystemEncoding(); 
     237        if (!PyArg_ParseTuple(args, "esO&", encoding, &filename, pt_ExampleGenerator, &gen)) 
     238            PYERROR(PyExc_TypeError, "string and example generator expected", PYNULL); 
     239        PyErr_Clear(); 
     240        free_filename = true; 
     241    } 
    222242 
    223243    if (skipAttrTypes && !gen->domain->classVar) { 
    224244      PyErr_Format(PyExc_TypeError, "Format .%s cannot save classless data sets", defaultExtension); 
     245      if (free_filename) 
     246          PyMem_Free(filename); 
    225247      return PYNULL; 
    226248    } 
     
    228250    char *DK = NULL, *DC = NULL; 
    229251    if (!readUndefinedSpecs(keyws, DK, DC)) 
    230       return PYNULL; 
     252    { 
     253      if (free_filename) 
     254          PyMem_Free(filename); 
     255      return PYNULL; 
     256    } 
    231257   
    232258    FILE *ostr = openExtended(filename, defaultExtension); 
    233259    if (!ostr) 
    234       return PYNULL; 
    235  
     260    { 
     261      if (free_filename) 
     262          PyMem_Free(filename); 
     263      return PYNULL; 
     264    } 
     265 
     266    if (free_filename) 
     267        PyMem_Free(filename); 
    236268    tabDelim_writeDomain(ostr, gen->domain, skipAttrTypes, delim, listDiscreteValues); 
    237269    tabDelim_writeExamples(ostr, gen, delim, DK, DC); 
     
    317349{ PyTRY 
    318350    char *filename; 
     351    bool free_filename = false; 
    319352    PExampleGenerator gen; 
    320353 
    321354    if (!PyArg_ParseTuple(args, "sO&:saveBasket", &filename, pt_ExampleGenerator, &gen)) 
    322       return PYNULL; 
     355    { 
     356      char *encoding = getFileSystemEncoding(); 
     357      if (!PyArg_ParseTuple(args, "esO&:saveBasket", encoding, &filename, pt_ExampleGenerator, &gen)) 
     358          return PYNULL; 
     359      PyErr_Clear(); 
     360      free_filename = true; 
     361    } 
    323362 
    324363    if (gen->domain->variables->size()) 
     364    { 
     365      if (free_filename) 
     366          PyMem_Free(filename); 
    325367      PYERROR(PyExc_TypeError, ".basket format can only store meta-attribute values", PYNULL); 
     368    } 
    326369 
    327370    FILE *ostr = openExtended(filename, "basket"); 
     371 
    328372    if (!ostr) 
    329       return PYNULL; 
     373    { 
     374      if (free_filename) 
     375          PyMem_Free(filename); 
     376      return PYNULL; 
     377    } 
    330378 
    331379    set<int> missing; 
     
    337385      fclose(ostr); 
    338386      remove(filename); 
     387      if (free_filename) 
     388          PyMem_Free(filename); 
    339389      throw; 
    340390    } 
    341391 
    342392    fclose(ostr); 
     393 
     394    if (free_filename) 
     395        PyMem_Free(filename); 
    343396 
    344397    if (!missing.empty()) { 
  • source/orange/lib_kernel.cpp

    r10357 r10460  
    27352735 
    27362736const char *getExtension(const char *name); 
     2737char *getFileSystemEncoding(); // defined in lib_io.cpp 
    27372738 
    27382739PyObject *saveTabDelimited(PyObject *, PyObject *args, PyObject *keyws); 
     
    27452746{ 
    27462747  char *filename; 
     2748  bool free_filename = false; 
    27472749  if (!PyArg_ParseTuple(args, "s:ExampleGenerator.save", &filename)) 
    2748     return PYNULL; 
     2750  { 
     2751      // Try again, this time with the fs encoding. 
     2752      char *encoding = getFileSystemEncoding(); 
     2753      if (!PyArg_ParseTuple(args, "es:ExampleGenerator.save", encoding, &filename)) 
     2754          return PYNULL; 
     2755      free_filename = true; 
     2756      PyErr_Clear(); 
     2757  } 
    27492758 
    27502759  const char *extension = getExtension(filename); 
    27512760  if (!extension) 
     2761  { 
     2762    if (free_filename) 
     2763        PyMem_Free(filename); 
    27522764    PYERROR(PyExc_TypeError, "file name must have an extension", PYNULL); 
     2765  } 
    27532766 
    27542767 
     
    27882801 
    27892802  Py_DECREF(newargs); 
     2803 
     2804  if (free_filename) 
     2805      PyMem_Free(filename); 
     2806 
    27902807  return res; 
    27912808} 
     
    30573074} 
    30583075 
    3059  
    30603076CONSTRUCTOR_KEYWORDS(ExampleTable, "domain use useMetas dontCheckStored dontStore filterMetas filter_metas DC DK NA noClass noCodedDiscrete createNewOn") 
    30613077 
     
    30663082    char *filename = NULL; 
    30673083    if (PyArg_ParseTuple(argstuple, "s", &filename)) 
    3068       return loadDataFromFile(type, filename, argstuple, keywords, false); 
     3084        return loadDataFromFile(type, filename, argstuple, keywords, false); 
     3085 
     3086    PyErr_Clear(); 
     3087 
     3088    /*For a case where the unicode can't be converted to a default 
     3089     * encoding (on most platforms this is ASCII) 
     3090     */ 
     3091    char * coding = getFileSystemEncoding(); 
     3092    if (PyArg_ParseTuple(argstuple, "es", coding, &filename)) 
     3093    { 
     3094        PyObject *rval = loadDataFromFile(type, filename, argstuple, keywords, false); 
     3095        PyMem_Free(filename); 
     3096        return rval; 
     3097    } 
    30693098 
    30703099    PyErr_Clear(); 
Note: See TracChangeset for help on using the changeset viewer.