Changeset 7386:7742fd194b6e in orange


Ignore:
Timestamp:
02/04/11 09:46:19 (3 years ago)
Author:
mocnik <mocnik@…>
Branch:
default
Convert:
4a153279f284e0a08c93307240472c2f1e6005f2
Message:

Documentation modifications to use the right style in knn module.

File:
1 edited

Legend:

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

    r7327 r7386  
    4242    .. attribute:: k 
    4343     
    44     Number of neighbours. If set to 0 (which is also the default value), the  
    45     square root of the number of instances is used. 
     44        Number of neighbours. If set to 0 (which is also the default value),  
     45        the square root of the number of instances is used. 
    4646     
    4747    .. attribute:: rankWeight 
    4848     
    49     Enables weighting by ranks (default: :obj:`true`) 
     49        Enables weighting by ranks (default: :obj:`true`) 
    5050     
    5151    .. attribute:: distanceConstructor 
    5252     
    53     A component that constructs the object for measuring distances between  
    54     instances. 
     53        component that constructs the object for measuring distances between  
     54        instances. 
    5555 
    5656kNNLearner first constructs an object for measuring distances between  
     
    9090    .. attribute:: k 
    9191     
    92     Number of neighbours. If set to 0 (which is also the default value),  
    93     the square root of the number of examples is used. 
     92        Number of neighbours. If set to 0 (which is also the default value),  
     93        the square root of the number of examples is used. 
    9494     
    9595    .. attribute:: rankWeight 
    9696     
    97     Enables weighting by ranks (default: :obj:`true`). 
     97        Enables weighting by ranks (default: :obj:`true`). 
    9898     
    9999    .. attribute:: weightID 
    100100     
    101     ID of meta attribute with weights of examples 
     101        ID of meta attribute with weights of examples 
    102102     
    103103    .. attribute:: nExamples 
    104104     
    105     The number of learning instances. It is used to compute the number of  
    106     neighbours if :attr:`kNNClassifier.k` is zero. 
     105        The number of learning instances. It is used to compute the number of  
     106        neighbours if :attr:`kNNClassifier.k` is zero. 
    107107 
    108108When called to classify an instance, the classifier first calls  
     
    146146We will test the learner on 'iris' dataset. We shall split it onto train 
    147147(80%) and test (20%) sets, learn on training instances and test on five 
    148 randomly selected test instances. 
    149  
    150 First part of (`knnlearner.py`_, uses `iris.tab`_) 
     148randomly selected test instances, in part of  
     149(`knnlearner.py`_, uses `iris.tab`_): 
    151150 
    152151.. literalinclude:: code/knnExample1.py 
     
    168167classifiers. So there is not much point in changing the default. If you 
    169168decide to do so, you need to set the distanceConstructor to an instance 
    170 of one of the classes for distance measuring. 
    171  
    172 Second part of (`knnlearner.py`_, uses `iris.tab`_) 
     169of one of the classes for distance measuring. This can be seen in the following 
     170part of (`knnlearner.py`_, uses `iris.tab`_): 
    173171 
    174172.. literalinclude:: code/knnExample2.py 
     
    214212    .. attribute:: distance 
    215213     
    216     a component that measures distance between examples 
     214        a component that measures distance between examples 
    217215     
    218216    .. attribute:: examples 
    219217     
    220     a stored list of instances 
     218        a stored list of instances 
    221219     
    222220    .. attribute:: weightID 
    223221     
    224     ID of meta attribute with weight 
     222        ID of meta attribute with weight 
    225223     
    226224    .. method:: __call__(instance, n) 
     
    251249    .. attribute:: distanceConstructor 
    252250     
    253     A component of class ExamplesDistanceConstructor that "learns" to measure 
    254     distances between instances. Learning can be, for instances, storing the 
    255     ranges of continuous features or the number of value of a discrete feature 
    256     (see the page about measuring distances for more information). The result 
    257     of learning is an instance of ExamplesDistance that should be used for 
    258     measuring distances between instances. 
     251        A component of class ExamplesDistanceConstructor that "learns" to 
     252        measure distances between instances. Learning can be, for instances, 
     253        storing the ranges of continuous features or the number of value of 
     254        a discrete feature (see the page about measuring distances for more 
     255        information). The result of learning is an instance of  
     256        ExamplesDistance that should be used for measuring distances 
     257        between instances. 
    259258     
    260259    .. attribute:: includeSame 
    261260     
    262     Tells whether to include the examples that are same as the reference; 
    263     default is true. 
     261        Tells whether to include the examples that are same as the reference; 
     262        default is true. 
    264263     
    265264    .. method:: __call__(table, weightID, distanceID) 
     
    284283======= 
    285284 
    286 The following script shows how to find the five nearest neighbours of the 
    287 first instance in the lenses dataset. 
    288  
    289 (`knnInstanceDistance.py`_, uses `lenses.tab`_) 
     285The following script (`knnInstanceDistance.py`_, uses `lenses.tab`_)  
     286shows how to find the five nearest neighbours of the first instance 
     287in the lenses dataset. 
     288 
     289 
    290290 
    291291.. literalinclude:: code/knnInstanceDistance.py 
Note: See TracChangeset for help on using the changeset viewer.