Changeset 7529:47ac9f0ab5bd in orange
 Timestamp:
 02/04/11 21:00:37 (3 years ago)
 Branch:
 default
 Convert:
 aeebe3f9724fefdc33736661cc1e4a57a40c0ce2
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

orange/Orange/probability/distributions.py
r7513 r7529 4 4 features, distributions and contingencies. 5 5 6 ================= 6 ======================================== 7 7 Basic Statistics for Continuous Features 8 ================= 8 ======================================== 9 9 10 10 The are two simple classes for computing basic statistics … … 63 63 by :obj:`ContDistribution`. !!!TODO 64 64 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 metaattribute 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 noncontinuous features. 82 83 `DomainBasicAttrStat` behaves like a ordinary list, except that its 84 elements can also be indexed by feature descriptors or feature names. 65 85 66 86 .. _distributionsbasicstat: code/distributionsbasicstat.py … … 78 98 petal width 0.100 2.500 1.199 79 99 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 metaattribute 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 .. _distributionsbasicstat: code/distributionsbasicstat.py 101 part of `distributionsbasicstat`_ (uses iris.tab) 102 103 .. literalinclude:: code/distributionsbasicstat.py 104 :lines: 11 105 106 This code prints out:: 107 108 5.84333467484 109 110 111 112 ================= 100 101 .. _distributionsbasicstat: code/distributionsbasicstat.py 102 part of `distributionsbasicstat`_ (uses iris.tab) 103 104 .. literalinclude:: code/distributionsbasicstat.py 105 :lines: 11 106 107 This code prints out:: 108 109 5.84333467484 110 111 112 113 ================== 113 114 Contingency Matrix 114 ================= 115 ================== 115 116 116 117 Contingency 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. 118 discrete and continuous variables; although examples on this page will mostly 119 use discrete ones, similar code could be run for continuous variables. 120 120 121 121 .. _distributionscontingency: code/distributionscontingency.py … … 124 124 .. literalinclude:: code/distributionscontingency.py 125 125 :lines: 18 126 127 126 128 127 This code prints out:: … … 133 132 4 <72.000, 36.000> 134 133 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. 134 Contingencies behave like lists of distributions (in this case, class distributions) indexed by values (of `e`, in this example). Distributions are, in turn indexed 135 by values (class values, here). The variable `e` from the above example is called 136 the outer variable, and the class is the inner. This can also be reversed, and it 137 is also possible to use features for both, outer and inner variable, so the 138 matrix shows distributions of one variable's values given the value of another. 139 There 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 143 143 144 144 There is a hierarchy of classes with contingencies:: … … 670 670 671 671 672 672 673 from orange import \ 673 BasicAttrStat, \674 DomainBasicAttrStat, \675 674 DomainContingency, \ 676 675 DomainDistributions, \ 677 676 DistributionList, \ 678 677 ComputeDomainContingency, \ 679 Contingency, \ 680 ContingencyAttrAttr, \ 681 ContingencyClass, \ 682 ContingencyAttrClass, \ 683 ContingencyClassAttr 678 Contingency 679 680 from orange import BasicAttrStat as BasicStatistics 681 from orange import DomainBasicAttrStat as DomainBasicStatistics 682 from orange import ContingencyAttrAttr as ContingencyVarVar 683 from orange import ContingencyAttrAttr as ContingencyClass 684 from orange import ContingencyAttrAttr as ContingencyVarClass 685 from orange import ContingencyAttrAttr as ContingencyClassVar
Note: See TracChangeset
for help on using the changeset viewer.