Ignore:
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • docs/reference/rst/Orange.classification.bayes.rst

    r9616 r9635  
    1111 
    1212A `Naive Bayes classifier 
    13 <http://en.wikipedia.org/wiki/Naive_Bayes_classifier>`_ is a simple 
     13<http://en.wikipedia.org/wiki/Naive_Bayes_classifier>`_ is a 
    1414probabilistic classifier that estimates conditional probabilities of the 
    1515dependant variable from training data and uses them for classification 
     
    5757 
    5858Probability distributions for continuous features are estimated with \ 
    59 :class:`Orange.statistics.estimate.Loess`. 
     59:class:`~Orange.statistics.estimate.Loess`. 
    6060 
    6161.. literalinclude:: code/bayes-plot-iris.py 
  • docs/reference/rst/Orange.data.table.rst

    r9372 r9636  
    66 
    77Class `Orange.data.Table` holds a list of data instances of type 
    8 :obj:`Orange.data.Instance`. All instances belong to the same domain. 
     8:obj:`Orange.data.Instance`. All instances belong to the same domain 
     9(:obj:`Orange.data.Domain`). 
     10 
     11Data tables are usually loaded from a file (see :doc:`/Orange.data.formats`):: 
     12 
     13    import Orange 
     14    data = Orange.data.Table("titanic") 
     15 
     16Data tables can also be created programmatically, as in the :ref:`code 
     17below <example-table-prog1>`. 
     18 
    919 
    1020------------------- 
     
    1222------------------- 
    1323 
    14 :obj:`Table` supports most list-like operations: gettins, setting, 
     24:obj:`Table` supports most list-like operations: getting, setting, 
    1525removing data instances, as well as methods :obj:`append` and 
    1626:obj:`extend`. The limitation is that table contain instances of 
     
    2939As usual in Python, the data table is considered False, when empty. 
    3040 
    31 ----------- 
    32   
    3341.. class:: Table 
    3442 
     
    3846        attribute is read-only. 
    3947 
    40     .. attribute:: owns_examples 
     48    .. attribute:: owns_instances 
    4149 
    4250        True, if the table contains the data instances, False if it 
     
    5260        An integer that is increased whenever the table is 
    5361        changed. This is not foolproof, since the object cannot 
    54         detect when individual examples are changed. It will, however, 
     62        detect when individual instances are changed. It will, however, 
    5563        catch any additions and removals from the table. 
    5664 
     
    6674       If the table was loaded from a file, this list of flags tells 
    6775       whether the feature descriptors were reused and how they 
    68        matched. See :ref:`file-formats` for details. 
     76       matched. See :ref:`descriptor reuse <variable_descriptor_reuse>` for details. 
    6977 
    7078    .. attribute:: meta_attribute_load_status 
     
    7785        Read data from the given file. If the name includes the 
    7886        extension it must be one of the known file formats (see 
    79         :ref:`file-formats`). If no extension is given, the directory 
     87        :doc:`/Orange.data.formats`). If no extension is given, the directory 
    8088        is searched for any file with recognized extensions. If the 
    8189        file is not found, Orange will also search the directories 
     
    8391 
    8492        The optional flag `create_new_on` decides when variable 
    85         descriptors are reused. See :ref:`file-formats` for more details. 
     93        descriptors are reused. See :ref:`descriptor reuse 
     94        <variable_descriptor_reuse>` for more details. 
    8695 
    8796        :param filename: the name of the file 
     
    9099        :type create_new_on: int 
    91100 
     101    .. _example-table-prog1: 
     102 
    92103    .. method:: __init__(domain) 
    93104 
    94105        Construct an empty data table with the given domain. 
     106 
     107        .. literalinclude:: code/datatable1.py 
     108            :lines: 7-16 
     109 
     110        The example :ref:`continues <example-table-prog2>`. 
    95111 
    96112        :param domain: domain descriptor 
    97113        :type domain: Orange.data.Domain 
    98  
    99         ..literalinclude:: code/datatable1.py 
    100         :lines: 7-16 
    101114 
    102115    .. method:: __init__(instances[, references]) 
     
    116129        :param references: if True, the new table contains references 
    117130        :type references: bool 
     131 
     132    .. _example-table-prog2: 
    118133 
    119134    .. method:: __init__(domain, instances) 
     
    130145        :type instances: Table or list or numpy.array 
    131146 
    132         The following example fills the data table created above with 
    133         some data from a list. 
     147        The following example fills the data table created :ref:`above 
     148        <example-table-prog1>` with some data from a list. 
    134149 
    135150        .. literalinclude:: code/datatable1.py 
     
    186201        following script. 
    187202 
    188         ..literalinclude:: code/datatable_merge.py 
     203        .. literalinclude:: code/datatable_merge.py 
    189204 
    190205        This is what the output looks like:: 
     
    208223 
    209224        Merging succeeds since the values of `a1` and `m1` are the 
    210         same for all matching examples from both tables. 
     225        same for all matching instances from both tables. 
    211226 
    212227    .. method:: append(inst) 
     
    249264        :param filt: filter list 
    250265        :type filt: list of integers 
    251         :param idx: selects which examples to pick 
     266        :param idx: selects which instances to pick 
    252267        :type idx: int 
    253268        :param negate: negates the selection 
     
    306321        :param filt: filter list 
    307322        :type filt: list of integers 
    308         :param idx: selects which examples to pick 
     323        :param idx: selects which instances to pick 
    309324        :type idx: int 
    310325        :param negate: negates the selection 
     
    315330 
    316331        Same as :obj:`select`, except that it returns a Python list 
    317     with data instances. 
     332    with data instances. 
    318333 
    319334        :param filt: filter list 
    320335        :type filt: list of integers 
    321         :param idx: selects which examples to pick 
     336        :param idx: selects which instances to pick 
    322337        :type idx: int 
    323338        :param negate: negates the selection 
     
    449464            Return True if any instance has a missing class value. 
    450465 
    451     .. method:: random_example() 
    452  
    453             Return a random example from the 
     466    .. method:: random_instance() 
     467 
     468            Return a random instance from the 
    454469            table. Data table's own :obj:`random_generator` is used, 
    455470            which is initially seeded to 0, so results are 
  • install-scripts/orngServer/serverUpdateScripts/updateKEGG.py

    r8042 r9634  
    22##!contact=ales.erjavec@fri.uni-lj.si 
    33 
    4 import obiKEGG, obiGene, obiTaxonomy 
    5 import orngServerFiles, orngEnviron 
    6 import os, sys, tarfile, urllib2, shutil 
     4import obiKEGG2, obiGene, obiTaxonomy, obiGeneSets 
     5import os, sys, tarfile, urllib2, shutil, cPickle 
    76from getopt import getopt 
    87 
    9 import obiData 
    10 obiKEGG.borg_class(obiData.FtpDownloader) #To limit the number of connections 
    11  
     8from Orange.misc import serverfiles, ConsoleProgressBar 
     9DOMAIN = "KEGG" 
    1210 
    1311opt = dict(getopt(sys.argv[1:], "u:p:", ["user=", "password="])[0]) 
     
    1614password = opt.get("-p", opt.get("--password", "password")) 
    1715 
    18 tmp_path = os.path.join(orngEnviron.bufferDir, "tmp_KEGG/") 
     16sf = serverfiles.ServerFiles(username, password) 
    1917 
    20 #u = obiKEGG.Update(local_database_path=path) 
    21 serverFiles=orngServerFiles.ServerFiles(username, password) 
     18genome = obiKEGG2.KEGGGenome() 
     19common = genome.common_organisms() 
    2220 
    23 #def output(self, *args, **kwargs): 
    24 #    print args, kwargs 
    25      
    26 #serverFiles = type("bla", (object,), dict(upload=output, unprotect=output))() 
     21rev_taxmap = dict([(v, k) for k, v in genome.TAXID_MAP.items()]) 
    2722 
    2823 
    29 try: 
    30     shutil.rmtree(tmp_path) 
    31 except Exception, ex: 
    32     pass 
    33  
    34 try: 
    35     os.mkdir(tmp_path) 
    36 except Exception, ex: 
    37     pass 
    38  
    39 realPath = os.path.realpath(os.curdir) 
    40 os.chdir(tmp_path) 
    41  
    42 obiKEGG.DEFAULT_DATABASE_PATH = tmp_path 
    43  
    44 uncompressedSize = lambda filename: sum(info.size for info in tarfile.open(filename).getmembers()) 
    45  
    46 def tar(filename, mode="w:gz", add=[]): 
    47     f = tarfile.open(filename, mode) 
    48     for path in add: 
    49         f.add(path) 
    50     f.close() 
    51     return uncompressedSize(filename) 
    52  
    53 print "KEGGGenome.download()" 
    54 obiKEGG.KEGGGenome.download() 
    55  
    56 genome = obiKEGG.KEGGGenome() 
    57          
    58 essential_organisms = genome.essential_organisms() 
    59 common_organisms = genome.common_organisms() 
    60  
    61 files=["genes/genome"] 
    62  
    63 print "Uploading kegg_genome.tar.gz" 
    64  
    65 size = tar("kegg_genome.tar.gz", add=files) 
    66 serverFiles.upload("KEGG", "kegg_genome.tar.gz", "kegg_genome.tar.gz", title="KEGG Genome", 
    67                    tags=["kegg", "genome", "taxonomy", "essential", "#uncompressed:%i" % size, "#compression:tar.gz",  
    68                          "#version:%s" % obiKEGG.KEGGGenome.VERSION, "#files:%s" % "!@".join(files)]) 
    69 serverFiles.unprotect("KEGG", "kegg_genome.tar.gz") 
    70  
    71 print "KEGGEnzymes.download()" 
    72 obiKEGG.KEGGEnzymes.download() 
    73 enzymes = obiKEGG.KEGGEnzymes() 
    74  
    75 print "KEGGCompounds.download()" 
    76 obiKEGG.KEGGCompounds.download() 
    77 compounds = obiKEGG.KEGGCompounds() 
    78  
    79 print "KEGGReactions.download()" 
    80 obiKEGG.KEGGReactions.download() 
    81 reactions = obiKEGG.KEGGReactions() 
    82  
    83 files = ["ligand/enzyme/", "ligand/reaction/", "ligand/compound/"] 
    84 size = tar("kegg_ligand.tar.gz", add=files) 
    85  
    86 print "Uploading kegg_ligand.tar.gz" 
    87 serverFiles.upload("KEGG", "kegg_ligand.tar.gz", "kegg_ligand.tar.gz", title="KEGG Ligand", 
    88                    tags=["kegg", "enzymes", "compunds", "reactions", "essential", "#uncompressed:%i" % size, 
    89                          "#compression:tar.gz", "#version:v1.0", "#files:%s" % "!@".join(files)]) 
    90 serverFiles.unprotect("KEGG", "kegg_ligand.tar.gz") 
    91  
    92  
    93 ### KEGG Reference Pathways 
    94 ############################ 
    95  
    96 print 'KEGGPathway.download_pathways("map")' 
    97 obiKEGG.KEGGPathway.download_pathways("map") 
    98  
    99 files = ["pathway/map/"] 
    100  
    101 size = tar("kegg_pathways_map.tar.gz", add=files) 
    102  
    103 print "Uploading kegg_pathways_map.tar.gz" 
    104 serverFiles.upload("KEGG", "kegg_pathways_map.tar.gz", "kegg_pathways_map.tar.gz", title="KEGG Reference pathways (map)", 
    105                    tags=["kegg", "map", "pathways", "reference", "essential", "#uncompressed:%i" % size, 
    106                          "#compression:tar.gz", "#version:%s" % obiKEGG.KEGGPathway.VERSION, "#files:%s" % "!@".join(files)]) 
    107 serverFiles.unprotect("KEGG", "kegg_pathways_map.tar.gz") 
    108  
    109 print 'KEGGPathway.download_pathways("ec")' 
    110 obiKEGG.KEGGPathway.download_pathways("ec") 
    111  
    112 files = ["pathway/ec/", "xml/kgml/metabolic/ec/"] 
    113  
    114 size = tar("kegg_pathways_ec.tar.gz", add=files) 
    115  
    116 print "Uploading kegg_pathways_ec.tar.gz" 
    117 serverFiles.upload("KEGG", "kegg_pathways_ec.tar.gz", "kegg_pathways_ec.tar.gz", title="KEGG Reference pathways (ec)", 
    118                    tags=["kegg", "ec", "pathways", "reference", "essential", "#uncompressed:%i" % size, 
    119                          "#compression:tar.gz", "#version:%s" % obiKEGG.KEGGPathway.VERSION, "#files:%s" % "!@".join(files)]) 
    120 serverFiles.unprotect("KEGG", "kegg_pathways_ec.tar.gz") 
    121  
    122 print 'KEGGPathway.download_pathways("ko")' 
    123 obiKEGG.KEGGPathway.download_pathways("ko") 
    124  
    125 files = ["pathway/ko/", "xml/kgml/metabolic/ko/", "xml/kgml/non-metabolic/ko/"] 
    126  
    127 size = tar("kegg_pathways_ko.tar.gz", add=files) 
    128  
    129 print "Uploading kegg_pathways_ko.tar.gz" 
    130 serverFiles.upload("KEGG", "kegg_pathways_ko.tar.gz", "kegg_pathways_ko.tar.gz", title="KEGG Reference pathways (ko)", 
    131                    tags=["kegg", "ko", "pathways", "reference", "essential", "#uncompressed:%i" % size, 
    132                          "#compression:tar.gz", "#version:%s" % obiKEGG.KEGGPathway.VERSION, "#files:%s" % "!@".join(files)]) 
    133 serverFiles.unprotect("KEGG", "kegg_pathways_ko.tar.gz") 
    134  
    135  
    136 for org_code in common_organisms: 
    137     org_name = genome[org_code].definition 
     24for org in common: 
    13825     
    139     ### KEGG Genes 
    140     ############## 
     26    ##################### 
     27    # Create gene aliases 
     28    ##################### 
    14129     
    142     print "KEGGGenes.download(%s)" % org_code 
    143     obiKEGG.KEGGGenes.download(org_code) 
    144  
    145     genes = obiKEGG.KEGGGenes(org_code) 
     30#    genes = obiKEGG2.KEGGGenes(org) 
     31#     
     32#    pb = ConsoleProgressBar("Retriving KEGG ids for %r:" % org) 
     33#    genes.pre_cache(progress_callback=pb.set_state) 
     34#    aliases = [] 
     35#    for key, entry in genes.iteritems(): 
     36#        aliases.append(set([key]) | set(entry.alt_names)) 
     37#    pb.finish() 
     38#     
     39#    taxid = obiKEGG2.to_taxid(org) 
     40#    ids_filename = "kegg_gene_id_aliases_" + taxid + ".pickle" 
     41#    filename = serverfiles.localpath(DOMAIN, ids_filename) 
     42#     
     43#    cPickle.dump(aliases, open(filename, "wb")) 
     44#     
     45#    print "Uploading", ids_filename 
     46#    sf.upload(DOMAIN, ids_filename, filename, 
     47#              "KEGG Gene id aliases", 
     48#              tags=["KEGG", "genes", "aliases",  
     49#                    "#version:%s" % obiKEGG2.MatcherAliasesKEGG.VERSION 
     50#                    ], 
     51#              ) 
     52#    sf.unprotect(DOMAIN, ids_filename) 
    14653     
    147     filename = "kegg_genes_%s.tar.gz" % org_code 
    148     files = [os.path.split(obiKEGG.KEGGGenes.filename(org_code))[0]] 
     54    ########################## 
     55    # Create pathway gene sets 
     56    ########################## 
    14957     
    150     size = tar(filename, add=files) 
     58    organism = obiKEGG2.KEGGOrganism(org) 
     59    ge = genome[org] 
    15160     
    152     print "Uploading", filename 
    153     serverFiles.upload("KEGG", filename, filename, title="KEGG Genes for " + org_name, 
    154                        tags=["kegg", "genes", org_name, "#uncompressed:%i" % size, "#compression:tar.gz", 
    155                              "#version:%s" % obiKEGG.KEGGGenes.VERSION, "#files:%s" % "!@".join(files)] + (["essential"] if org_code in essential_organisms else [])) 
    156     serverFiles.unprotect("KEGG", filename) 
     61    taxid = rev_taxmap.get(ge.taxid, ge.taxid) 
     62    gene_sets = obiGeneSets.keggGeneSets(taxid) 
    15763     
    158     ### KEGG Pathways 
    159     ################# 
     64    print "Uploading pathway gene sets for", taxid, "(%s)" % org 
     65    obiGeneSets.register_serverfiles(gene_sets, sf) 
    16066     
    161     print "KEGGPathway.download_pathways(%s)" % org_code 
    162     obiKEGG.KEGGPathway.download_pathways(org_code) 
    163      
    164     filename = "kegg_pathways_%s.tar.gz" % org_code 
    165     files = [obiKEGG.KEGGPathway.directory_png(org_code, path="").lstrip("/"),  
    166              obiKEGG.KEGGPathway.directory_kgml(org_code, path="").lstrip("/"), 
    167              obiKEGG.KEGGPathway.directory_kgml(org_code, path="").lstrip("/").replace("metabolic", "non-metabolic")] 
    168      
    169     size = tar(filename, add=files) 
    170      
    171     print "Uploading", filename 
    172     serverFiles.upload("KEGG", filename, filename, title="KEGG Pathways for " + org_name, 
    173                        tags=["kegg", "genes", org_name, "#uncompressed:%i" % size, "#compression:tar.gz", 
    174                              "#version:%s" % obiKEGG.KEGGPathway.VERSION, "#files:%s" % "!@".join(files)] + (["essential"] if org_code in essential_organisms else [])) 
    175     serverFiles.unprotect("KEGG", filename) 
    176      
    177      
    178 brite_ids = [line.split()[-1] for line in urllib2.urlopen("ftp://ftp.genome.jp/pub/kegg/brite/br/").read().splitlines() if line.split()[-1].endswith(".keg")] 
    179 ko_brite_ids = [line.split()[-1] for line in urllib2.urlopen("ftp://ftp.genome.jp/pub/kegg/brite/ko/").read().splitlines() if line.split()[-1].endswith(".keg")] 
    180  
    181 for id in brite_ids + ko_brite_ids: 
    182     print "KEGGBrite.download(%s)" % id.split(".")[0] 
    183     obiKEGG.KEGGBrite.download(id.split(".")[0]) 
    184      
    185 files = ["brite/ko/", "brite/br/"] 
    186 size = tar("kegg_brite.tar.gz", add=files) 
    187  
    188 print "Uploading kegg_brite.tar.gz" 
    189 serverFiles.upload("KEGG", "kegg_brite.tar.gz", "kegg_brite.tar.gz", title="KEGG Brite", 
    190                    tags=["kegg", "brite", "essential", "#uncompressed:%i" % size, 
    191                          "#compression:tar.gz", "#version:%s" % obiKEGG.KEGGBrite.VERSION, "#files:%s" % "!@".join(files)]) 
    192 serverFiles.unprotect("KEGG", "kegg_brite.tar.gz") 
    193  
    194 os.chdir(realPath) 
  • orange/Orange/classification/bayes.py

    r9333 r9635  
    2222     
    2323        m for m-estimate. If set, m-estimation of probabilities 
    24         will be used using :class:`Orange.statistics.estimate.M`. 
     24        will be used using :class:`~Orange.statistics.estimate.M`. 
    2525        This attribute is ignored if you also set :obj:`estimator_constructor`. 
    2626         
     
    2929        Probability estimator constructor for 
    3030        prior class probabilities. Defaults to 
    31         :class:`Orange.statistics.estimate.RelativeFrequency`. 
     31        :class:`~Orange.statistics.estimate.RelativeFrequency`. 
    3232        Setting this attribute disables the above described attribute :obj:`m`. 
    3333         
     
    4242        Probability estimator constructor for conditional probabilities for 
    4343        continuous features. Defaults to  
    44         :class:`Orange.statistics.estimate.Loess`. 
     44        :class:`~Orange.statistics.estimate.Loess`. 
    4545    """ 
    4646     
     
    6767         
    6868        :param data: Data instances to learn from. 
    69         :type data: Orange.data.Table 
     69        :type data: :class:`~Orange.data.Table` 
    7070        :param weight: Id of meta attribute with weights of instances 
    7171        :type weight: int 
    72         :rtype: :class:`Orange.classification.bayes.NaiveClassifier` 
     72        :rtype: :class:`~Orange.classification.bayes.NaiveClassifier` 
    7373        """ 
    7474        bayes = _BayesLearner() 
     
    140140         
    141141        :param instance: instance to be classified. 
    142         :type instance: :class:`Orange.data.Instance` 
    143         :param result_type: :class:`Orange.classification.Classifier.GetValue` or \ 
    144               :class:`Orange.classification.Classifier.GetProbabilities` or 
    145               :class:`Orange.classification.Classifier.GetBoth` 
     142        :type instance: :class:`~Orange.data.Instance` 
     143        :param result_type: :class:`~Orange.classification.Classifier.GetValue` or 
     144              :class:`~Orange.classification.Classifier.GetProbabilities` or 
     145              :class:`~Orange.classification.Classifier.GetBoth` 
    146146         
    147         :rtype: :class:`Orange.data.Value`,  
    148               :class:`Orange.statistics.distribution.Distribution` or a tuple with both 
     147        :rtype: :class:`~Orange.data.Value`, 
     148              :class:`~Orange.statistics.distribution.Distribution` or a 
     149              tuple with both 
    149150        """ 
    150151        return self.native_bayes_classifier(instance, result_type, *args, **kwdargs) 
     
    166167        :param class_: class value for which the probability should be 
    167168                output. 
    168         :type class_: :class:`Orange.data.Value` 
     169        :type class_: :class:`~Orange.data.Value` 
    169170        :param instance: instance to be classified. 
    170         :type instance: :class:`Orange.data.Instance` 
     171        :type instance: :class:`~Orange.data.Instance` 
    171172         
    172173        """ 
  • orange/Orange/data/variable.py

    r9349 r9636  
    285285(such as "meta" or "class"), and are separated by spaces.  
    286286 
     287.. _variable_descriptor_reuse: 
     288 
    287289Reuse of descriptors 
    288290-------------------- 
  • orange/Orange/misc/__init__.py

    r9301 r9637  
    1919 
    2020.. automodule:: Orange.misc.r 
     21 
     22.. automodule:: Orange.misc.random 
    2123 
    2224""" 
  • orange/OrangeWidgets/Evaluate/OWPredictions.py

    r9601 r9633  
    151151        self.tasklabel = "N/A" 
    152152        self.precision = 2 
    153         self.doPrediction = True 
     153        self.doPrediction = False 
    154154        self.outvar = None # current output variable (set by the first predictor/data set send in) 
    155155 
  • source/orange/_aliases.txt

    r8042 r9636  
    3232filterbool filter_bool 
    3333randomexample random_example 
     34randomexample random_instance 
    3435 
    3536ClassifierByExampleTable 
Note: See TracChangeset for help on using the changeset viewer.