Changeset 7585:2e5c9bc0dc57 in orange


Ignore:
Timestamp:
02/05/11 00:04:13 (3 years ago)
Author:
blaz <blaz.zupan@…>
Branch:
default
Convert:
fb4a3dfe2cedc2960f605dd2f85c92ccf6317e8a
Message:

corrected few typos, changed section styles

File:
1 edited

Legend:

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

    r7402 r7585  
    33.. index: 
    44   single: classification; k-nearest neighbors (kNN) 
    5  
    6 The module includes implementation of `nearest neighbors algorithm <http://en.wikipedia.org/wiki/K-nearest_neighbor_algorithm>`_ and classes 
     5    
     6******************* 
     7k-nearest neighbors 
     8******************* 
     9 
     10The module includes implementation of `nearest neighbors  
     11algorithm <http://en.wikipedia.org/wiki/K-nearest_neighbor_algorithm>`_ and classes 
    712for finding nearest instances according to chosen distance metrics. 
    813 
    9 ============================ 
    10 k-Nearest Neighbor Algorithm 
     14k-nearest neighbor algorithm 
    1115============================ 
    1216 
     
    4549    .. attribute:: k 
    4650     
    47         Number of neighbours. If set to 0 (which is also the default value),  
     51        Number of neighbors. If set to 0 (which is also the default value),  
    4852        the square root of the number of instances is used. 
    4953     
     
    8387    .. method:: findNearest(instance) 
    8488     
    85     A component that finds nearest neighbours of a given instance. 
     89    A component that finds nearest neighbors of a given instance. 
    8690         
    8791    :param instance: given instance 
     
    9397    .. attribute:: k 
    9498     
    95         Number of neighbours. If set to 0 (which is also the default value),  
     99        Number of neighbors. If set to 0 (which is also the default value),  
    96100        the square root of the number of examples is used. 
    97101     
     
    111115When called to classify an instance, the classifier first calls  
    112116:meth:`kNNClassifier.findNearest`  
    113 to retrieve a list with :attr:`kNNClassifier.k` nearest neighbours. The 
     117to retrieve a list with :attr:`kNNClassifier.k` nearest neighbors. The 
    114118component :meth:`kNNClassifier.findNearest` has  
    115119a stored table of instances (those that have been passed to the learner)  
    116120together with their weights. If instances are weighted (non-zero  
    117 :obj:`weightID`), weights are considered when counting the neighbours. 
    118  
    119 If :meth:`kNNClassifier.findNearest` returns only one neighbour  
     121:obj:`weightID`), weights are considered when counting the neighbors. 
     122 
     123If :meth:`kNNClassifier.findNearest` returns only one neighbor  
    120124(this is the case if :obj:`k=1`), :class:`kNNClassifier` returns the 
    121125neighbour's class. 
     
    130134* if :obj:`rankWeight` is :obj:`false`, :obj:`t` is a distance from the 
    131135  instance being classified 
    132 * if :obj:`rankWeight` is :obj:`true`, neighbours are ordered and :obj:`t` 
    133   is the position of the neighbour on the list (a rank) 
     136* if :obj:`rankWeight` is :obj:`true`, neighbors are ordered and :obj:`t` 
     137  is the position of the neighbor on the list (a rank) 
    134138 
    135139 
     
    138142 
    139143Weighting gives the classifier certain insensitivity to the number of 
    140 neighbours used, making it possible to use large :obj:`k`'s. 
     144neighbors used, making it possible to use large :obj:`k`'s. 
    141145 
    142146The classifier can treat continuous and discrete features, and can even 
     
    145149 
    146150Examples 
    147 ======== 
    148  
    149 We will test the learner on 'iris' dataset. We shall split it onto train 
     151-------- 
     152 
     153We will test the learner on 'iris' data set. We shall split it onto train 
    150154(80%) and test (20%) sets, learn on training instances and test on five 
    151155randomly selected test instances, in part of  
     
    162166    Iris-setosa Iris-setosa 
    163167 
    164 The secret of kNN's success is that the instances in iris dataset appear in 
    165 three well separated clusters. The classifier's accuraccy will remain 
    166 excellent even with very large or small number of neighbours. 
     168The secret of kNN's success is that the instances in iris data set appear in 
     169three well separated clusters. The classifier's accuracy will remain 
     170excellent even with very large or small number of neighbors. 
    167171 
    168172As many experiments have shown, a selection of instances distance measure 
     
    190194.. index: fnn 
    191195 
    192 ========================== 
    193 Finding Nearest Neighbours 
    194 ========================== 
    195  
    196 Orange provides classes for finding the nearest neighbours of the given 
     196 
     197Finding nearest neighbors 
     198========================= 
     199 
     200Orange provides classes for finding the nearest neighbors of the given 
    197201reference instance. While we might add some smarter classes in future, we 
    198 now have only two - abstract classes that defines the general behaviour of 
    199 neighbour searching classes, and classes that implement brute force search. 
     202now have only two - abstract classes that defines the general behavior of 
     203neighbor searching classes, and classes that implement brute force search. 
    200204 
    201205As usually in Orange, there is a pair of classes: a class that does the work 
     
    283287        :rtype: :class:`FindNearest` 
    284288 
    285 Example 
    286 ======= 
     289Examples 
     290-------- 
    287291 
    288292The following script (`knnInstanceDistance.py`_, uses `lenses.tab`_)  
    289293shows how to find the five nearest neighbours of the first instance 
    290294in the lenses dataset. 
    291  
    292  
    293295 
    294296.. literalinclude:: code/knnInstanceDistance.py 
Note: See TracChangeset for help on using the changeset viewer.