Changeset 10361:2c8d6b739b3d in orange


Ignore:
Timestamp:
02/24/12 13:01:59 (2 years ago)
Author:
Lan Zagar <lan.zagar@…>
Branch:
default
rebase_source:
ed0e1f04ef6bc37ac12d1bd2b71f04bf05024a39
Message:

Corrected some links in classfromvar documentation. But a lot of it should be rewritten.

Location:
docs/reference/rst
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • docs/reference/rst/Orange.classification.classfromvar.rst

    r10135 r10361  
    1313care of automatic value computation when needed. 
    1414 
    15 There are two classifiers from variable; the simpler :obj:`~Orange.classification.ClassifierFromVarFD` 
     15There are two classifiers from variable; the simpler :obj:`ClassifierFromVarFD` 
    1616supposes that example is from some fixed domain and the safer 
    17 :obj:`~Orange.classification.ClassifierFromVar` does not. 
     17:obj:`ClassifierFromVar` does not. 
    1818 
    1919Both classifiers can be given a transformer that can modify the value. 
     
    2727.. class:: ClassifierFromVar(which_var, transformer) 
    2828     
    29     Compute variable's values from variable which_var using 
    30     transformation defined by transformer.         
     29    Compute variable's values from variable :obj:`~ClassifierFromVar.which_var` 
     30    using transformation defined by :obj:`~ClassifierFromVar.transformer`. 
    3131 
    3232    .. attribute:: which_var 
     
    3737 
    3838        The transformer for the value. It should be a class derived from 
    39         TransformValue, but you can also use a callback function. 
     39        :obj:`~Orange.data.utils.TransformValue`, but you can also use a 
     40        callback function. 
    4041 
    4142    .. attribute:: distribution_for_unknown 
    4243 
    43         The distribution that is returned when the which_var's value is undefined. 
     44        The distribution that is returned when the 
     45        :obj:`~ClassifierFromVar.which_var`'s value is undefined. 
    4446 
    45 When given an instance, :obj:`~Orange.classification.ClassifierFromVar` will return 
    46 transformer(instance[which_var]). Attribute which_var can be either an ordinary variable, 
    47 a meta variable or a variable which is not defined for the instance but has getValueFrom 
    48 that can be used to compute the value. If none goes through or if the value found is unknown, 
    49 a Value of subtype Distribution containing distributionForUnknown is returned. 
     47When given an instance, :obj:`ClassifierFromVar` will return 
     48`transformer(instance[which_var])`. 
     49Attribute :obj:`~ClassifierFromVar.which_var` can be either an ordinary 
     50variable, a meta variable or a variable which is not defined for the instance 
     51but has :obj:`~Orange.feature.Descriptor.get_value_from` that can be used to 
     52compute the value. If none goes through or if the value found is unknown, a 
     53Value of subtype Distribution containing 
     54:obj:`~ClassifierFromVar.distribution_for_unknown` is returned. 
    5055 
    51 The class stores the domain version for the last example and its position in the domain. 
    52 If consecutive examples come from the same domain (which is usually the case), 
    53 :obj:`~Orange.classification.ClassifierFromVar` is just two simple ifs slower than  
    54 :obj:`~Orange.classification.ClassifierFromVarFD`. 
     56The class stores the domain version for the last example and its position in 
     57the domain. If consecutive examples come from the same domain (which is usually 
     58the case), :obj:`~Orange.classification.ClassifierFromVar` is just two simple 
     59ifs slower than :obj:`~Orange.classification.ClassifierFromVarFD`. 
    5560 
    5661As you might have guessed, the crucial component here is the transformer. 
    57 Let us, for sake of demonstration, load a Monk 1 dataset and construct an attribute 
    58 e1 that will have value "1", when e is "1", and "not 1" when e is different than 1. 
    59 There are many ways to do it, and that same problem is covered in different places 
    60 in Orange documentation. Although the way presented here is not the simplest, 
    61 it will serve to demonstrate how ClassifierFromVar works. 
     62Let us, for sake of demonstration, load a `monks-1` dataset and construct an 
     63attribute `e1` that will have value "1", when `e` is "1", and "not 1" when `e` 
     64is different than 1. There are many ways to do it, and that same problem is 
     65covered in different places in Orange documentation. Although the way presented 
     66here is not the simplest, it will serve to demonstrate how ClassifierFromVar 
     67works. 
    6268 
    6369 
     
    7076.. class:: ClassifierFromVarFD 
    7177 
    72     :obj:`~Orange.classification.ClassifierFromVarFD` is very similar to :obj:`~Orange.classification.ClassifierFromVar` except that the variable 
    73     is not given as a descriptor (like which_var) but as an index. The index can be 
    74     either a position of the variable in the domain or a meta-id. Given that :obj:`~Orange.classification.ClassifierFromVarFD` 
    75     is practically no faster than :obj:`~Orange.classification.ClassifierFromVar` (and can in future even be merged with the latter), 
    76     you should seldom need to use the class. 
     78    :obj:`ClassifierFromVarFD` is very similar to :obj:`ClassifierFromVar` 
     79    except that the variable is not given as a descriptor (like 
     80    :obj:`~ClassifierFromVar.which_var`) but as an index. The index can be 
     81    either a position of the variable in the domain or a meta-id. Given that 
     82    :obj:`ClassifierFromVarFD` is practically no faster than 
     83    :obj:`ClassifierFromVar` (and can in future even be merged with the 
     84    latter), you should seldom need to use the class. 
    7785 
    78     .. attribute:: domain (inherited from ClassifierFromVarFD) 
     86    .. attribute:: domain (inherited from :obj:`ClassifierFromVarFD`) 
    7987     
    8088        The domain on which the classifier operates. 
     
    92100        The distribution that is returned when the which_var's value is undefined. 
    93101 
    94 When an example is passed to :obj:`~Orange.classification.ClassifierFromVarFD`, 
    95 it is first checked whether it is 
    96 from the correct domain; an exception is raised if not. If the domain is OK, 
    97 the corresponding attribute value is retrieved, transformed and returned. 
     102When an instance is passed to :obj:`~Orange.classification.ClassifierFromVarFD`, 
     103it is first checked whether it is from the correct domain; an exception is 
     104raised if not. If the domain is OK, the corresponding attribute value is 
     105retrieved, transformed and returned. 
    98106 
    99 :obj:`~Orange.classification.ClassifierFromVarFD`'s twin brother, :obj:`~Orange.classification.ClassifierFromVar`, can also handle variables that 
    100 are not in the instances' domain or meta-variables, but can be computed therefrom by using 
    101 their getValueFrom. Since :obj:`~Orange.classification.ClassifierFromVarFD` doesn't store attribute descriptor but 
    102 only an index, such functionality is obviously impossible. 
     107:obj:`ClassifierFromVarFD`'s twin brother, :obj:`ClassifierFromVar`, can also 
     108handle variables that are not in the instances' domain or meta-variables, 
     109but can be computed therefrom by using their 
     110:obj:`~Orange.feature.Descriptor.get_value_from`. Since 
     111:obj:`ClassifierFromVarFD` doesn't store attribute descriptor but only an index, 
     112such functionality is obviously impossible. 
    103113 
    104 To rewrite the above script to use :obj:`~Orange.classification.ClassifierFromVarFD`, 
    105 we need to set the domain and the e's index to position 
    106 (equivalent to setting which_var in :obj:`~Orange.classification.ClassifierFromVar`). 
    107 The initialization of :obj:`~Orange.classification.ClassifierFromVarFD` thus goes like this: 
     114To rewrite the above script to use :obj:`ClassifierFromVarFD`, 
     115we need to set the domain and the `e`'s index to position 
     116(equivalent to setting which_var in :obj:`ClassifierFromVar`). 
     117The initialization of :obj:`ClassifierFromVarFD` thus goes like this: 
    108118 
    109119.. literalinclude:: code/classifier-from-var-example.py 
  • docs/reference/rst/code/classifier-from-var-example.py

    r10123 r10361  
    1111        return 1 
    1212 
    13 e1.getValueFrom = Orange.classification.ClassifierFromVar() 
    14 e1.getValueFrom.whichVar = e 
    15 e1.getValueFrom.transformer = eTransformer 
     13e1.get_value_from = Orange.classification.ClassifierFromVar() 
     14e1.get_value_from.whichVar = e 
     15e1.get_value_from.transformer = eTransformer 
    1616 
    1717monks2 = monks.select(["a", "b", "e", e1, "y"]) 
     
    1919    print i 
    2020 
    21 e1.getValueFrom = Orange.classification.ClassifierFromVarFD() 
    22 e1.getValueFrom.domain = monks.domain 
    23 e1.getValueFrom.position = monks.domain.attributes.index(e) 
    24 e1.getValueFrom.transformer = eTransformer 
     21e1.get_value_from = Orange.classification.ClassifierFromVarFD() 
     22e1.get_value_from.domain = monks.domain 
     23e1.get_value_from.position = monks.domain.attributes.index(e) 
     24e1.get_value_from.transformer = eTransformer 
    2525 
Note: See TracChangeset for help on using the changeset viewer.