Changeset 8066:9a2baba11942 in orange


Ignore:
Timestamp:
07/04/11 10:43:49 (3 years ago)
Author:
markotoplak
Branch:
default
Convert:
4ce168301855d769058045e7712c6389bae7f7e5
Message:

Replaced getValueFrom. References #850.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/Orange/classification/lookup.py

    r8042 r8066  
    1919 
    2020A natural habitat for these classifiers is feature construction: 
    21 they usually reside in :obj:`getValueFrom` fields of constructed 
     21they usually reside in :obj:`~Orange.data.variable.Variable.get_value_from` fields of constructed 
    2222features to facilitate their automatic computation. For instance, 
    2323the following script shows how to translate the `monks-1.tab`_ dataset 
     
    5757for instance:: 
    5858 
    59     e2.getValueFrom = lambda ex, rw: orange.Value(e2, ex["e"]=="1") 
     59    e2.get_value_from = lambda ex, rw: orange.Value(e2, ex["e"]=="1") 
    6060 
    6161 
     
    301301    ['1', '3', '2', '0'] <12.000, 0.000> 
    302302 
    303 ClassifierByDataTable will usually be used by getValueFrom. So, we 
     303ClassifierByDataTable will usually be used by :obj:`Orange.data.variable.Variable.get_value_from`. So, we 
    304304would probably continue this by constructing a new feature and put the 
    305 classifier into its getValueFrom. 
     305classifier into its :obj:`Orange.data.variable.Variable.get_value_from`. 
    306306 
    307307    >>> y2 = Orange.data.variable.Discrete("y2", values = ["0", "1"]) 
    308     >>> y2.getValueFrom = abe 
     308    >>> y2.get_value_from = abe 
    309309 
    310310There's something disturbing here. Although abe determines the value of 
     
    320320the new class variable and the features that should be used for 
    321321classification. This saves us from constructing data_s and reassigning 
    322 the class_var. It doesn't set the getValueFrom, though. 
     322the class_var. It doesn't set the :obj:`Orange.data.variable.Variable.get_value_from`, though. 
    323323 
    324324part of `lookup-table.py`_ (uses: `monks-1.tab`_):: 
     
    408408        >>> newVar = Orange.data.variable.Discrete("a=b", values=["no", "yes"]) 
    409409        >>> lookup = lookup_from_function(newVar, bound, lambda x: x[0]==x[1]) 
    410         >>> newVar.getValueFrom = lookup 
     410        >>> newVar.get_value_from = lookup 
    411411        >>> import orngCI 
    412412        >>> table2 = orngCI.addAnAttribute(newVar, table) 
     
    425425 
    426426    The feature was inserted with use of orngCI.addAnAttribute. By setting 
    427     newVar.getValueFrom to lookup we state that when converting domains 
     427    newVar.get_value_from to lookup we state that when converting domains 
    428428    (either when needed by addAnAttribute or at some other place), lookup 
    429429    should be used to compute newVar's value. (A bit off topic, but 
    430     important: you should never call getValueFrom directly, but always call 
     430    important: you should never call :obj:`Orange.data.variable.Variable.get_value_from` directly, but always call 
    431431    it through computeValue.) 
    432432 
     
    449449    dump_lookup_function returns a string with a lookup function in 
    450450    tab-delimited format. Argument func can be any of the above-mentioned 
    451     classifiers or a feature whose getValueFrom points to one of such 
     451    classifiers or a feature whose :obj:`Orange.data.variable.Variable.get_value_from` points to one of such 
    452452    classifiers. 
    453453 
     
    541541def dump_lookup_function(func): 
    542542    if isinstance(func, Orange.data.variable.Variable): 
    543         if not func.getValueFrom: 
     543        if not func.get_value_from: 
    544544            raise TypeError, "attribute '%s' does not have an associated function" % func.name 
    545545        else: 
    546             func = func.getValueFrom 
     546            func = func.get_value_from 
    547547 
    548548    outp = "" 
Note: See TracChangeset for help on using the changeset viewer.