Changeset 9986:c6ae4843d946 in orange


Ignore:
Timestamp:
02/07/12 21:48:58 (2 years ago)
Author:
markotoplak
Branch:
default
Message:

Added value transfromers to the hierarchy.

Files:
8 edited
1 moved

Legend:

Unmodified
Added
Removed
  • Orange/__init__.py

    r9944 r9986  
    1919_import("data.io") 
    2020_import("data.sample") 
     21_import("data.utils") 
    2122_import("data.discretization") 
    2223 
  • Orange/data/utils.py

    r9936 r9986  
    1 """\ 
    2 ************************** 
    3 Data Utilities (``utils``) 
    4 ************************** 
    5  
    6 Common operations on :class:`Orange.data.Table`. 
    7  
    8 """ 
    91#from __future__ import absolute_import 
     2 
     3from Orange.core import TransformValue, \ 
     4    Ordinal2Continuous, \ 
     5    Discrete2Continuous, \ 
     6    NormalizeContinuous, \ 
     7    MapIntValue 
     8 
    109 
    1110import random 
  • Orange/fixes/fix_changed_names.py

    r9942 r9986  
    586586           "orange.RandomGenerator": "Orange.misc.Random", 
    587587 
     588           "orange.TransformValue": "Orange.data.utils.TransformValue", 
     589           "orange.Ordinal2Continuous": "Orange.data.utils.Ordinal2Continuous", 
     590           "orange.Discrete2Continuous": "Orange.data.utils.Discrete2Continuous", 
     591           "orange.NormalizeContinuous": "Orange.data.utils.NormalizeContinuous", 
     592           "orange.MapIntValue": "Orange.data.utils.MapIntValue", 
     593 
    588594           } 
    589595 
  • docs/reference/rst/Orange.data.rst

    r9941 r9986  
    1313    Orange.data.discretization 
    1414    Orange.data.continuization 
     15    Orange.data.utils 
  • docs/reference/rst/Orange.data.utils.rst

    r9941 r9986  
    1 .. py:currentmodule:: Orange.core 
     1##################### 
     2Utilities (``utils``) 
     3##################### 
     4 
     5================== 
     6Value transformers 
     7================== 
    28 
    39Value transformers are objects that take care of simple transformations 
     
    1117:file:`Orange.data.continuization`. 
    1218 
    13 .. class TransformValue 
     19.. class:: TransformValue 
    1420 
    1521    The abstract root of the hierarchy of transformers provides the call 
    1622    operator and chaining of transformers. 
    1723 
    18     .. attribute subtransformer 
     24    .. attribute:: subtransformer 
    1925 
    2026        The transformation that takes place prior to this. 
     
    2228 
    2329 
    24 .. class Ordinal2Continuous 
     30.. class:: Ordinal2Continuous 
    2531 
    2632    Converts ordinal values to continuous. For example, variable values 
     
    3137    converted to 0, 0.3333, 0.6666 and 0.9999. 
    3238 
    33     .. attribute factor 
     39    .. attribute:: factor 
    3440 
    3541        The factor by which the values are multiplied. 
    3642 
    37     .. literalinclude:: transformvalue-o2c.py 
     43    .. literalinclude:: code/transformvalue-o2c.py 
    3844        :lines: 7-23 
    3945 
     
    4349 
    4450 
    45 .. class Discrete2Continuous 
     51.. class:: Discrete2Continuous 
    4652 
    4753    Converts a discrete value to a continuous so that some chosen 
     
    4955    the settings. 
    5056 
    51     .. attribute value 
     57    .. attribute:: value 
    5258 
    5359        The value that in converted to 1.0; others are converted to 0.0 
    5460        or -1.0. Value needs to be specified by an integer index. 
    5561 
    56     .. attribute zero_based 
     62    .. attribute:: zero_based 
    5763 
    5864        Decides whether the other values will be transformed to 0.0 
     
    6167        otherwise, undefined values yield an error. 
    6268 
    63     .. attribute invert 
     69    .. attribute:: invert 
    6470 
    6571        If ``True`` (default is ``False``), the transformations are 
     
    7177    attribute `e1` that will indicate whether `e` is 1 or not. 
    7278 
    73     .. literalinclude transformvalue-d2c.py 
     79    .. literalinclude:: code/transformvalue-d2c.py 
    7480 
    7581 
    76 .. class NormalizeContinuous 
     82.. class:: NormalizeContinuous 
    7783 
    7884    Takes a continuous values and subtracts the ``average`` and 
    7985    divides the difference by half of the ``span``. 
    8086 
    81     .. attribute average 
     87    .. attribute:: average 
    8288 
    8389        The value that is subtracted from the original.</DD> 
    8490 
    85     .. span 
     91    .. attribute:: span 
    8692 
    8793        The divisor 
     
    9197    deviation. 
    9298 
    93     .. literalinclude transformvalue-nc.py 
     99    .. literalinclude code/transformvalue-nc.py 
    94100        :lines: 1-17 
    95101 
    96 .. class MapIntValue 
     102.. class:: MapIntValue 
    97103 
    98104    A discrete-to-discrete transformer that changes values according to the 
    99105    given mapping. MapIntValue is used for binarization in decision trees. 
    100106 
    101     .. attribute mapping 
     107    .. attribute:: mapping 
    102108 
    103109        A mapping that determines the new value: ``v = mapping[v]``. 
     
    109115    'old'. 
    110116 
    111     .. literalinclude transformvalue-miv.py 
     117    .. literalinclude:: code/transformvalue-miv.py 
    112118        :lines: 1-12 
    113119 
  • docs/reference/rst/code/transformvalue-d2c.py

    r9945 r9986  
    66e1 = Orange.feature.Continuous("e=1") 
    77e1.getValueFrom = Orange.core.ClassifierFromVar(whichVar = data.domain["e"]) 
    8 e1.getValueFrom.transformer = Orange.core.Discrete2Continuous() 
     8e1.getValueFrom.transformer = Orange.data.utils.Discrete2Continuous() 
    99e1.getValueFrom.transformer.value = int(Orange.data.Value(e, "1")) 
  • docs/reference/rst/code/transformvalue-miv.py

    r9924 r9986  
    66age_b = Orange.feature.Discrete("age_c", values = ['young', 'old']) 
    77age_b.getValueFrom = Orange.core.ClassifierFromVar(whichVar = age) 
    8 age_b.getValueFrom.transformer = Orange.core.MapIntValue() 
     8age_b.getValueFrom.transformer = Orange.data.utils.MapIntValue() 
    99age_b.getValueFrom.transformer.mapping = [0, 1, 1] 
    1010 
  • docs/reference/rst/code/transformvalue-nc.py

    r9924 r9986  
    88    attr_c = Orange.feature.Continous(attr.name+"_n") 
    99    attr_c.getValueFrom = Orange.core.ClassifierFromVar(whichVar = attr) 
    10     transformer = Orange.core.NormalizeContinuous() 
     10    transformer = Orange.data.utils.NormalizeContinuous() 
    1111    attr_c.getValueFrom.transformer = transformer 
    1212    transformer.average = domstat[attr].avg 
  • docs/reference/rst/code/transformvalue-o2c.py

    r9924 r9986  
    1313age_c = Orange.feature.Continuous("age_c") 
    1414age_c.getValueFrom = Orange.core.ClassifierFromVar(whichVar = age) 
    15 age_c.getValueFrom.transformer = Orange.core.Ordinal2Continuous() 
     15age_c.getValueFrom.transformer = Orange.data.utils.Ordinal2Continuous() 
    1616 
    1717age_cn = Orange.feature.Continuous("age_cn") 
    1818age_cn.getValueFrom = Orange.core.ClassifierFromVar(whichVar = age) 
    19 age_cn.getValueFrom.transformer = Orange.core.Ordinal2Continuous() 
     19age_cn.getValueFrom.transformer = Orange.data.utils.Ordinal2Continuous() 
    2020age_cn.getValueFrom.transformer.factor = 0.5 
    2121 
Note: See TracChangeset for help on using the changeset viewer.