Changeset 7529:47ac9f0ab5bd in orange


Ignore:
Timestamp:
02/04/11 21:00:37 (3 years ago)
Author:
janezd <janez.demsar@…>
Branch:
default
Convert:
aeebe3f9724fefdc33736661cc1e4a57a40c0ce2
Message:

Commit before renaming directory

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/Orange/probability/distributions.py

    r7513 r7529  
    44features, distributions and contingencies. 
    55  
    6 ================= 
     6======================================== 
    77Basic Statistics for Continuous Features 
    8 ================= 
     8======================================== 
    99 
    1010The are two simple classes for computing basic statistics 
     
    6363    by :obj:`ContDistribution`. !!!TODO 
    6464 
     65    Instances of this class are seldom constructed manually; they are more often 
     66    returned by :obj:`DomainBasicAttrStat` described below. 
     67 
     68.. class:: DomainBasicAttrStat 
     69 
     70    :param data: A table of instances 
     71    :type data: Orange.data.Table 
     72    :param weight: The id of the meta-attribute with weights 
     73    :type weight: `int` or none 
     74     
     75    Constructor computes the statistics for all continuous features in the 
     76    give data, and puts `None` to the places corresponding to other types of 
     77    features. 
     78 
     79    .. method:: purge() 
     80     
     81        Removes the `None`'s corresponding to non-continuous features. 
     82     
     83    `DomainBasicAttrStat` behaves like a ordinary list, except that its 
     84    elements can also be indexed by feature descriptors or feature names. 
    6585 
    6686    .. _distributions-basic-stat: code/distributions-basic-stat.py 
     
    7898             petal width 0.100 2.500 1.199 
    7999 
    80     Instances of this class are seldom constructed manually; they are more often 
    81     returned as elements of the class :class:`DomainBasicAttrStat`  described below. 
    82  
    83 .. class:: DomainBasicAttrStat 
    84     :param data: A table of instances 
    85     :type data: Orange.data.Table 
    86     :param weight: The id of the meta-attribute with weights 
    87     :type data: `int` or none 
    88      
    89     DomainBasicAttrStat behaves like a ordinary list, except that its 
    90     elements can also be indexed by feature descriptors or feature names.     
    91  
    92     .. method:: purge() 
    93    
    94     Noticed the "if a" in the script? It's needed because of discrete 
    95     features for which this statistics cannot be measured and are thus 
    96     represented by a None. Method purge gets rid of them by removing 
    97     the None's from the list. 
    98  
    99  
    100 .. _distributions-basic-stat: code/distributions-basic-stat.py 
    101 part of `distributions-basic-stat`_ (uses iris.tab) 
    102  
    103 .. literalinclude:: code/distributions-basic-stat.py 
    104     :lines: 11- 
    105  
    106 This code prints out:: 
    107  
    108     5.84333467484  
    109  
    110  
    111  
    112 ================= 
     100 
     101    .. _distributions-basic-stat: code/distributions-basic-stat.py 
     102    part of `distributions-basic-stat`_ (uses iris.tab) 
     103 
     104    .. literalinclude:: code/distributions-basic-stat.py 
     105        :lines: 11- 
     106 
     107    This code prints out:: 
     108 
     109        5.84333467484  
     110 
     111 
     112 
     113================== 
    113114Contingency Matrix 
    114 ================= 
     115================== 
    115116 
    116117Contingency matrix contains conditional distributions. They can work for both, 
    117 discrete and continuous features; although the examples on this page will be 
    118 mostly limited to discrete features, the analogous could be done with 
    119 continuous values. 
     118discrete and continuous variables; although examples on this page will mostly 
     119use discrete ones, similar code could be run for continuous variables. 
    120120 
    121121.. _distributions-contingency: code/distributions-contingency.py 
     
    124124.. literalinclude:: code/distributions-contingency.py 
    125125    :lines: 1-8 
    126  
    127126 
    128127This code prints out:: 
     
    133132    4 <72.000, 36.000>  
    134133 
    135  
    136 As this simple example shows, contingency is similar to a dictionary 
    137 (or a list, it is a bit ambiguous), where feature values serve as 
    138 keys and class distributions are the dictionary values. 
    139 The feature e is here called the outer feature, and the class 
    140 is the inner. That's not the only possible configuration of contingency 
    141 matrix; class can also be outside or there can be no class at all and the 
    142 matrix shows distributions of one feature values given the value of another. 
     134Contingencies behave like lists of distributions (in this case, class distributions) indexed by values (of `e`, in this example). Distributions are, in turn indexed 
     135by values (class values, here). The variable `e` from the above example is called 
     136the outer variable, and the class is the inner. This can also be reversed, and it 
     137is also possible to use features for both, outer and inner variable, so the 
     138matrix shows distributions of one variable's values given the value of another. 
     139There is a corresponding hierarchy of classes for handling hierarchies: :obj:`Contingency` is a base class for :obj:`ContingencyAttrAttr` (and 
     140:obj:`ContingencyClass`; the latter is  
     141 
     142 
    143143 
    144144There is a hierarchy of classes with contingencies:: 
     
    670670 
    671671 
     672 
    672673from orange import \ 
    673      BasicAttrStat, \ 
    674      DomainBasicAttrStat, \ 
    675674     DomainContingency, \ 
    676675     DomainDistributions, \ 
    677676     DistributionList, \ 
    678677     ComputeDomainContingency, \ 
    679      Contingency, \ 
    680      ContingencyAttrAttr, \ 
    681      ContingencyClass, \ 
    682      ContingencyAttrClass, \ 
    683      ContingencyClassAttr 
     678     Contingency 
     679 
     680from orange import BasicAttrStat as BasicStatistics 
     681from orange import DomainBasicAttrStat as DomainBasicStatistics 
     682from orange import ContingencyAttrAttr as ContingencyVarVar 
     683from orange import ContingencyAttrAttr as ContingencyClass 
     684from orange import ContingencyAttrAttr as ContingencyVarClass 
     685from orange import ContingencyAttrAttr as ContingencyClassVar 
Note: See TracChangeset for help on using the changeset viewer.