Ignore:
Files:
519 added
78 deleted
24 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeCanvas/orngDlgs.py

    r11037 r11075  
    66from PyQt4.QtGui import * 
    77from orngCanvasItems import MyCanvasText 
     8from contextlib import closing 
    89import OWGUI, sys, os 
    910 
     
    726727class AddOnManagerDialog(QDialog): 
    727728    def __init__(self, canvasDlg, *args): 
    728         apply(QDialog.__init__,(self,) + args) 
     729        QDialog.__init__(self, *args) 
     730        self.setModal(True) 
     731 
    729732        self.canvasDlg = canvasDlg 
    730733        self.setWindowTitle("Add-on Management") 
     
    845848        self.repaint() 
    846849        add, remove, upgrade = self.to_install(), self.to_remove(), self.to_upgrade 
     850 
     851        def errormessage(title, message, details=None, exc_info=None): 
     852            box = QMessageBox(QMessageBox.Critical, title, message, 
     853                              parent=self) 
     854 
     855            if details is not None: 
     856                box.setDetailedText(details) 
     857            elif exc_info: 
     858                import traceback 
     859                if isinstance(exc_info, tuple): 
     860                    details = traceback.format_exception(*(exc_info + (10,))) 
     861                else: 
     862                    details = traceback.format_exc(10) 
     863                box.setDetailedText(details) 
     864 
     865            return box.exec_() 
     866 
    847867        for name in upgrade: 
    848868            try: 
     
    851871                Orange.utils.addons.upgrade(name, self.pcb) 
    852872            except Exception, e: 
    853                 QMessageBox.critical(self, "Error", "Problem upgrading add-on %s: %s" % (name, e)) 
     873                errormessage("Error", 
     874                             "Problem upgrading add-on %s: %s" % (name, e), 
     875                             exc_info=True) 
     876            except SystemExit, e: 
     877                errormessage("Error", "Abnormal exit", exc_info=True) 
     878 
    854879        for name in remove: 
    855880            try: 
     
    858883                Orange.utils.addons.uninstall(name, self.pcb) 
    859884            except Exception, e: 
    860                 QMessageBox.critical(self, "Error", "Problem uninstalling add-on %s: %s" % (name, e)) 
     885                errormessage("Error", 
     886                             "Problem uninstalling add-on %s: %s" % (name, e), 
     887                             exc_info=True) 
     888 
    861889        for name in add: 
    862890            try: 
     
    865893                Orange.utils.addons.install(name, self.pcb) 
    866894            except Exception, e: 
    867                 QMessageBox.critical(self, "Error", "Problem installing add-on %s: %s" % (name, e)) 
     895                errormessage("Error", 
     896                             "Problem installing add-on %s: %s" % (name, e), 
     897                             exc_info=True) 
     898            except SystemExit, e: 
     899                errormessage("Error", "Abnormal exit", exc_info=True) 
    868900 
    869901        if len(upgrade) > 0: 
     
    889921        self.progress.setMaximum(max) 
    890922        self.progress.setValue(val) 
    891         self.progress.repaint() 
     923        qApp.processEvents(QEventLoop.ExcludeUserInputEvents) 
    892924 
    893925    def reloadRepo(self): 
     
    908940        result = [] 
    909941        import Orange.utils.addons 
    910         for ao in Orange.utils.addons.addons.values(): 
    911             if ao.installed_version and ao.available_version and ao.installed_version != ao.available_version: 
    912                 result.append(ao.name) 
     942        with closing(Orange.utils.addons.open_addons()) as addons: 
     943            for ao in addons.values(): 
     944                if ao.installed_version and ao.available_version and ao.installed_version != ao.available_version: 
     945                    result.append(ao.name) 
    913946        return result 
    914947     
     
    9771010            addon = self.getAddOnFromItem(item) 
    9781011        if addon: 
    979             self.lblDescription.setText(addon.summary.strip() +"\n"+ addon.description.strip()) 
    980             self.lblVerAvailValue.setText(addon.available_version) 
    981  
    982             self.lblVerInstalledValue.setText(addon.installed_version if addon.installed_version else "-") #TODO Tell whether it's a system-wide installation 
     1012            self.lblDescription.setText((addon.summary.strip() or "") +"\n"+ (addon.description.strip() or "")) 
     1013            self.lblVerAvailValue.setText(addon.available_version or "") 
     1014 
     1015            self.lblVerInstalledValue.setText(addon.installed_version or "-") #TODO Tell whether it's a system-wide installation 
    9831016            self.upgradeButton.setVisible(bool(addon.installed_version and addon.installed_version!=addon.available_version) and addon.name not in self.to_upgrade) #TODO Disable if it's a system-wide installation 
    9841017            self.donotUpgradeButton.setVisible(addon.name in self.to_upgrade) 
     
    10031036    def enableDisableButtons(self): 
    10041037        import Orange.utils.addons 
    1005         aos = Orange.utils.addons.addons.values() 
    1006         self.upgradeAllButton.setEnabled(any(ao.installed_version and ao.available_version and 
    1007                                              ao.installed_version != ao.available_version and 
    1008                                              ao.name not in self.to_upgrade for ao in aos)) 
     1038        with closing(Orange.utils.addons.open_addons()) as addons: 
     1039            aos = addons.values() 
     1040            self.upgradeAllButton.setEnabled(any(ao.installed_version and ao.available_version and 
     1041                                                 ao.installed_version != ao.available_version and 
     1042                                                 ao.name not in self.to_upgrade for ao in aos)) 
    10091043         
    10101044    def currentItemChanged(self, new, previous): 
     
    10531087         
    10541088        # Add repositories and add-ons 
    1055         addons = {} 
    1056         for name in Orange.utils.addons.search_index(self.searchStr): 
    1057             addons[name.lower()] = Orange.utils.addons.addons[name.lower()] 
    1058         self.addAddOnsToTree(addons, selected = selected_addon, to_install=to_install, to_remove=to_remove) 
    1059         self.refreshInfoPane() 
     1089        with closing(Orange.utils.addons.open_addons()) as global_addons: 
     1090            addons = {} 
     1091            for name in Orange.utils.addons.search_index(self.searchStr): 
     1092                addons[name.lower()] = global_addons[name.lower()] 
     1093            self.addAddOnsToTree(addons, selected = selected_addon, to_install=to_install, to_remove=to_remove) 
     1094            self.refreshInfoPane() 
    10601095 
    10611096        #TODO Should we somehow show the legacy registered addons? 
  • Orange/classification/__init__.py

    r10188 r11051  
    1414ClassifierFromVar = core.ClassifierFromVar 
    1515ConstantClassifier = core.DefaultClassifier 
     16 
     17class PyLearner(object): 
     18    def __new__(cls, data=None, **kwds): 
     19        learner = object.__new__(cls) 
     20        if data: 
     21            learner.__init__(**kwds) # force init 
     22            return learner(data) 
     23        else: 
     24            return learner  # invokes the __init__ 
     25 
     26    def __init__(self, name='learner'): 
     27        self.name = name 
     28 
     29    def __call__(self, data, weight=None): 
     30        return None 
     31 
     32class PyClassifier: 
     33    def __init__(self, **kwds): 
     34        self.__dict__.update(kwds) 
     35 
     36    def __call__(self, example, resultType = Classifier.GetValue): 
     37        return self.classifier(example, resultType) 
  • Orange/classification/logreg.py

    r10885 r11063  
    22from Orange.utils import deprecated_keywords, deprecated_members 
    33from Orange.data import preprocess 
     4import decimal 
    45import math 
    56 
     
    910from numpy.linalg import inv 
    1011from Orange.core import LogRegClassifier, LogRegFitter, LogRegFitter_Cholesky 
     12 
     13def format_decimal(x, prec=2): 
     14    """Allows arbitrary precision with scientific notation""" 
     15    tup = x.as_tuple() 
     16    digits = list(tup.digits[:prec + 1]) 
     17    sign = '-' if tup.sign else '' 
     18    dec = ''.join(str(i) for i in digits[1:]) 
     19    exp = x.adjusted() 
     20    return '{sign}{int}.{dec}e{exp}'.format(sign=sign, int=digits[0], dec=dec, exp=exp) 
    1121 
    1222def dump(classifier): 
     
    3242    out.append(formatstr % ("Feature", "beta", "st. error", "wald Z", "P", "OR=exp(beta)")) 
    3343    out.append('') 
    34     formatstr = "%"+str(longest)+"s %10.2f %10.2f %10.2f %10.2f"     
     44    formatstr = "%"+str(longest)+"s %10.2f %10.2f %10.2f %10.2f" 
    3545    out.append(formatstr % ("Intercept", classifier.beta[0], classifier.beta_se[0], classifier.wald_Z[0], classifier.P[0])) 
    36     formatstr = "%"+str(longest)+"s %10.2f %10.2f %10.2f %10.2f %10.2f"     
     46    formatstr = "%"+str(longest)+"s %10.2f %10.2f %10.2f %10.2f %s" 
    3747    for i in range(len(classifier.continuized_domain.features)): 
    38         out.append(formatstr % (classifier.continuized_domain.features[i].name, classifier.beta[i+1], classifier.beta_se[i+1], classifier.wald_Z[i+1], abs(classifier.P[i+1]), math.exp(classifier.beta[i+1]))) 
     48        try: 
     49            exp = decimal.Decimal(math.e) ** decimal.Decimal(classifier.beta[i+1]) 
     50        except TypeError: 
     51            # Python 2.6 does not support creating Decimals from float 
     52            exp = decimal.Decimal(str(math.e)) ** decimal.Decimal(str(classifier.beta[i+1])) 
     53        out.append(formatstr % (classifier.continuized_domain.features[i].name, 
     54            classifier.beta[i+1], 
     55            classifier.beta_se[i+1], 
     56            classifier.wald_Z[i+1], 
     57            abs(classifier.P[i+1]), 
     58            format_decimal(exp))) 
    3959 
    4060    return '\n'.join(out) 
    41          
     61 
    4262 
    4363def has_discrete_values(domain): 
  • Orange/testing/regression/results_tests_20/modules_logreg1.py.txt

    r9951 r11064  
    77 
    88    Intercept      -1.23       0.08     -15.15      -0.00 
    9  status=first       0.86       0.16       5.39       0.00       2.36 
    10 status=second      -0.16       0.18      -0.91       0.36       0.85 
    11  status=third      -0.92       0.15      -6.12       0.00       0.40 
    12     age=child       1.06       0.25       4.30       0.00       2.89 
    13    sex=female       2.42       0.14      17.04       0.00      11.25 
     9 status=first       0.86       0.16       5.39       0.00 2.35e0 
     10status=second      -0.16       0.18      -0.91       0.36 8.51e-1 
     11 status=third      -0.92       0.15      -6.12       0.00 3.98e-1 
     12    age=child       1.06       0.25       4.30       0.00 2.89e0 
     13   sex=female       2.42       0.14      17.04       0.00 1.12e1 
  • Orange/testing/unit/tests/test_logreg.py

    r10678 r11061  
    77from orngLR import LogRegLearner, Univariate_LogRegLearner, StepWiseFSS, StepWiseFSS_Filter 
    88 
    9 from Orange.classification.logreg import LibLinearLogRegLearner 
     9from Orange.classification.logreg import LibLinearLogRegLearner, dump 
     10import Orange 
     11 
    1012def datasets_iter(): 
    1113    for name, (data,) in testing.datasets_iter(testing.CLASSIFICATION_DATASETS): 
     
    2224        """ 
    2325        if len(dataset) < len(dataset.domain): 
    24             raise unittest.SkipTest("No enough examples") 
     26            raise unittest.SkipTest("Not enough examples") 
    2527        testing.LearnerTestCase.test_learner_on(self, dataset) 
    2628 
     
    4850        testing.LearnerTestCase.test_learner_on(self, dataset) 
    4951 
     52class TestUtils(unittest.TestCase): 
     53    def test_dump(self): 
     54        """Test for dump() failing (OverflowError: math range error on math.exp) 
     55         on classifiers with high beta""" 
     56        quality = Orange.feature.Discrete('quality') 
     57        quality.add_value('low') 
     58        quality.add_value('high') 
     59        price = Orange.feature.Continuous('price') 
     60        variables = [price, quality] 
     61        matrix = [[0.01, 'high'], [0.001, 'low']] 
     62        domain = Orange.data.Domain(variables) 
     63        data = Orange.data.Table(domain, matrix) 
     64        classifier = LogRegLearner(data) 
     65        text_dump = dump(classifier) 
     66 
     67 
    5068if __name__ == "__main__": 
    5169    unittest.main() 
  • Orange/testing/unit/tests/test_table.py

    r10655 r11048  
    99    import unittest 
    1010from Orange.testing import testing 
     11 
    1112import Orange 
    1213import cPickle 
     14import tempfile 
     15import gc 
     16 
    1317 
    1418def native(table): 
     
    1822    return table 
    1923 
     24 
    2025def names_iter(): 
    2126    for name in testing.ALL_DATASETS: 
    2227        yield name.replace(" ", "_").replace("-", "_"), (name,) 
    2328 
     29 
    2430@testing.data_driven(data_iter=names_iter()) 
    2531class TestLoading(unittest.TestCase): 
     
    3036        """ 
    3137        table = Orange.data.Table(name) 
    32         self.assertIsNotNone(getattr(table, "attributeLoadStatus"), "No attributeLoadStatus") 
     38        self.assertIsNotNone(getattr(table, "attributeLoadStatus"), 
     39                             "No attributeLoadStatus") 
    3340 
    3441    @testing.test_on_data 
     
    4148#        self.assertEqual(table.domain, table_clone.domain) 
    4249#        self.assertEqual(table.domain.class_var, table_clone.domain.class_var) 
    43         self.assertEqual(native(table), native(table_clone), "Native representation is not equal!") 
    44          
    45      
    46  
    47  
    48 import tempfile 
     50        self.assertEqual(native(table), native(table_clone), 
     51                         "Native representation is not equal!") 
     52 
    4953 
    5054@testing.datasets_driven 
     
    6771            f.flush() 
    6872            data_arff = Orange.data.Table(f.name) 
     73 
    6974    @testing.test_on_datasets(datasets=testing.CLASSIFICATION_DATASETS + \ 
    7075                              testing.REGRESSION_DATASETS) 
     
    8792@testing.datasets_driven 
    8893class TestUnicodeFilenames(unittest.TestCase): 
    89      
     94 
    9095    @testing.test_on_data 
    9196    def test_tab_on(self, name): 
     
    97102            f.flush() 
    98103            table1 = Orange.data.Table(f.name) 
    99          
     104 
    100105    @testing.test_on_datasets(datasets=testing.CLASSIFICATION_DATASETS + \ 
    101106                              testing.REGRESSION_DATASETS) 
     
    108113            f.flush() 
    109114            table1 = Orange.data.Table(f.name) 
    110              
     115 
    111116    @testing.test_on_datasets(datasets=testing.CLASSIFICATION_DATASETS + \ 
    112117                              testing.REGRESSION_DATASETS) 
     
    119124            f.flush() 
    120125            table1 = Orange.data.Table(f.name) 
    121              
     126 
    122127    def test_basket(self): 
    123128        """ Test the loading and saving to/from unicode (utf-8) filenames. 
     
    156161 
    157162 
     163class TestDataOwnership(unittest.TestCase): 
     164    def test_clone(self): 
     165        """Test that `clone` method returns a table with it's own copy 
     166        of the data. 
     167 
     168        """ 
     169        iris = Orange.data.Table("iris") 
     170        clone = iris.clone() 
     171 
     172        self.assertTrue(iris.owns_instances and clone.owns_instances) 
     173        self.assertTrue(all(e1.reference() != e2.reference() 
     174                            for e1, e2 in zip(iris, clone))) 
     175 
     176        clone[0][0] = -1 
     177        self.assertTrue(iris[0][0] != clone[0][0]) 
     178 
     179        del clone 
     180        gc.collect() 
     181 
     182    def test_reference(self): 
     183        iris = Orange.data.Table("iris") 
     184 
     185        ref = Orange.data.Table(iris, True) 
     186 
     187        self.assertTrue(iris.owns_instances) 
     188        self.assertFalse(ref.owns_instances) 
     189 
     190        self.assertTrue(all(e1.reference() == e2.reference() 
     191                            for e1, e2 in zip(iris, ref))) 
     192 
     193        ref[0][0] = -1 
     194        self.assertEqual(iris[0][0], -1) 
     195 
     196        with self.assertRaises(TypeError): 
     197            ref.append( 
     198                Orange.data.Instance(ref.domain, 
     199                                     [0, 0, 0, 0, "Iris-setosa"]) 
     200            ) 
     201 
     202        del ref 
     203        gc.collect() 
     204 
     205 
    158206if __name__ == "__main__": 
    159207    unittest.main() 
  • Orange/utils/addons.py

    r11037 r11071  
    3131import platform 
    3232from collections import namedtuple, defaultdict 
     33from contextlib import closing 
    3334 
    3435import Orange.utils.environ 
     
    4748 
    4849AOLIST_FILE = os.path.join(Orange.utils.environ.orange_settings_dir, "addons.shelve") 
    49 try: 
    50     addons = shelve.open(AOLIST_FILE, 'c') 
    51     if any(name != name.lower() for name, record in addons.items()):  # Try to read the whole list and check for sanity. 
    52         raise Exception("Corrupted add-on list.") 
    53 except: 
    54     if os.path.isfile(AOLIST_FILE): 
    55         os.remove(AOLIST_FILE) 
    56     addons = shelve.open(AOLIST_FILE, 'n') 
    57  
    58 addons_corrupted = len(addons)==0 
     50def open_addons(): 
     51    try: 
     52        addons = shelve.open(AOLIST_FILE, 'c') 
     53        if any(name != name.lower() for name, record in addons.items()):  # Try to read the whole list and check for sanity. 
     54            raise Exception("Corrupted add-on list.") 
     55    except: 
     56        if os.path.isfile(AOLIST_FILE): 
     57            os.remove(AOLIST_FILE) 
     58        addons = shelve.open(AOLIST_FILE, 'n') 
     59    return addons 
     60 
     61global addons_corrupted 
     62with closing(open_addons()) as addons: 
     63    addons_corrupted = len(addons)==0 
    5964 
    6065addon_refresh_callback = [] 
     
    6671 
    6772    index = defaultdict(list) 
    68     for name, ao in addons.items(): 
    69         for s in [name, ao.summary, ao.description, ao.author] + (ao.keywords if ao.keywords else []): 
    70             if not s: 
    71                 continue 
    72             words = [word for word in re.split(INDEX_RE, s.lower()) 
    73                      if len(word)>1] 
    74             for word in words: 
    75                 for i in range(len(word)): 
    76                     index[word[:i+1]].append(name) 
     73    with closing(open_addons()) as addons: 
     74        for name, ao in addons.items(): 
     75            for s in [name, ao.summary, ao.description, ao.author] + (ao.keywords if ao.keywords else []): 
     76                if not s: 
     77                    continue 
     78                words = [word for word in re.split(INDEX_RE, s.lower()) 
     79                         if len(word)>1] 
     80                for word in words: 
     81                    for i in range(len(word)): 
     82                        index[word[:i+1]].append(name) 
    7783 
    7884def search_index(query): 
     
    8187    words = [word for word in re.split(INDEX_RE, query.lower()) if len(word)>1] 
    8288    if not words: 
    83         return addons.keys() 
     89        with closing(open_addons()) as addons: 
     90            return addons.keys() 
    8491    for word in words: 
    8592        result.update(index[word]) 
     
    104111        readthedocs = None 
    105112 
     113    global addons_corrupted 
    106114    docs = {} 
    107115    if progress_callback: 
    108116        progress_callback(len(pkg_dict)+1, 1) 
    109     for i, (name, (_, version)) in enumerate(pkg_dict.items()): 
    110         if force or name not in addons or addons[name.lower()].available_version != version: 
    111             try: 
    112                 data = pypi.release_data(name, version) 
    113                 rel = pypi.release_urls(name, version)[0] 
    114  
    115                 if readthedocs: 
    116                     try: 
    117                         docs = readthedocs.project.get(slug=name.lower())['objects'][0] 
    118                     except: 
    119                         docs = {} 
    120                 addons[name.lower()] = OrangeAddOn(name = name, 
    121                                            available_version = data['version'], 
    122                                            installed_version = addons[name.lower()].installed_version if name.lower() in addons else None, 
    123                                            summary = data['summary'], 
    124                                            description = data.get('description', ''), 
    125                                            author = str((data.get('author', '') or '') + ' ' + (data.get('author_email', '') or '')).strip(), 
    126                                            docs_url = data.get('docs_url', docs.get('subdomain', '')), 
    127                                            keywords = data.get('keywords', "").split(","), 
    128                                            homepage = data.get('home_page', ''), 
    129                                            package_url = data.get('package_url', ''), 
    130                                            release_url = rel.get('url', None), 
    131                                            release_size = rel.get('size', -1), 
    132                                            python_version = rel.get('python_version', None)) 
    133             except Exception, e: 
    134                 import traceback 
    135                 traceback.print_exc() 
    136                 warnings.warn('Could not load data for the following add-on: %s'%name) 
    137         if progress_callback: 
    138             progress_callback(len(pkg_dict)+1, i+2) 
    139     addons_corrupted = False 
    140     addons.sync() 
     117    with closing(open_addons()) as addons: 
     118        for i, (name, (_, version)) in enumerate(pkg_dict.items()): 
     119            if force or name not in addons or addons[name.lower()].available_version != version: 
     120                try: 
     121                    data = pypi.release_data(name, version) 
     122                    rel = pypi.release_urls(name, version)[0] 
     123 
     124                    if readthedocs: 
     125                        try: 
     126                            docs = readthedocs.project.get(slug=name.lower())['objects'][0] 
     127                        except: 
     128                            docs = {} 
     129                    addons[name.lower()] = OrangeAddOn(name = name, 
     130                                               available_version = data['version'], 
     131                                               installed_version = addons[name.lower()].installed_version if name.lower() in addons else None, 
     132                                               summary = data['summary'], 
     133                                               description = data.get('description', ''), 
     134                                               author = str((data.get('author', '') or '') + ' ' + (data.get('author_email', '') or '')).strip(), 
     135                                               docs_url = data.get('docs_url', docs.get('subdomain', '')), 
     136                                               keywords = data.get('keywords', "").split(","), 
     137                                               homepage = data.get('home_page', ''), 
     138                                               package_url = data.get('package_url', ''), 
     139                                               release_url = rel.get('url', None), 
     140                                               release_size = rel.get('size', -1), 
     141                                               python_version = rel.get('python_version', None)) 
     142                except Exception, e: 
     143                    import traceback 
     144                    traceback.print_exc() 
     145                    warnings.warn('Could not load data for the following add-on: %s'%name) 
     146            if progress_callback: 
     147                progress_callback(len(pkg_dict)+1, i+2) 
     148        addons_corrupted = False 
    141149 
    142150    rebuild_index() 
     
    144152def load_installed_addons(): 
    145153    found = set() 
    146     for entry_point in pkg_resources.iter_entry_points(ADDONS_ENTRY_POINT): 
    147         name, version = entry_point.dist.project_name, entry_point.dist.version 
    148         #TODO We could import setup.py from entry_point.location and load descriptions and such ... 
    149         if name.lower() in addons: 
    150             addons[name.lower()] = addons[name.lower()]._replace(installed_version = version) 
    151         else: 
    152             addons[name.lower()] = OrangeAddOn(name = name, 
    153                 available_version = None, 
    154                 installed_version = version, 
    155                 summary = "", 
    156                 description = "", 
    157                 author = "", 
    158                 docs_url = "", 
    159                 keywords = "", 
    160                 homepage = "", 
    161                 package_url = "", 
    162                 release_url = "", 
    163                 release_size = None, 
    164                 python_version = None) 
    165         found.add(name.lower()) 
    166     for name in set(addons).difference(found): 
    167         addons[name.lower()] = addons[name.lower()]._replace(installed_version = None) 
    168     addons.sync() 
     154    with closing(open_addons()) as addons: 
     155        for entry_point in pkg_resources.iter_entry_points(ADDONS_ENTRY_POINT): 
     156            name, version = entry_point.dist.project_name, entry_point.dist.version 
     157            #TODO We could import setup.py from entry_point.location and load descriptions and such ... 
     158            if name.lower() in addons: 
     159                addons[name.lower()] = addons[name.lower()]._replace(installed_version = version) 
     160            else: 
     161                addons[name.lower()] = OrangeAddOn(name = name, 
     162                    available_version = None, 
     163                    installed_version = version, 
     164                    summary = "", 
     165                    description = "", 
     166                    author = "", 
     167                    docs_url = "", 
     168                    keywords = "", 
     169                    homepage = "", 
     170                    package_url = "", 
     171                    release_url = "", 
     172                    release_size = None, 
     173                    python_version = None) 
     174            found.add(name.lower()) 
     175        for name in set(addons).difference(found): 
     176            addons[name.lower()] = addons[name.lower()]._replace(installed_version = None) 
    169177    rebuild_index() 
    170178 
     
    209217        import urllib 
    210218        rh = (lambda done, bs, fs: progress_callback(fs/bs, done)) if progress_callback else None 
    211         egg = urllib.urlretrieve(addons[name.lower()].release_url, reporthook=rh)[0] 
     219        with closing(open_addons()) as addons: 
     220            egg = urllib.urlretrieve(addons[name.lower()].release_url, reporthook=rh)[0] 
    212221    except Exception, e: 
    213222        raise Exception("Unable to download add-on from repository: %s" % e) 
     
    218227            egg_contents = tarfile.open(egg) 
    219228            egg_contents.extractall(tmpdir) 
    220             setup_py = os.path.join(tmpdir, name+'-'+addons[name.lower()].available_version, 'setup.py') 
     229            with closing(open_addons()) as addons: 
     230                setup_py = os.path.join(tmpdir, name+'-'+addons[name.lower()].available_version, 'setup.py') 
    221231        except Exception, e: 
    222232            raise Exception("Unable to unpack add-on: %s" % e) 
  • docs/conf.py

    r11043 r11049  
    4848sphinx.ext.autodoc.inspect = myinspect 
    4949numpydoc.docscrape.inspect = myinspect 
    50  
    5150module_setup = imp.load_source('module_setup', os.path.join(PATH, '..', 'setup.py')) 
    5251VERSION = module_setup.VERSION 
     
    6362# documentation root, use os.path.abspath to make it absolute, like shown here. 
    6463sys.path.append(os.path.abspath(os.path.join(PATH, ".."))) 
     64sys.path.append(os.path.abspath(os.path.join(PATH, "..", "Orange"))) 
    6565import Orange 
    6666 
     
    177177# relative to this directory. They are copied after the builtin static files, 
    178178# so a file named "default.css" will overwrite the builtin "default.css". 
    179 html_static_path = [] 
     179html_static_path = ["../Orange/doc/widgets"] 
    180180 
    181181# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 
  • docs/extend-widgets/rst/OrangeWidgets.plot.owcurve.rst

    r9917 r11049  
    1 .. automodule :: OrangeWidgets.plot.owcurve 
     1.. automodule :: Orange.OrangeWidgets.plot.owcurve 
  • docs/extend-widgets/rst/index.rst

    r9917 r11049  
    33########################## 
    44 
     5Writing widgets is fairly easy with the provided environment which 
     6does most of the GUI-related boring stuff. 
     7 
    58.. toctree:: 
    69   :maxdepth: 3 
    710 
     11   basics 
     12   settings 
     13   channels 
     14   progressbar 
     15   graphing 
     16   plotsbasic 
     17   plots 
     18   contextsettings 
     19 
     20`Code and icons <code.zip>`_ from the tutorial. To learn where to put Python 
     21files and icons, read :doc:`Getting Started <basics>`. 
     22 
     23 
     24********* 
     25Reference 
     26********* 
     27 
     28.. toctree:: 
     29   :maxdepth: 3 
     30 
     31   api 
     32   owgui 
    833   OrangeWidgets.plot 
    934 
  • docs/index.rst

    r11028 r11070  
    22==================== 
    33 
     4Visual programming: 
    45 
    5 Widget Catalog 
    6 -------------- 
     6- :doc:`Widget catalog <widgets/rst/index>` 
    77 
    8 :doc:`Widget catalog <widgets/rst/index>` contains descriptions of most widgets as they appear in the latest version of Orange. 
     8Python scripting: 
    99 
     10- :doc:`Tutorial <tutorial/rst/index>` 
     11- :doc:`Reference <reference/rst/index>` 
    1012 
    11 Scripting Documentation 
    12 ----------------------- 
     13Development documentation: 
    1314 
    14 A beginner should start with the :doc:`tutorial <tutorial/rst/index>`, which shows how to do simple stuff like loading data and constructing classifiers. 
    15  
    16 For everyday programming in Orange, use :doc:`reference <reference/rst/index>`. 
    17  
    18 If you would like to write new widgets you should also take a look at the :doc:`widget development manual <extend-widgets/rst/index>`. 
    19  
    20  
    21 Orange Development Documentation 
    22 -------------------------------- 
    23  
    24 For documentation about development of Orange itself, please see our wiki_. 
    25  
    26 .. _wiki: http://orange.biolab.si/trac/intertrac/ 
    27  
    28 Contents 
    29 -------- 
    30  
    31 .. toctree:: 
    32    :maxdepth: 1 
    33  
    34    widgets/rst/index 
    35    first-steps/rst/index 
    36    tutorial/rst/index 
    37    reference/rst/index 
    38    development/rst/index 
    39    extend-widgets/rst/index 
    40  
     15- :doc:`Widget development manual <extend-widgets/rst/index>` 
     16- `Wiki pages for developers <http://orange.biolab.si/trac>`_ 
    4117 
    4218Indices and tables 
  • docs/tutorial/rst/classification.rst

    r9994 r11058  
    33 
    44.. index:: classification 
    5 .. index:: supervised data mining 
     5.. index::  
     6   single: data mining; supervised 
    67 
    7 A substantial part of Orange is devoted to machine learning methods 
    8 for classification, or supervised data mining. These methods start 
    9 from the data that incorporates class-labeled instances, like 
    10 :download:`voting.tab <code/voting.tab>`:: 
     8Much of Orange is devoted to machine learning methods for classification, or supervised data mining. These methods rely on 
     9the data with class-labeled instances, like that of senate voting. Here is a code that loads this data set, displays the first data instance and shows its predicted class (``republican``):: 
    1110 
    12    >>> data = orange.ExampleTable("voting.tab") 
     11   >>> data = Orange.data.Table("voting") 
    1312   >>> data[0] 
    1413   ['n', 'y', 'n', 'y', 'y', 'y', 'n', 'n', 'n', 'y', '?', 'y', 'y', 'y', 'n', 'y', 'republican'] 
    15    >>> data[0].getclass() 
     14   >>> data[0].get_class() 
    1615   <orange.Value 'party'='republican'> 
    1716 
    18 Supervised data mining attempts to develop predictive models from such 
    19 data that, given the set of feature values, predict a corresponding 
    20 class. 
     17Learners and Classifiers 
     18------------------------ 
    2119 
    22 .. index:: classifiers 
    2320.. index:: 
    24    single: classifiers; naive Bayesian 
     21   single: classification; learner 
     22.. index:: 
     23   single: classification; classifier 
     24.. index:: 
     25   single: classification; naive Bayesian classifier 
    2526 
    26 There are two types of objects important for classification: learners 
    27 and classifiers. Orange has a number of build-in learners. For 
    28 instance, ``orange.BayesLearner`` is a naive Bayesian learner. When 
    29 data is passed to a learner (e.g., ``orange.BayesLearner(data))``, it 
    30 returns a classifier. When data instance is presented to a classifier, 
    31 it returns a class, vector of class probabilities, or both. 
     27Classification uses two types of objects: learners and classifiers. Learners consider class-labeled data and return a classifier. Given a data instance (a vector of feature values), classifiers return a predicted class:: 
    3228 
    33 A Simple Classifier 
    34 ------------------- 
     29    >>> import Orange 
     30    >>> data = Orange.data.Table("voting") 
     31    >>> learner = Orange.classification.bayes.NaiveLearner() 
     32    >>> classifier = learner(data) 
     33    >>> classifier(data[0]) 
     34    <orange.Value 'party'='republican'> 
    3535 
    36 Let us see how this works in practice. We will 
    37 construct a naive Bayesian classifier from voting data set, and 
    38 will use it to classify the first five instances from this data set 
    39 (:download:`classifier.py <code/classifier.py>`):: 
     36Above, we read the data, constructed a `naive Bayesian learner <http://en.wikipedia.org/wiki/Naive_Bayes_classifier>`_, gave it the data set to construct a classifier, and used it to predict the class of the first data item. We also use these concepts in the following code that predicts the classes of the first five instances in the data set: 
    4037 
    41    import orange 
    42    data = orange.ExampleTable("voting") 
    43    classifier = orange.BayesLearner(data) 
    44    for i in range(5): 
    45        c = classifier(data[i]) 
    46        print "original", data[i].getclass(), "classified as", c 
     38.. literalinclude: code/classification-classifier1.py 
     39   :lines: 4- 
    4740 
    48 The script loads the data, uses it to constructs a classifier using 
    49 naive Bayesian method, and then classifies first five instances of the 
    50 data set. Note that both original class and the class assigned by a 
    51 classifier is printed out. 
     41The script outputs:: 
    5242 
    53 The data set that we use includes votes for each of the U.S.  House of 
    54 Representatives Congressmen on the 16 key votes; a class is a 
    55 representative's party. There are 435 data instances - 267 democrats 
    56 and 168 republicans - in the data set (see UCI ML Repository and 
    57 voting-records data set for further description).  This is how our 
    58 classifier performs on the first five instances: 
     43    republican; originally republican 
     44    republican; originally republican 
     45    republican; originally democrat 
     46      democrat; originally democrat 
     47      democrat; originally democrat 
    5948 
    60    1: republican (originally republican) 
    61    2: republican (originally republican) 
    62    3: republican (originally democrat) 
    63    4: democrat (originally democrat) 
    64    5: democrat (originally democrat) 
     49Naive Bayesian classifier has made a mistake in the third instance, but otherwise predicted correctly. No wonder, since this was also the data it trained from. 
    6550 
    66 Naive Bayes made a mistake at a third instance, but otherwise predicted 
    67 correctly. 
    68  
    69 Obtaining Class Probabilities 
    70 ----------------------------- 
     51Probabilistic Classification 
     52---------------------------- 
    7153 
    7254To find out what is the probability that the classifier assigns 
    7355to, say, democrat class, we need to call the classifier with 
    74 additional parameter ``orange.GetProbabilities``. Also, note that the 
    75 democrats have a class index 1. We find this out with print 
    76 ``data.domain.classVar.values`` (:download:`classifier2.py <code/classifier2.py>`):: 
     56additional parameter that specifies the output type. If this is ``Orange.classification.Classifier.GetProbabilities``, the classifier will output class probabilities: 
    7757 
    78    import orange 
    79    data = orange.ExampleTable("voting") 
    80    classifier = orange.BayesLearner(data) 
    81    print "Possible classes:", data.domain.classVar.values 
    82    print "Probabilities for democrats:" 
    83    for i in range(5): 
    84        p = classifier(data[i], orange.GetProbabilities) 
    85        print "%d: %5.3f (originally %s)" % (i+1, p[1], data[i].getclass()) 
     58.. literalinclude: code/classification-classifier2.py 
     59   :lines: 4- 
    8660 
    87 The output of this script is:: 
     61The output of the script also shows how badly the naive Bayesian classifier missed the class for the thrid data item:: 
    8862 
    89    Possible classes: <republican, democrat> 
    90    Probabilities for democrats: 
    91    1: 0.000 (originally republican) 
    92    2: 0.000 (originally republican) 
    93    3: 0.005 (originally democrat) 
    94    4: 0.998 (originally democrat) 
    95    5: 0.957 (originally democrat) 
     63   Probabilities for democrat: 
     64   0.000; originally republican 
     65   0.000; originally republican 
     66   0.005; originally democrat 
     67   0.998; originally democrat 
     68   0.957; originally democrat 
    9669 
    97 The printout, for example, shows that with the third instance 
    98 naive Bayes has not only misclassified, but the classifier missed 
    99 quite substantially; it has assigned only a 0.005 probability to 
    100 the correct class. 
     70Cross-Validation 
     71---------------- 
    10172 
    102 .. note:: 
    103    Python list indexes start with 0. 
     73.. index:: cross-validation 
    10474 
    105 .. note:: 
    106    The ordering of class values depend on occurence of classes in the 
    107    input data set. 
     75Validating the accuracy of classifiers on the training data, as we did above, serves demonstration purposes only. Any performance measure that assess accuracy should be estimated on the independent test set. Such is also a procedure called `cross-validation <http://en.wikipedia.org/wiki/Cross-validation_(statistics)>`_, which averages performance estimates across several runs, each time considering a different training and test subsets as sampled from the original data set: 
    10876 
    109 Classification tree 
    110 ------------------- 
     77.. literalinclude: code/classification-cv.py 
     78   :lines: 3- 
    11179 
    112 .. index:: classifiers 
    11380.. index:: 
    114    single: classifiers; classification trees 
     81   single: classification; scoring 
     82.. index:: 
     83   single: classification; area under ROC 
     84.. index:: 
     85   single: classification; accuracy 
    11586 
    116 Classification tree learner (yes, this is the same *decision tree*) 
    117 is a native Orange learner, but because it is a rather 
    118 complex object that is for its versatility composed of a number of 
    119 other objects (for attribute estimation, stopping criterion, etc.), 
    120 a wrapper (module) called ``orngTree`` was build around it to simplify 
    121 the use of classification trees and to assemble the learner with 
    122 some usual (default) components. Here is a script with it (:download:`tree.py <code/tree.py>`):: 
     87Cross-validation is expecting a list of learners. The performance estimators also return a list of scores, one for every learner. There was just one learner in the script above, hence the list of size one was used. The script estimates classification accuracy and area under ROC curve. The later score is very high, indicating a very good performance of naive Bayesian learner on senate voting data set:: 
    12388 
    124    import orange, orngTree 
    125    data = orange.ExampleTable("voting") 
     89   Accuracy: 0.90 
     90   AUC:      0.97 
     91 
     92 
     93Handful of Classifiers 
     94---------------------- 
     95 
     96Orange includes wide range of classification algorithms, including: 
     97 
     98- logistic regression (``Orange.classification.logreg``) 
     99- k-nearest neighbors (``Orange.classification.knn``) 
     100- support vector machines (``Orange.classification.svm``) 
     101- classification trees (``Orange.classification.tree``) 
     102- classification rules (``Orange.classification.rules``) 
     103 
     104Some of these are included in the code that estimates the probability of a target class on a testing data. This time, training and test data sets are disjoint: 
     105 
     106.. index:: 
     107   single: classification; logistic regression 
     108.. index:: 
     109   single: classification; trees 
     110.. index:: 
     111   single: classification; k-nearest neighbors 
     112 
     113.. literalinclude: code/classification-other.py 
     114 
     115For these five data items, there are no major differences between predictions of observed classification algorithms:: 
     116 
     117   Probabilities for republican: 
     118   original class  tree      k-NN      lr        
     119   republican      0.949     1.000     1.000 
     120   republican      0.972     1.000     1.000 
     121   democrat        0.011     0.078     0.000 
     122   democrat        0.015     0.001     0.000 
     123   democrat        0.015     0.032     0.000 
     124 
     125The following code cross-validates several learners. Notice the difference between this and the code above. Cross-validation requires learners, while in the script above, learners were immediately given the data and the calls returned classifiers. 
     126 
     127.. literalinclude: code/classification-cv2.py 
     128 
     129Logistic regression wins in area under ROC curve:: 
     130 
     131            nbc  tree lr   
     132   Accuracy 0.90 0.95 0.94 
     133   AUC      0.97 0.94 0.99 
     134 
     135Reporting on Classification Models 
     136---------------------------------- 
     137 
     138Classification models are objects, exposing every component of its structure. For instance, one can traverse classification tree in code and observe the associated data instances, probabilities and conditions. It is often, however, sufficient, to provide textual output of the model. For logistic regression and trees, this is illustrated in the script below: 
     139 
     140.. literalinclude: code/classification-models.py 
     141 
     142   The logistic regression part of the output is: 
    126143    
    127    tree = orngTree.TreeLearner(data, sameMajorityPruning=1, mForPruning=2) 
    128    print "Possible classes:", data.domain.classVar.values 
    129    print "Probabilities for democrats:" 
    130    for i in range(5): 
    131        p = tree(data[i], orange.GetProbabilities) 
    132        print "%d: %5.3f (originally %s)" % (i+1, p[1], data[i].getclass()) 
     144   class attribute = survived 
     145   class values = <no, yes> 
     146 
     147         Feature       beta  st. error     wald Z          P OR=exp(beta) 
    133148    
    134    orngTree.printTxt(tree) 
     149       Intercept      -1.23       0.08     -15.15      -0.00 
     150    status=first       0.86       0.16       5.39       0.00       2.36 
     151   status=second      -0.16       0.18      -0.91       0.36       0.85 
     152    status=third      -0.92       0.15      -6.12       0.00       0.40 
     153       age=child       1.06       0.25       4.30       0.00       2.89 
     154      sex=female       2.42       0.14      17.04       0.00      11.25 
    135155 
    136 .. note::  
    137    The script for classification tree is almost the same as the one 
    138    for naive Bayes (:download:`classifier2.py <code/classifier2.py>`), except that we have imported 
    139    another module (``orngTree``) and used learner 
    140    ``orngTree.TreeLearner`` to build a classifier called ``tree``. 
     156Trees can also be rendered in `dot <http://en.wikipedia.org/wiki/DOT_language>`_:: 
    141157 
    142 .. note:: 
    143    For those of you that are at home with machine learning: the 
    144    default parameters for tree learner assume that a single example is 
    145    enough to have a leaf for it, gain ratio is used for measuring the 
    146    quality of attributes that are considered for internal nodes of the 
    147    tree, and after the tree is constructed the subtrees no pruning 
    148    takes place. 
     158   tree.dot(file_name="0.dot", node_shape="ellipse", leaf_shape="box") 
    149159 
    150 The resulting tree with default parameters would be rather big, so we 
    151 have additionally requested that leaves that share common predecessor 
    152 (node) are pruned if they classify to the same class, and requested 
    153 that tree is post-pruned using m-error estimate pruning method with 
    154 parameter m set to 2.0. The output of our script is:: 
    155  
    156    Possible classes: <republican, democrat> 
    157    Probabilities for democrats: 
    158    1: 0.051 (originally republican) 
    159    2: 0.027 (originally republican) 
    160    3: 0.989 (originally democrat) 
    161    4: 0.985 (originally democrat) 
    162    5: 0.985 (originally democrat) 
    163  
    164 Notice that all of the instances are classified correctly. The last 
    165 line of the script prints out the tree that was used for 
    166 classification:: 
    167  
    168    physician-fee-freeze=n: democrat (98.52%) 
    169    physician-fee-freeze=y 
    170    |    synfuels-corporation-cutback=n: republican (97.25%) 
    171    |    synfuels-corporation-cutback=y 
    172    |    |    mx-missile=n 
    173    |    |    |    el-salvador-aid=y 
    174    |    |    |    |    adoption-of-the-budget-resolution=n: republican (85.33%) 
    175    |    |    |    |    adoption-of-the-budget-resolution=y 
    176    |    |    |    |    |    anti-satellite-test-ban=n: democrat (99.54%) 
    177    |    |    |    |    |    anti-satellite-test-ban=y: republican (100.00%) 
    178    |    |    |    el-salvador-aid=n 
    179    |    |    |    |    handicapped-infants=n: republican (100.00%) 
    180    |    |    |    |    handicapped-infants=y: democrat (99.77%) 
    181    |    |    mx-missile=y 
    182    |    |    |    religious-groups-in-schools=y: democrat (99.54%) 
    183    |    |    |    religious-groups-in-schools=n 
    184    |    |    |    |    immigration=y: republican (98.63%) 
    185    |    |    |    |    immigration=n 
    186    |    |    |    |    |    handicapped-infants=n: republican (98.63%) 
    187    |    |    |    |    |    handicapped-infants=y: democrat (99.77%) 
    188  
    189 The printout includes the feature on which the tree branches in the 
    190 internal nodes. For leaves, it shows the the class label to which a 
    191 tree would make a classification. The probability of that class, as 
    192 estimated from the training data set, is also displayed. 
    193  
    194 If you are more of a *visual* type, you may like the graphical  
    195 presentation of the tree better. This was achieved by printing out a 
    196 tree in so-called dot file (the line of the script required for this 
    197 is ``orngTree.printDot(tree, fileName='tree.dot', 
    198 internalNodeShape="ellipse", leafShape="box")``), which was then 
    199 compiled to PNG using program called `dot`_. 
     160Following figure shows an example of such rendering. 
    200161 
    201162.. image:: files/tree.png 
    202163   :alt: A graphical presentation of a classification tree 
    203  
    204 .. _dot: http://graphviz.org/ 
    205  
    206 Nearest neighbors and majority classifiers 
    207 ------------------------------------------ 
    208  
    209 .. index:: classifiers 
    210 .. index::  
    211    single: classifiers; k nearest neighbours 
    212 .. index::  
    213    single: classifiers; majority classifier 
    214  
    215 Let us here check on two other classifiers. Majority classifier always 
    216 classifies to the majority class of the training set, and predicts  
    217 class probabilities that are equal to class distributions from the training 
    218 set. While being useless as such, it may often be good to compare this 
    219 simplest classifier to any other classifier you test &ndash; if your 
    220 other classifier is not significantly better than majority classifier, 
    221 than this may a reason to sit back and think. 
    222  
    223 The second classifier we are introducing here is based on k-nearest 
    224 neighbors algorithm, an instance-based method that finds k examples 
    225 from training set that are most similar to the instance that has to be 
    226 classified. From the set it obtains in this way, it estimates class 
    227 probabilities and uses the most frequent class for prediction. 
    228  
    229 The following script takes naive Bayes, classification tree (what we 
    230 have already learned), majority and k-nearest neighbors classifier 
    231 (new ones) and prints prediction for first 10 instances of voting data 
    232 set (:download:`handful.py <code/handful.py>`):: 
    233  
    234    import orange, orngTree 
    235    data = orange.ExampleTable("voting") 
    236     
    237    # setting up the classifiers 
    238    majority = orange.MajorityLearner(data) 
    239    bayes = orange.BayesLearner(data) 
    240    tree = orngTree.TreeLearner(data, sameMajorityPruning=1, mForPruning=2) 
    241    knn = orange.kNNLearner(data, k=21) 
    242     
    243    majority.name="Majority"; bayes.name="Naive Bayes"; 
    244    tree.name="Tree"; knn.name="kNN" 
    245     
    246    classifiers = [majority, bayes, tree, knn] 
    247     
    248    # print the head 
    249    print "Possible classes:", data.domain.classVar.values 
    250    print "Probability for republican:" 
    251    print "Original Class", 
    252    for l in classifiers: 
    253        print "%-13s" % (l.name), 
    254    print 
    255     
    256    # classify first 10 instances and print probabilities 
    257    for example in data[:10]: 
    258        print "(%-10s)  " % (example.getclass()), 
    259        for c in classifiers: 
    260            p = apply(c, [example, orange.GetProbabilities]) 
    261            print "%5.3f        " % (p[0]), 
    262        print 
    263  
    264 The code is somehow long, due to our effort to print the results 
    265 nicely. The first part of the code sets-up our four classifiers, and 
    266 gives them names. Classifiers are then put into the list denoted with 
    267 variable ``classifiers`` (this is nice since, if we would need to add 
    268 another classifier, we would just define it and put it in the list, 
    269 and for the rest of the code we would not worry about it any 
    270 more). The script then prints the header with the names of the 
    271 classifiers, and finally uses the classifiers to compute the 
    272 probabilities of classes. Note for a special function ``apply`` that 
    273 we have not met yet: it simply calls a function that is given as its 
    274 first argument, and passes it the arguments that are given in the 
    275 list. In our case, ``apply`` invokes our classifiers with a data 
    276 instance and request to compute probabilities. The output of our 
    277 script is:: 
    278  
    279    Possible classes: <republican, democrat> 
    280    Probability for republican: 
    281    Original Class Majority      Naive Bayes   Tree          kNN 
    282    (republican)   0.386         1.000         0.949         1.000 
    283    (republican)   0.386         1.000         0.973         1.000 
    284    (democrat  )   0.386         0.995         0.011         0.138 
    285    (democrat  )   0.386         0.002         0.015         0.468 
    286    (democrat  )   0.386         0.043         0.015         0.035 
    287    (democrat  )   0.386         0.228         0.015         0.442 
    288    (democrat  )   0.386         1.000         0.973         0.977 
    289    (republican)   0.386         1.000         0.973         1.000 
    290    (republican)   0.386         1.000         0.973         1.000 
    291    (democrat  )   0.386         0.000         0.015         0.000 
    292  
    293 .. note:: 
    294    The prediction of majority class classifier does not depend on the 
    295    instance it classifies (of course!). 
    296  
    297 .. note::  
    298    At this stage, it would be inappropriate to say anything conclusive 
    299    on the predictive quality of the classifiers - for this, we will 
    300    need to resort to statistical methods on comparison of 
    301    classification models. 
  • docs/tutorial/rst/ensembles.rst

    r9994 r11058  
    11.. index:: ensembles 
     2 
     3Ensembles 
     4========= 
     5 
     6`Learning of ensembles <http://en.wikipedia.org/wiki/Ensemble_learning>`_ combines the predictions of separate models to gain in accuracy. The models may come from different training data samples, or may use different learners on the same data sets. Learners may also be diversified by changing their parameter sets. 
     7 
     8In Orange, ensembles are simply wrappers around learners. They behave just like any other learner. Given the data, they return models that can predict the outcome for any data instance:: 
     9 
     10   >>> import Orange 
     11   >>> data = Orange.data.Table("housing") 
     12   >>> tree = Orange.classification.tree.TreeLearner() 
     13   >>> btree = Orange.ensemble.bagging.BaggedLearner(tree) 
     14   >>> btree 
     15   BaggedLearner 'Bagging' 
     16   >>> btree(data) 
     17   BaggedClassifier 'Bagging' 
     18   >>> btree(data)(data[0]) 
     19   <orange.Value 'MEDV'='24.6'> 
     20 
     21The last line builds a predictor (``btree(data)``) and then uses it on a first data instance. 
     22 
     23Most ensemble methods can wrap either classification or regression learners. Exceptions are task-specialized techniques such as boosting. 
     24 
     25Bagging and Boosting 
     26-------------------- 
     27 
    228.. index::  
    329   single: ensembles; bagging 
     30 
     31`Bootstrap aggregating <http://en.wikipedia.org/wiki/Bootstrap_aggregating>`_, or bagging, samples the training data uniformly and with replacement to train different predictors. Majority vote (classification) or mean (regression) across predictions then combines independent predictions into a single prediction.  
     32 
    433.. index::  
    534   single: ensembles; boosting 
    635 
    7 Ensemble learners 
    8 ================= 
     36In general, boosting is a technique that combines weak learners into a single strong learner. Orange implements `AdaBoost <http://en.wikipedia.org/wiki/AdaBoost>`_, which assigns weights to data instances according to performance of the learner. AdaBoost uses these weights to iteratively sample the instances to focus on those that are harder to classify. In the aggregation AdaBoost emphases individual classifiers with better performance on their training sets. 
    937 
    10 Building ensemble classifiers in Orange is simple and easy. Starting 
    11 from learners/classifiers that can predict probabilities and, if 
    12 needed, use example weights, ensembles are actually wrappers that can 
    13 aggregate predictions from a list of constructed classifiers. These 
    14 wrappers behave exactly like other Orange learners/classifiers. We 
    15 will here first show how to use a module for bagging and boosting that 
    16 is included in Orange distribution (:py:mod:`Orange.ensemble` module), and 
    17 then, for a somehow more advanced example build our own ensemble 
    18 learner. Using this module, using it is very easy: you have to define 
    19 a learner, give it to bagger or booster, which in turn returns a new 
    20 (boosted or bagged) learner. Here goes an example (:download:`ensemble3.py <code/ensemble3.py>`):: 
     38The following script wraps a classification tree in boosted and bagged learner, and tests the three learner through cross-validation: 
    2139 
    22    import orange, orngTest, orngStat, orngEnsemble 
    23    data = orange.ExampleTable("promoters") 
    24     
    25    majority = orange.MajorityLearner() 
    26    majority.name = "default" 
    27    knn = orange.kNNLearner(k=11) 
    28    knn.name = "k-NN (k=11)" 
    29     
    30    bagged_knn = orngEnsemble.BaggedLearner(knn, t=10) 
    31    bagged_knn.name = "bagged k-NN" 
    32    boosted_knn = orngEnsemble.BoostedLearner(knn, t=10) 
    33    boosted_knn.name = "boosted k-NN" 
    34     
    35    learners = [majority, knn, bagged_knn, boosted_knn] 
    36    results = orngTest.crossValidation(learners, data, folds=10) 
    37    print "        Learner   CA     Brier Score" 
    38    for i in range(len(learners)): 
    39        print ("%15s:  %5.3f  %5.3f") % (learners[i].name, 
    40            orngStat.CA(results)[i], orngStat.BrierScore(results)[i]) 
     40.. literalinclude:: code/ensemble-bagging.py 
    4141 
    42 Most of the code is used for defining and naming objects that learn, 
    43 and the last piece of code is to report evaluation results. Notice 
    44 that to bag or boost a learner, it takes only a single line of code 
    45 (like, ``bagged_knn = orngEnsemble.BaggedLearner(knn, t=10)``)! 
    46 Parameter ``t`` in bagging and boosting refers to number of 
    47 classifiers that will be used for voting (or, if you like better, 
    48 number of iterations by boosting/bagging). Depending on your random 
    49 generator, you may get something like:: 
     42The benefit of the two ensembling techniques, assessed in terms of area under ROC curve, is obvious:: 
    5043 
    51            Learner   CA     Brier Score 
    52            default:  0.473  0.501 
    53        k-NN (k=11):  0.859  0.240 
    54        bagged k-NN:  0.813  0.257 
    55       boosted k-NN:  0.830  0.244 
     44    tree: 0.83 
     45   boost: 0.90 
     46    bagg: 0.91 
    5647 
     48Stacking 
     49-------- 
    5750 
     51.. index::  
     52   single: ensembles; stacking 
     53 
     54Consider we partition a training set into held-in and held-out set. Assume that our taks is prediction of y, either probability of the target class in classification or a real value in regression. We are given a set of learners. We train them on held-in set, and obtain a vector of prediction on held-out set. Each element of the vector corresponds to prediction of individual predictor. We can now learn how to combine these predictions to form a target prediction, by training a new predictor on a data set of predictions and true value of y in held-out set. The technique is called `stacked generalization <http://en.wikipedia.org/wiki/Ensemble_learning#Stacking>`_, or in short stacking. Instead of a single split to held-in and held-out data set, the vectors of predictions are obtained through cross-validation. 
     55 
     56Orange provides a wrapper for stacking that is given a set of base learners and a meta learner: 
     57 
     58.. literalinclude:: code/ensemble-stacking.py 
     59   :lines: 3- 
     60 
     61By default, the meta classifier is naive Bayesian classifier. Changing this to logistic regression may be a good idea as well:: 
     62 
     63    stack = Orange.ensemble.stacking.StackedClassificationLearner(base_learners, \ 
     64               meta_learner=Orange.classification.logreg.LogRegLearner) 
     65 
     66Stacking is often better than each of the base learners alone, as also demonstrated by running our script:: 
     67 
     68   stacking: 0.967 
     69      bayes: 0.933 
     70       tree: 0.836 
     71        knn: 0.947 
     72 
     73Random Forests 
     74-------------- 
     75 
     76.. index::  
     77   single: ensembles; random forests 
     78 
     79`Random forest <http://en.wikipedia.org/wiki/Random_forest>`_ ensembles tree predictors. The diversity of trees is achieved in randomization of feature selection for node split criteria, where instead of the best feature one is picked arbitrary from a set of best features. Another source of randomization is a bootstrap sample of data from which the threes are developed. Predictions from usually several hundred trees are aggregated by voting. Constructing so many trees may be computationally demanding. Orange uses a special tree inducer (Orange.classification.tree.SimpleTreeLearner, considered by default) optimized for speed in random forest construction:  
     80 
     81.. literalinclude:: code/ensemble-forest.py 
     82   :lines: 3- 
     83 
     84Random forests are often superior when compared to other base classification or regression learners:: 
     85 
     86   forest: 0.976 
     87    bayes: 0.935 
     88      knn: 0.952 
  • docs/tutorial/rst/index.rst

    r9386 r11059  
    33############### 
    44 
    5 If you are new to Orange, then this is probably the best place to start. This 
    6 tutorial was written with a purpose to provide a gentle tutorial over basic 
    7 functionality of Orange. The tutorial includes: 
     5This is a gentle introduction on scripting in Orange. Orange is a  `Python <http://www.python.org/>`_ library, and the tutorial is a guide through Orange scripting in this language. 
    86 
    9 As Orange is integrated within `Python <http://www.python.org/>`_, the tutorial 
    10 is in essence a guide through some basic Orange scripting in this language. 
    11 Although relying on Python, those of you who have some knowledge on programming 
    12 won't need to learn Python first: the tutorial should be simple enough to skip 
    13 learning Python itself. 
     7We here assume you have already `downloaded and installed Orange <http://orange.biolab.si/download/>`_ and have a working version of Python. Python scripts can run in a terminal window, integrated environments like `PyCharm <http://www.jetbrains.com/pycharm/>`_ and `PythonWin <http://wiki.python.org/moin/PythonWin>`_, 
     8or shells like `iPython <http://ipython.scipy.org/moin/>`_. Whichever environment you are using, try now to import Orange. Below, we used a Python shell:: 
    149 
    15 Contents: 
     10   % python 
     11   >>> import Orange 
     12   >>> Orange.version.version 
     13   '2.6a2.dev-a55510d' 
     14   >>> 
     15 
     16If this leaves no error and warning, Orange and Python are properly 
     17installed and you are ready to continue with this Tutorial. 
     18 
     19******** 
     20Contents 
     21******** 
    1622 
    1723.. toctree:: 
    1824   :maxdepth: 1 
    1925 
    20    start.rst 
    21    load-data.rst 
    22    basic-exploration.rst 
     26   data.rst 
    2327   classification.rst 
    24    evaluation.rst 
    25    learners-in-python.rst 
    2628   regression.rst 
    27    association-rules.rst 
    28    feature-subset-selection.rst 
    2929   ensembles.rst 
    30    discretization.rst 
     30   python-learners.rst 
    3131 
    3232**************** 
    33 Index and search 
     33Index and Search 
    3434**************** 
    3535 
  • docs/tutorial/rst/regression.rst

    r9385 r11058  
    1 .. index:: regression 
    2  
    31Regression 
    42========== 
    53 
    6 At the time of writing of this part of tutorial, there were 
    7 essentially two different learning methods for regression modelling: 
    8 regression trees and instance-based learner (k-nearest neighbors). In 
    9 this lesson, we will see that using regression is just like using 
    10 classifiers, and evaluation techniques are not much different either. 
     4.. index:: regression 
     5 
     6From the interface point of view, regression methods in Orange are very similar to classification. Both intended for supervised data mining, they require class-labeled data. Just like in classification, regression is implemented with learners and regression models (regressors). Regression learners are objects that accept data and return regressors. Regression models are given data items to predict the value of continuous class: 
     7 
     8.. literalinclude:: code/regression.py 
     9 
     10 
     11Handful of Regressors 
     12--------------------- 
    1113 
    1214.. index:: 
    13    single: regression; regression trees 
     15   single: regression; tree 
    1416 
    15 Few simple regressors 
    16 --------------------- 
     17Let us start with regression trees. Below is an example script that builds the tree from data on housing prices and prints out the tree in textual form: 
    1718 
    18 Let us start with regression trees. Below is an example script that builds 
    19 the tree from :download:`housing.tab <code/housing.tab>` data set and prints 
    20 out the tree in textual form (:download:`regression1.py <code/regression1.py>`):: 
     19.. literalinclude:: code/regression-tree.py 
     20   :lines: 3- 
    2121 
    22    import orange, orngTree 
     22The script outputs the tree:: 
    2323    
    24    data = orange.ExampleTable("housing.tab") 
    25    rt = orngTree.TreeLearner(data, measure="retis", mForPruning=2, minExamples=20) 
    26    orngTree.printTxt(rt, leafStr="%V %I") 
    27     
    28 Notice special setting for attribute evaluation measure! Following is 
    29 the output of this script:: 
    30     
    31    RM<6.941: 19.9 [19.333-20.534] 
    32    RM>=6.941 
    33    |    RM<7.437 
    34    |    |    CRIM>=7.393: 14.4 [10.172-18.628] 
    35    |    |    CRIM<7.393 
    36    |    |    |    DIS<1.886: 45.7 [37.124-54.176] 
    37    |    |    |    DIS>=1.886: 32.7 [31.656-33.841] 
    38    |    RM>=7.437 
    39    |    |    TAX<534.500: 45.9 [44.295-47.498] 
    40    |    |    TAX>=534.500: 21.9 [21.900-21.900] 
     24   RM<=6.941: 19.9 
     25   RM>6.941 
     26   |    RM<=7.437 
     27   |    |    CRIM>7.393: 14.4 
     28   |    |    CRIM<=7.393 
     29   |    |    |    DIS<=1.886: 45.7 
     30   |    |    |    DIS>1.886: 32.7 
     31   |    RM>7.437 
     32   |    |    TAX<=534.500: 45.9 
     33   |    |    TAX>534.500: 21.9 
     34 
     35Following is initialization of few other regressors and their prediction of the first five data instances in housing price data set: 
    4136 
    4237.. index:: 
    43    single: regression; k nearest neighbours 
     38   single: regression; mars 
     39   single: regression; linear 
    4440 
    45 Predicting continues classes is just like predicting crisp ones. In 
    46 this respect, the following script will be nothing new. It uses both 
    47 regression trees and k-nearest neighbors, and also uses a majority 
    48 learner which for regression simply returns an average value from 
    49 learning data set (:download:`regression2.py <code/regression2.py>`):: 
     41.. literalinclude:: code/regression-other.py 
     42   :lines: 3- 
    5043 
    51    import orange, orngTree, orngTest, orngStat 
    52     
    53    data = orange.ExampleTable("housing.tab") 
    54    selection = orange.MakeRandomIndices2(data, 0.5) 
    55    train_data = data.select(selection, 0) 
    56    test_data = data.select(selection, 1) 
    57     
    58    maj = orange.MajorityLearner(train_data) 
    59    maj.name = "default" 
    60     
    61    rt = orngTree.TreeLearner(train_data, measure="retis", mForPruning=2, minExamples=20) 
    62    rt.name = "reg. tree" 
    63     
    64    k = 5 
    65    knn = orange.kNNLearner(train_data, k=k) 
    66    knn.name = "k-NN (k=%i)" % k 
    67     
    68    regressors = [maj, rt, knn] 
    69     
    70    print "\n%10s " % "original", 
    71    for r in regressors: 
    72      print "%10s " % r.name, 
    73    print 
    74     
    75    for i in range(10): 
    76      print "%10.1f " % test_data[i].getclass(), 
    77      for r in regressors: 
    78        print "%10.1f " % r(test_data[i]), 
    79      print 
     44Looks like the housing prices are not that hard to predict:: 
    8045 
    81 The otput of this script is:: 
     46   y    lin  mars tree 
     47   21.4 24.8 23.0 20.1 
     48   15.7 14.4 19.0 17.3 
     49   36.5 35.7 35.6 33.8 
    8250 
    83      original     default   reg. tree  k-NN (k=5) 
    84          24.0        50.0        25.0        24.6 
    85          21.6        50.0        25.0        22.0 
    86          34.7        50.0        35.4        26.6 
    87          28.7        50.0        25.0        36.2 
    88          27.1        50.0        21.7        18.9 
    89          15.0        50.0        21.7        18.9 
    90          18.9        50.0        21.7        18.9 
    91          18.2        50.0        21.7        21.0 
    92          17.5        50.0        21.7        16.6 
    93          20.2        50.0        21.7        23.1 
     51Cross Validation 
     52---------------- 
    9453 
    95 .. index: mean squared error 
     54Just like for classification, the same evaluation module (``Orange.evaluation``) is available for regression. Its testing submodule includes procedures such as cross-validation, leave-one-out testing and similar, and functions in scoring submodule can assess the accuracy from the testing: 
    9655 
    97 Evaluation and scoring 
    98 ---------------------- 
     56.. literalinclude:: code/regression-other.py 
     57   :lines: 3- 
    9958 
    100 For our third and last example for regression, let us see how we can 
    101 use cross-validation testing and for a score function use 
    102 (:download:`regression3.py <code/regression3.py>`, uses `housing.tab <code/housing.tab>`):: 
     59.. index:  
     60   single: regression; root mean squared error 
    10361 
    104    import orange, orngTree, orngTest, orngStat 
    105     
    106    data = orange.ExampleTable("housing.tab") 
    107     
    108    maj = orange.MajorityLearner() 
    109    maj.name = "default" 
    110    rt = orngTree.TreeLearner(measure="retis", mForPruning=2, minExamples=20) 
    111    rt.name = "regression tree" 
    112    k = 5 
    113    knn = orange.kNNLearner(k=k) 
    114    knn.name = "k-NN (k=%i)" % k 
    115    learners = [maj, rt, knn] 
    116     
    117    data = orange.ExampleTable("housing.tab") 
    118    results = orngTest.crossValidation(learners, data, folds=10) 
    119    mse = orngStat.MSE(results) 
    120     
    121    print "Learner        MSE" 
    122    for i in range(len(learners)): 
    123      print "%-15s %5.3f" % (learners[i].name, mse[i]) 
     62`MARS <http://en.wikipedia.org/wiki/Multivariate_adaptive_regression_splines>`_ has the lowest root mean squared error:: 
    12463 
    125 Again, compared to classification tasks, this is nothing new. The only 
    126 news in the above script is a mean squared error evaluation function 
    127 (``orngStat.MSE``). The scripts prints out the following report:: 
     64   Learner  RMSE 
     65   lin      4.83 
     66   mars     3.84 
     67   tree     5.10 
    12868 
    129    Learner        MSE 
    130    default         84.777 
    131    regression tree 40.096 
    132    k-NN (k=5)      17.532 
    133  
    134 Other scoring techniques are available to evaluate the success of 
    135 regression. Script below uses a range of them, plus features a nice 
    136 implementation where a list of scoring techniques is defined 
    137 independetly from the code that reports on the results (part of 
    138 :download:`regression4.py <code/regression4.py>`):: 
    139  
    140    lr = orngRegression.LinearRegressionLearner(name="lr") 
    141    rt = orngTree.TreeLearner(measure="retis", mForPruning=2, 
    142                              minExamples=20, name="rt") 
    143    maj = orange.MajorityLearner(name="maj") 
    144    knn = orange.kNNLearner(k=10, name="knn") 
    145    learners = [maj, lr, rt, knn] 
    146     
    147    # evaluation and reporting of scores 
    148    results = orngTest.learnAndTestOnTestData(learners, train, test) 
    149    scores = [("MSE", orngStat.MSE), 
    150              ("RMSE", orngStat.RMSE), 
    151              ("MAE", orngStat.MAE), 
    152              ("RSE", orngStat.RSE), 
    153              ("RRSE", orngStat.RRSE), 
    154              ("RAE", orngStat.RAE), 
    155              ("R2", orngStat.R2)] 
    156     
    157    print "Learner  " + "".join(["%-7s" % s[0] for s in scores]) 
    158    for i in range(len(learners)): 
    159        print "%-8s " % learners[i].name + "".join(["%6.3f " % s[1](results)[i] for s in scores]) 
    160  
    161 Here, we used a number of different scores, including: 
    162  
    163 * MSE - mean squared errror, 
    164 * RMSE - root mean squared error, 
    165 * MAE - mean absolute error, 
    166 * RSE - relative squared error, 
    167 * RRSE - root relative squared error, 
    168 * RAE - relative absolute error, and 
    169 * R2 - coefficient of determinatin, also referred to as R-squared. 
    170  
    171 For precise definition of these measures, see :py:mod:`Orange.statistics`. Running 
    172 the script above yields:: 
    173  
    174    Learner  MSE    RMSE   MAE    RSE    RRSE   RAE    R2 
    175    maj      84.777  9.207  6.659  1.004  1.002  1.002 -0.004 
    176    lr       23.729  4.871  3.413  0.281  0.530  0.513  0.719 
    177    rt       40.096  6.332  4.569  0.475  0.689  0.687  0.525 
    178    knn      17.244  4.153  2.670  0.204  0.452  0.402  0.796 
    179  
  • docs/widgets/rst/data/file.rst

    r11028 r11050  
    44==== 
    55 
    6 .. image:: images/File_icon.png 
     6.. image:: ../../../../Orange/OrangeWidgets/Data/icons/File_48.png 
    77   :alt: File widget icon 
    88    
     
    6060Any of your schemas should probably start with the :ref:`File` widget. In the schema below, 
    6161the widget is used to read the data that is then sent to both :ref:`Data Table` widget and  
    62 to widget that displays `Attribute Statistics`_. 
     62to widget that displays :ref:`Attribute Statistics`. 
    6363 
    6464.. image:: images/File_schema.png 
  • docs/widgets/rst/index.rst

    r10843 r11050  
    1717      - |DataTable_icon| :ref:`Data Table` 
    1818      - |SelectAttributes_icon| :ref:`Select Attributes` 
    19     * - |Rank_icon| `Rank`_ 
    20       - |PurgeDomain_icon| `Purge Domain`_ 
    21       - |MergeData_icon| `Merge Data`_ 
    22     * - |Concat_icon| `Concatenate`_ 
    23       - |DataSampler_icon| `Data Sampler`_ 
    24       - |SelectData_icon| `Select Data`_ 
    25     * - |Save_icon| `Save`_ 
    26       - |Discretize_icon| `Discretize`_ 
    27       - |Cont_icon| `Continuize`_ 
    28     * - |Impute_icon| `Impute`_ 
    29       - |Outliers_icon| `Outliers`_ 
     19    * - |Rank_icon| :ref:`Rank` 
     20      - |PurgeDomain_icon| :ref:`Purge Domain` 
     21      - |MergeData_icon| :ref:`Merge Data` 
     22    * - |Concat_icon| :ref:`Concatenate` 
     23      - |DataSampler_icon| :ref:`Data Sampler` 
     24      - |SelectData_icon| :ref:`Select Data` 
     25    * - |Save_icon| :ref:`Save` 
     26      - |Discretize_icon| :ref:`Discretize` 
     27      - |Cont_icon| :ref:`Continuize` 
     28    * - |Impute_icon| :ref:`Impute` 
     29      - |Outliers_icon| :ref:`Outliers` 
    3030      - 
    3131 
    32 .. _`Rank`: _static/Data/Rank.htm 
    33  
    34 .. _`Purge Domain`: _static/Data/PurgeDomain.htm 
    35  
    36 .. _`Merge Data`: _static/Data/MergeData.htm 
    37  
    38 .. _`Concatenate`: _static/Data/Concatenate.htm 
    39  
    40 .. _`Data Sampler`: _static/Data/DataSampler.htm 
    41  
    42 .. _`Select Data`: _static/Data/SelectData.htm 
    43  
    44 .. _`Save`: _static/Data/Save.htm 
    45  
    46 .. _`Discretize`: _static/Data/Discretize.htm 
    47  
    48 .. _`Continuize`: _static/Data/Continuize.htm 
    49  
    50 .. _`Impute`: _static/Data/Impute.htm 
    51  
    52 .. _`Outliers`: _static/Data/Outliers.htm 
    53  
    54  
    55 .. |File_icon| image:: data/images/File_icon.png 
     32.. |File_icon| image:: ../../../Orange/OrangeWidgets/Data/icons/File_48.png 
    5633    :align: middle 
    5734    :alt: File 
     
    5936    :height: 48 
    6037 
    61 .. |DataTable_icon| image:: data/images/DataTable_icon.png 
     38.. |DataTable_icon| image:: ../../../Orange/OrangeWidgets/Data/icons/DataTable_48.png 
    6239    :align: middle 
    6340    :alt: Data Table 
     
    6542    :height: 48 
    6643     
    67 .. |SelectAttributes_icon| image:: data/images/SelectAttributes_icon.png 
     44.. |SelectAttributes_icon| image:: ../../../Orange/OrangeWidgets/Data/icons/SelectAttributes_48.png 
    6845    :align: middle 
    6946    :alt: Select Attributes 
     
    145122    :widths: 1 1 1 
    146123     
    147     * - |Distributions_icon| `Distributions`_ 
    148       - |ScatterPlot_icon| `Scatter Plot`_ 
    149       - |AttributeStatistics_icon| `Attribute Statistics`_ 
    150     * - |LinearProjection_icon| `Linear Projection`_ 
    151       - |Radviz_icon| `Radviz`_ 
    152       - |Polyviz_icon| `Polyviz`_ 
    153     * - |ParallelCoords_icon| `Parallel Coordinates`_ 
    154       - |SurveyPlot_icon| `Survey Plot`_ 
    155       - |MosaicDisplay_icon| `Mosaic Display`_ 
    156     * - |SieveDiagram_icon| `Sieve Diagram`_ 
     124    * - |Distributions_icon| :ref:`Distributions` 
     125      - |ScatterPlot_icon| :ref:`Scatter Plot` 
     126      - |AttributeStatistics_icon| :ref:`Attribute Statistics` 
     127    * - |LinearProjection_icon| :ref:`Linear Projection` 
     128      - |Radviz_icon| :ref:`Radviz` 
     129      - |Polyviz_icon| :ref:`Polyviz` 
     130    * - |ParallelCoords_icon| :ref:`Parallel Coordinates` 
     131      - |SurveyPlot_icon| :ref:`Survey Plot` 
     132      - |MosaicDisplay_icon| :ref:`Mosaic Display` 
     133    * - |SieveDiagram_icon| :ref:`Sieve Diagram` 
    157134      - |SieveMultigram_icon| Sieve Multigram  
    158135      - 
    159      
    160 .. _`Distributions`: _static/Visualize/Distributions.htm 
    161  
    162 .. _`Scatter Plot`: _static/Visualize/Scatterplot.htm 
    163  
    164 .. _`Attribute Statistics`: _static/Visualize/AttributeStatistics.htm 
    165  
    166 .. _`Linear Projection`: _static/Visualize/LinearProjection.htm 
    167  
    168 .. _`Radviz`: _static/Visualize/Radviz.htm 
    169  
    170 .. _`Polyviz`: _static/Visualize/Polyviz.htm 
    171  
    172 .. _`Parallel Coordinates`: _static/Visualize/ParallelCoordinates.htm 
    173  
    174 .. _`Survey Plot`: _static/Visualize/SurveyPlot.htm 
    175  
    176 .. _`Mosaic Display`: _static/Visualize/MosaicDisplay.htm 
    177  
    178 .. _`Sieve Diagram`: _static/Visualize/SieveDiagram.htm 
    179  
    180136 
    181137.. |Distributions_icon| image:: ../../../Orange/OrangeWidgets/Visualize/icons/Distribution_48.png 
     
    253209    :widths: 1 1 1 
    254210     
    255     * - |NaiveBayes_icon| `Naive Bayes`_ 
    256       - |SVM_icon| `SVM`_ 
    257       - |LogReg_icon| `Logistic Regression`_ 
    258     * - |Majority_icon| `Majority`_ 
    259       - |ClassificationTree_icon| `Classification Tree`_ 
    260       - |ClassificationTreeGraph_icon| `Classification Tree Graph`_  
    261     * - |ClsTreeViewer_icon| `Classification Tree Viewer`_ 
    262       - |CN2Rules_icon| `CN2 Rules`_ 
    263       - |CN2RulesViewer_icon| `CN2 Rules Viewer`_ 
    264     * - |kNN_icon| `k-Nearest Neighbours`_ 
    265       - |Nomogram_icon| `Nomogram`_ 
    266       - |RandomForest_icon| `Random Forest`_ 
    267     * - |C4.5_icon| `C4.5`_ 
    268       - |ITreeBuilder_icon| `Interactive Tree Builder`_ 
     211    * - |NaiveBayes_icon| :ref:`Naive Bayes` 
     212      - |SVM_icon| :ref:`SVM` 
     213      - |LogReg_icon| :ref:`Logistic Regression` 
     214    * - |Majority_icon| :ref:`Majority` 
     215      - |ClassificationTree_icon| :ref:`Classification Tree` 
     216      - |ClassificationTreeGraph_icon| :ref:`Classification Tree Graph` 
     217    * - |ClsTreeViewer_icon| :ref:`Classification Tree Viewer` 
     218      - |CN2Rules_icon| :ref:`CN2 Rules` 
     219      - |CN2RulesViewer_icon| :ref:`CN2 Rules Viewer` 
     220    * - |kNN_icon| :ref:`k-Nearest Neighbours` 
     221      - |Nomogram_icon| :ref:`Nomogram` 
     222      - |RandomForest_icon| :ref:`Random Forest` 
     223    * - |C4.5_icon| :ref:`C4.5` 
     224      - |ITreeBuilder_icon| :ref:`Interactive Tree Builder` 
    269225      - 
    270  
    271 .. _`Naive Bayes`: _static/Classify/NaiveBayes.htm 
    272  
    273 .. _`SVM`: _static/Classify/SVM.htm 
    274  
    275 .. _`Logistic Regression`: _static/Classify/LogisticRegression.htm 
    276  
    277 .. _`Majority`: _static/Classify/Majority.htm 
    278  
    279 .. _`Classification Tree`: _static/Classify/ClassificationTree.htm 
    280  
    281 .. _`Classification Tree Graph`: _static/Classify/ClassificationTreeGraph.htm 
    282  
    283 .. _`Classification Tree Viewer`: _static/Classify/ClassificationTreeViewer.htm 
    284  
    285 .. _`CN2 Rules`: _static/Classify/CN2.htm 
    286  
    287 .. _`CN2 Rules Viewer`: _static/Classify/CN2.htm 
    288  
    289 .. _`k-Nearest Neighbours`: _static/Classify/kNearestNeighbours.htm 
    290  
    291 .. _`Nomogram`: _static/Classify/Nomogram.htm 
    292  
    293 .. _`Random Forest`: _static/Classify/RandomForest.htm 
    294  
    295 .. _`C4.5`: _static/Classify/C4.5.htm 
    296  
    297 .. _`Interactive Tree Builder`: _static/Classify/InteractiveTreeBuilder.htm 
    298  
    299226 
    300227.. |NaiveBayes_icon| image:: ../../../Orange/OrangeWidgets/Classify/icons/NaiveBayes_48.png 
     
    393320      - |LinearRegression_icon| :ref:`Linear Regression` 
    394321      - |Earth_icon| :ref:`Earth` 
    395     * - |RegressionTree_icon| `Regression Tree`_ 
    396       - |RegressionTreeGraph_icon| `Regression Tree Graph`_ 
    397       - |Pade_icon| `Pade`_ 
    398  
    399 .. _`Regression Tree`: _static/Regression/RegressionTree.htm 
    400  
    401 .. _`Regression Tree Graph`: _static/Regression/RegressionTreeGraph.htm 
    402  
    403 .. _`Pade`: _static/Regression/Pade.htm 
     322    * - |RegressionTree_icon| :ref:`Regression Tree` 
     323      - |RegressionTreeGraph_icon| :ref:`Regression Tree Graph` 
     324      - |Pade_icon| :ref:`Pade` 
    404325 
    405326.. |Mean_icon| image:: ../../../Orange/OrangeWidgets/icons/Unknown.png 
     
    447368    :class: widget-catalog-table 
    448369     
    449     * - |ConfusionMatrix_icon| `Confusion Matrix`_   
    450       - |ROCAnalysis_icon| `ROC Analysis`_ 
    451       - |LiftCurve_icon| `Lift Curve`_ 
    452     * - |CalibrationPlot_icon| `Calibration Plot`_ 
    453       - |TestLearners_icon| `Test Learners`_ 
    454       - |Predictions_icon| `Predictions`_ 
    455  
    456 .. _`Confusion Matrix`: _static/Evaluate/ConfusionMatrix.htm 
    457  
    458 .. _`ROC Analysis`: _static/Evaluate/ROCAnalysis.htm 
    459  
    460 .. _`Lift Curve`: _static/Evaluate/LiftCurve.htm 
    461  
    462 .. _`Calibration Plot`: _static/Evaluate/CalibrationPlot.htm 
    463  
    464 .. _`Test Learners`: _static/Evaluate/TestLearners.htm 
    465  
    466 .. _`Predictions`: _static/Evaluate/Predictions.htm 
     370    * - |ConfusionMatrix_icon| :ref:`Confusion Matrix` 
     371      - |ROCAnalysis_icon| :ref:`ROC Analysis` 
     372      - |LiftCurve_icon| :ref:`Lift Curve` 
     373    * - |CalibrationPlot_icon| :ref:`Calibration Plot` 
     374      - |TestLearners_icon| :ref:`Test Learners` 
     375      - |Predictions_icon| :ref:`Predictions` 
     376 
    467377 
    468378.. |ConfusionMatrix_icon| image:: ../../../Orange/OrangeWidgets/Evaluate/icons/ConfusionMatrix_48.png  
     
    510420    :class: widget-catalog-table 
    511421     
    512     * - |AssociationRules_icon| `Association Rules`_  
    513       - |AssociationRulesFilter_icon| `Association Rules Filter`_  
    514       - |AssociationRulesExplorer_icon| `Association Rules Explorer`_  
    515     * - |ItemSets_icon| `Item Sets`   
    516       - |ItemSetsExplorer_icon| `Item Sets Explorer`  
     422    * - |AssociationRules_icon| :ref:`Association Rules` 
     423      - |AssociationRulesFilter_icon| :ref:`Association Rules Filter` 
     424      - |AssociationRulesExplorer_icon| :ref:`Association Rules Explorer` 
     425    * - |ItemSets_icon| `Item Sets` 
     426      - |ItemSetsExplorer_icon| `Item Sets Explorer` 
    517427      - 
    518  
    519 .. _`Association Rules`: _static/Associate/AssociationRules.htm 
    520  
    521 .. _`Association Rules Filter`: _static/Associate/AssociationRulesFilter.htm 
    522  
    523 .. _`Association Rules Explorer`: _static/Associate/AssociationRulesExplorer.htm 
    524  
    525 .. _`Item Sets`: _static/Associate/ItemSets.htm 
    526  
    527 .. _`Item Sets Explorer`: _static/Associate/ItemSetsExplorer.htm 
    528428 
    529429.. |AssociationRules_icon| image:: ../../../Orange/OrangeWidgets/Associate/icons/AssociationRules_48.png 
     
    565465    :class: widget-catalog-table 
    566466     
    567     * - |DistanceFile_icon| `Distance File`_ 
     467    * - |DistanceFile_icon| :ref:`Distance File` 
    568468      - |SaveDistanceFile_icon| `Save Distance File` 
    569469      - |MatrixTransformation_icon| `Matrix Transformation` 
    570470    * - |DistanceMatrixFilter_icon| `Distance Matrix Filter` 
    571       - |DistanceMap_icon| `Distance Map`_ 
    572       - |ExampleDistance_icon| `Example Distance`_ 
    573     * - |AttributeDistance_icon| `AttributeDistance`_ 
    574       - |HierarchicalClustering_icon| `Hierarchical Clustering`_ 
    575       - |InteractionGraph_icon| `Interaction Graph`_ 
    576     * - |kMeansClustering_icon| `k-Means Clustering`_ 
    577       - |MDS_icon| `MDS`_ 
     471      - |DistanceMap_icon| :ref:`Distance Map` 
     472      - |ExampleDistance_icon| :ref:`Example Distance` 
     473    * - |AttributeDistance_icon| :ref:`Attribute Distance` 
     474      - |HierarchicalClustering_icon| :ref:`Hierarchical Clustering` 
     475      - |InteractionGraph_icon| :ref:`Interaction Graph` 
     476    * - |kMeansClustering_icon| :ref:`k-Means Clustering` 
     477      - |MDS_icon| :ref:`MDS` 
    578478      - |PCA_icon| :ref:`PCA` 
    579     * - |NetworkFile_icon| `Network File` 
    580       - |NetExplorer_icon| `Net Explorer`_ 
    581       - |NetworkFromDistances_icon| `Network From Distances` 
    582479    * - |SOM_icon| `SOM` 
    583480      - |SOMVisualizer_icon| `SOM Visualizer` 
    584481      - 
    585  
    586  
    587 .. _`Distance File`: _static/Unsupervised/DistanceFile.htm 
    588  
    589 .. _`Save Distance File`: _static/Unsupervised/SaveDistanceFile.htm 
    590  
    591 .. _`Matrix Transformation`: _static/Unsupervised/`MatrixTransformation.htm 
    592  
    593 .. _`Distance Matrix Filter`: _static/Unsupervised/DistanceMatrixFilter.htm 
    594  
    595 .. _`Distance Map`: _static/Unsupervised/DistanceMap.htm 
    596  
    597 .. _`Example Distance`: _static/Unsupervised/ExampleDistance.htm 
    598  
    599 .. _`AttributeDistance`: _static/Unsupervised/AttributeDistance.htm 
    600  
    601 .. _`Hierarchical Clustering`: _static/Unsupervised/HierarchicalClustering.htm 
    602  
    603 .. _`Interaction Graph`: _static/Unsupervised/InteractionGraph.htm 
    604  
    605 .. _`k-Means Clustering`: _static/Unsupervised/k-MeansClustering.htm 
    606  
    607 .. _`MDS`: _static/Unsupervised/MDS.htm 
    608  
    609 .. _`Network File`: _static/Unsupervised/NetworkFile.htm 
    610  
    611 .. _`Net Explorer`: _static/Unsupervised/NetExplorer.htm 
    612  
    613 .. _`Network From Distances`: _static/Unsupervised/NetworkFromDistances.htm 
    614  
    615 .. _`SOM`: _static/Unsupervised/SOM.htm 
    616  
    617 .. _`SOM Visualizer`: _static/Unsupervised/SOMVisualizer.htm 
    618482 
    619483.. |DistanceFile_icon| image:: ../../../Orange/OrangeWidgets/Unsupervised/icons/DistanceFile_48.png 
     
    726590    
    727591   data/file.rst 
    728    data/data-table.rst 
    729    data/select-attributes.rst 
    730     
     592   data/datatable.rst 
     593   data/selectattributes.rst 
     594   data/rank.rst 
     595   data/purgedomain.rst 
     596   data/mergedata.rst 
     597   data/concatenate.rst 
     598   data/datasampler.rst 
     599   data/selectdata.rst 
     600   data/save.rst 
     601   data/discretize.rst 
     602   data/continuize.rst 
     603   data/impute.rst 
     604   data/outliers.rst 
     605 
     606   visualize/distributions.rst 
     607   visualize/scatterplot.rst 
     608   visualize/attributestatistics.rst 
     609   visualize/linearprojection.rst 
     610   visualize/radviz.rst 
     611   visualize/polyviz.rst 
     612   visualize/parallelcoordinates.rst 
     613   visualize/surveyplot.rst 
     614   visualize/mosaicdisplay.rst 
     615   visualize/sievediagram.rst 
     616 
     617   classify/naivebayes.rst 
     618   classify/svm.rst 
     619   classify/logisticregression.rst 
     620   classify/majority.rst 
     621   classify/classificationtree.rst 
     622   classify/classificationtreegraph.rst 
     623   classify/classificationtreeviewer.rst 
     624   classify/cn2.rst 
     625   classify/cn2rulesviewer.rst 
     626   classify/knearestneighbours.rst 
     627   classify/nomogram.rst 
     628   classify/randomforest.rst 
     629   classify/c45.rst 
     630   classify/interactivetreebuilder.rst 
     631 
    731632   regression/mean.rst 
    732633   regression/linear.rst 
    733634   regression/earth.rst 
    734     
    735    unsupervized/PCA.rst 
     635   regression/regressiontree.rst 
     636   regression/regressiontreegraph.rst 
     637   regression/pade.rst 
     638 
     639   evaluate/confusionmatrix.rst 
     640   evaluate/rocanalysis.rst 
     641   evaluate/liftcurve.rst 
     642   evaluate/calibrationplot.rst 
     643   evaluate/testlearners.rst 
     644   evaluate/predictions.rst 
     645 
     646   associate/associationrules.rst 
     647   associate/associationrulesfilter.rst 
     648   associate/associationrulesexplorer.rst 
     649 
     650   unsupervized/distancefile.rst 
     651   unsupervized/distancemap.rst 
     652   unsupervized/exampledistance.rst 
     653   unsupervized/attributedistance.rst 
     654   unsupervized/hierarchicalclustering.rst 
     655   unsupervized/interactiongraph.rst 
     656   unsupervized/kmeansclustering.rst 
     657   unsupervized/mds.rst 
     658   unsupervized/pca.rst 
    736659 
    737660**************** 
  • docs/widgets/rst/regression/earth.rst

    r10404 r11050  
    5555 
    5656 
    57 After changing one or more settings, you need to push |5| ``Apply``,  
     57After changing one or more settings, you need to push 5 ``Apply``, 
    5858which will put the new learner on the output and, if the training 
    5959examples are given, construct a new predictor and output it as well. 
  • docs/widgets/rst/regression/linear.rst

    r10410 r11050  
    4545    2. Train an ordinary least squares or ridge regression model 
    4646    3. If ``Ridge lambda`` is checked the learner will build a ridge regression model 
    47        with |4| as the ``lambda`` parameter. 
     47       with 4 as the ``lambda`` parameter. 
    4848    4. Ridge lambda parameter. 
    4949    5. Use `Lasso`_ regularization. 
  • docs/widgets/rst/unsupervized/PCA.rst

    r10843 r11050  
    4646The number of components of the transformation can be selected using either 
    4747the `Components Selection` input box or by dragging the vertical cutoff line 
    48 in the graph (|5|). 
     48in the graph. 
  • install-scripts/mac/bundle-build-hg.sh

    r10946 r11074  
    3232PYTHON=${TMP_BUNDLE_DIR}/Orange.app/Contents/MacOS/python 
    3333 
     34#easy_install script in the bundle 
     35EASY_INSTALL=${TMP_BUNDLE_DIR}/Orange.app/Contents/MacOS/easy_install 
     36 
    3437#Python version 
    3538PY_VER=`$PYTHON -c "import sys; print sys.version[:3]"` 
     39 
     40# First install/upgrade distrubute. The setup.py scripts might 
     41# need it 
     42echo "Installing/upgrading distribute in the bundle" 
     43echo "=============================================" 
     44$EASY_INSTALL -U distribute 
     45 
    3646 
    3747echo "Checkouting and building orange" 
     
    4050 
    4151echo "Specifically building orangeqt" 
     52echo "------------------------------" 
     53 
    4254CUR_DIR=`pwd` 
    4355cd $REPOS_DIR/orange/source/orangeqt 
     
    5668Plugins = ../../../../../Resources/Qt4/plugins/" > $APP/Contents/Frameworks/Python.framework/Resources/Python.app/Contents/Resources/qt.conf 
    5769 
     70 
    5871echo "Checkouting and building bioinformatics addon" 
    5972echo "=============================================" 
     
    6578 
    6679echo "Installing networkx" 
    67 echo "+++++++++++++++++++++" 
     80echo "+++++++++++++++++++" 
    6881./bundle-inject-pypi.sh networkx-1.6 http://pypi.python.org/packages/source/n/networkx/networkx-1.6.tar.gz $REPOS_DIR ${TMP_BUNDLE_DIR}/Orange.app 
    6982 
    70 echo "Installing distribute" 
    71 echo "+++++++++++++++++++++" 
    72 ./bundle-inject-pypi.sh distribute-0.6.24 http://pypi.python.org/packages/source/d/distribute/distribute-0.6.24.tar.gz $REPOS_DIR ${TMP_BUNDLE_DIR}/Orange.app 
    73  
    74 # TODO: from here on we could use easy_install to install pip and then use that 
    7583echo "Installing suds library" 
    7684echo "+++++++++++++++++++++++" 
  • source/orange/cls_orange.cpp

    r10673 r11065  
    393393    } 
    394394  
    395     if (!strcmp(name, "name") || !strcmp(name, "shortDescription") || !strcmp(name, "description")) 
    396       return PyString_FromString(""); 
    397  
    398395    PyErr_Format(PyExc_AttributeError, "'%s' has no attribute '%s'", self->ob_type->tp_name, name); 
    399396    return PYNULL; 
     
    10251022 
    10261023 
     1024char const *genericNames[] = {"Classifier", "Learner", "Discretizer", NULL}; 
     1025 
     1026PyObject *Orange_get_name(TPyOrange *self) 
     1027{ 
     1028  PyTRY 
     1029    PyObject *pyname = Orange_getattr1(self, "name"); 
     1030    if (!pyname) {  
     1031      PyErr_Clear(); 
     1032      if (self->orange_dict) { 
     1033        pyname = PyDict_GetItemString(self->orange_dict, "name"); 
     1034        Py_XINCREF(pyname); 
     1035      } 
     1036    } 
     1037    if (pyname) { 
     1038      if (PyString_Check(pyname)) { 
     1039        return pyname; 
     1040      } 
     1041      PyObject *pystr = PyObject_Repr(pyname); 
     1042      Py_DECREF(pyname); 
     1043      return pystr; 
     1044    } 
     1045 
     1046    char const *tp_name = self->ob_type->tp_name; 
     1047    char const *dotp = tp_name + strlen(tp_name); 
     1048    while((dotp != tp_name) && (*dotp != '.')) { 
     1049      dotp--; 
     1050    } 
     1051    if (*dotp == '.') { 
     1052      dotp++; 
     1053    } 
     1054    if (*dotp == '_') { 
     1055      dotp++; 
     1056    } 
     1057    char *name = (char *)malloc(strlen(dotp) + 1); 
     1058    strcpy(name, dotp); 
     1059 
     1060    const int lenname = strlen(name); 
     1061    char *nameend = name + lenname; 
     1062    for(char const *const *gen = genericNames; *gen; gen++) { 
     1063        if (strlen(*gen) < lenname) { 
     1064            char *cap = nameend - strlen(*gen); 
     1065            if (!strcmp(cap, *gen)) { 
     1066              *cap = 0; 
     1067              break; 
     1068            } 
     1069        } 
     1070    } 
     1071    if ((*name >= 'A') && (*name <= 'Z')) { 
     1072      *name ^= 32; 
     1073      } 
     1074    return PyString_FromString(name); 
     1075  PyCATCH 
     1076} 
     1077 
     1078 
     1079 
     1080int Orange_set_name(TPyOrange *self, PyObject *arg) 
     1081{ 
     1082  PyTRY 
     1083    int res = Orange_setattr1(self, "name", arg); 
     1084    if (res == 1) { 
     1085        res = Orange_setattrDictionary(self, "name", arg, false); 
     1086    } 
     1087    return res; 
     1088  PyCATCH_1 
     1089} 
     1090 
     1091 
    10271092int Orange_nonzero(PyObject *self) 
    10281093{ PyTRY 
  • source/orange/table.cpp

    r10866 r11048  
    3232#include "table.ppp" 
    3333 
     34 
     35TExampleTable::TExampleTable(const TExampleTable& orig) 
     36: TExampleGenerator(orig.domain), 
     37  examples(NULL), 
     38  _Last(NULL), 
     39  _EndSpace(NULL), 
     40  ownsExamples(true) 
     41{ 
     42  reserve(orig.size()); 
     43  for(int i = 0; i < orig.size(); ++i){ 
     44      push_back(new TExample(orig.at(i))); 
     45  } 
     46} 
    3447 
    3548TExampleTable::TExampleTable(PDomain dom, bool owns) 
  • source/orange/table.hpp

    r9410 r11048  
    4141  // Iterates through examples of basevector 
    4242  #define baseITERATE(x) ITERATE(vector<TExample>, x, examples) 
     43 
     44  TExampleTable(const TExampleTable& orig); 
    4345 
    4446  TExampleTable(PDomain, bool owns = true); 
Note: See TracChangeset for help on using the changeset viewer.