source: orange/docs/reference/rst/Orange.core.transformvalue.rst @ 9941:3580c7e699e8

Revision 9941:3580c7e699e8, 3.7 KB checked in by janezd <janez.demsar@…>, 2 years ago (diff)

Added documentation about continuization, finished TransformValue

Line 
1.. py:currentmodule:: Orange.core
2
3Value transformers are objects that take care of simple transformations
4of values. Discretization, for instance, creates a transformer that
5converts continuous values into discrete, while continuizers do the
6opposite. Classification trees use transformers for binarization where
7values of discrete attributes are converted into binary.
8
9These objects are most often constructed by other classes and only seldom
10manually. See information on :file:`Orange.data.discretization` and
11:file:`Orange.data.continuization`.
12
13.. class TransformValue
14
15    The abstract root of the hierarchy of transformers provides the call
16    operator and chaining of transformers.
17
18    .. attribute subtransformer
19
20        The transformation that takes place prior to this.
21        This way, transformations can be chained.
22
23
24.. class Ordinal2Continuous
25
26    Converts ordinal values to continuous. For example, variable values
27    values `small`, `medium`, `large`, `extra large` (if given in
28    that order) would be, by default, converted to 0.0, 1.0, 2.0 and 3.0.
29    It is possible to add a factor by which the values are multiplied. If
30    the factor for the above case were 0.3333, the value would be
31    converted to 0, 0.3333, 0.6666 and 0.9999.
32
33    .. attribute factor
34
35        The factor by which the values are multiplied.
36
37    .. literalinclude:: transformvalue-o2c.py
38        :lines: 7-23
39
40    The values of attribute `age` (`young`, `pre-presbyopic` and
41    `presbyopic`) are transformed to 0.0, 1.0 and 2.0 in `age_c` and to
42    0, 0.5 and 1 in `age_cn`.
43
44
45.. class Discrete2Continuous
46
47    Converts a discrete value to a continuous so that some chosen
48    value is converted to 1.0 and all others to 0.0 or -1.0, depending on
49    the settings.
50
51    .. attribute value
52
53        The value that in converted to 1.0; others are converted to 0.0
54        or -1.0. Value needs to be specified by an integer index.
55
56    .. attribute zero_based
57
58        Decides whether the other values will be transformed to 0.0
59        (``True``, default) or -1.0 (``False``).
60        When ``False`` undefined values are transformed to 0.0;
61        otherwise, undefined values yield an error.
62
63    .. attribute invert
64
65        If ``True`` (default is ``False``), the transformations are
66        reversed - the selected ``value<`` becomes 0.0 (or -1.0)
67        and others 1.0.
68
69
70    The following script load the Monks 1 data set and constructs a new
71    attribute `e1` that will indicate whether `e` is 1 or not.
72
73    .. literalinclude transformvalue-d2c.py
74
75
76.. class NormalizeContinuous
77
78    Takes a continuous values and subtracts the ``average`` and
79    divides the difference by half of the ``span``.
80
81    .. attribute average
82
83        The value that is subtracted from the original.</DD>
84
85    .. span
86
87        The divisor
88
89    The following script "normalizes" all attribute in the Iris dataset by
90    subtracting the average value and dividing by the half of
91    deviation.
92
93    .. literalinclude transformvalue-nc.py
94        :lines: 1-17
95
96.. class MapIntValue
97
98    A discrete-to-discrete transformer that changes values according to the
99    given mapping. MapIntValue is used for binarization in decision trees.
100
101    .. attribute mapping
102
103        A mapping that determines the new value: ``v = mapping[v]``.
104        Undefined values remain undefined. Elements of the mapping
105        are  contains integer indices of values.
106
107    The following script transforms the value of `age` in dataset lenses
108    from 'young' to 'young', and from 'pre-presbyopic' and 'presbyopic' to
109    'old'.
110
111    .. literalinclude transformvalue-miv.py
112        :lines: 1-12
113
114    The mapping tells that the 0th value of `age` maps to the 0th of
115    `age_b`, and the 1st and 2nd value go to the 1st value of `age_b`.
Note: See TracBrowser for help on using the repository browser.