source: orange/orange/Orange/statistics/basic.py @ 7686:3ac55fafc17e

Revision 7686:3ac55fafc17e, 3.5 KB checked in by janezd <janez.demsar@…>, 3 years ago (diff)

Finished documentation for Domain (needs checking) and fixed the TOC section on Data description

Line 
1"""
2
3The are two simple classes for computing basic statistics
4for continuous features, such as their minimal and maximal value
5or average: :class:`Orange.statistics.basic.Variable` holds the statistics for a single variable
6and :class:`Orange.statistics.basic.Domain` behaves like a list of instances of
7the above class for all variables in the domain.
8
9.. class:: Variable
10
11    Computes and stores minimal, maximal, average and
12    standard deviation of a variable. It does not include the median or any
13    other statistics that can be computed on the fly, without remembering the
14    data; such statistics can be obtained classes from module :obj:`Orange.statistics.distribution`.
15
16    Instances of this class are seldom constructed manually; they are more often
17    returned by :obj:`Domain` described below.
18
19    .. attribute:: variable
20   
21        The variable to which the data applies.
22
23    .. attribute:: min
24
25        Minimal value encountered
26
27    .. attribute:: max
28
29        Maximal value encountered
30
31    .. attribute:: avg
32
33        Average value
34
35    .. attribute:: dev
36
37        Standard deviation
38
39    .. attribute:: n
40
41        Number of instances for which the value was defined.
42        If instances were weighted, :obj:`n` holds the sum of weights
43       
44    .. attribute:: sum
45
46        Weighted sum of values
47
48    .. attribute:: sum2
49
50        Weighted sum of squared values
51
52    ..
53        .. attribute:: holdRecomputation
54   
55            Holds recomputation of the average and standard deviation.
56
57    .. method:: add(value[, weight=1])
58   
59        Add a value to the statistics: adjust :obj:`min` and :obj:`max` if
60        necessary, increase :obj:`n` and recompute :obj:`sum`, :obj:`sum2`,
61        :obj:`avg` and :obj:`dev`.
62
63        :param value: Value to be added to the statistics
64        :type value: float
65        :param weight: Weight assigned to the value
66        :type weight: float
67
68    ..
69        .. method:: recompute()
70
71            Recompute the average and deviation.
72
73.. class:: Domain
74
75    ``statistics.basic.Domain`` behaves like an ordinary list, except that its
76    elements can also be indexed by variable names or descriptors.
77
78    .. method:: __init__(data[, weight=None])
79
80        Compute the statistics for all continuous variables in the data, and put
81        :obj:`None` to the places corresponding to variables of other types.
82
83        :param data: A table of instances
84        :type data: Orange.data.Table
85        :param weight: The id of the meta-attribute with weights
86        :type weight: `int` or none
87       
88    .. method:: purge()
89   
90        Remove the :obj:`None`'s corresponding to non-continuous features; this
91        truncates the list, so the indices do not respond to indices of
92        variables in the domain.
93   
94    part of `distributions-basic-stat.py`_ (uses monks-1.tab)
95   
96    .. literalinclude:: code/distributions-basic-stat.py
97        :lines: 1-10
98
99    Output::
100
101             feature   min   max   avg
102        sepal length 4.300 7.900 5.843
103         sepal width 2.000 4.400 3.054
104        petal length 1.000 6.900 3.759
105         petal width 0.100 2.500 1.199
106
107
108    part of `distributions-basic-stat`_ (uses iris.tab)
109   
110    .. literalinclude:: code/distributions-basic-stat.py
111        :lines: 11-
112
113    Output::
114
115        5.84333467484
116
117.. _distributions-basic-stat: code/distributions-basic-stat.py
118.. _distributions-basic-stat.py: code/distributions-basic-stat.py
119"""
120
121from Orange.core import BasicAttrStat as Variable
122from Orange.core import DomainBasicAttrStat as Domain
Note: See TracBrowser for help on using the repository browser.