Ignore:
Timestamp:
03/23/11 10:18:18 (3 years ago)
Author:
mocnik <mocnik@…>
Branch:
default
Convert:
d416bc8d106a54fb5f0e7e5875f6194778923631
Message:

Changing documentation to use underscores.

File:
1 edited

Legend:

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

    r7585 r7775  
    5252        the square root of the number of instances is used. 
    5353     
    54     .. attribute:: rankWeight 
     54    .. attribute:: rank_weight 
    5555     
    5656        Enables weighting by ranks (default: :obj:`true`) 
    5757     
    58     .. attribute:: distanceConstructor 
     58    .. attribute:: distance_constructor 
    5959     
    6060        component that constructs the object for measuring distances between  
     
    6262 
    6363kNNLearner first constructs an object for measuring distances between  
    64 instances. distanceConstructor is used if given; otherwise, Euclidean  
     64instances. distance_constructor is used if given; otherwise, Euclidean  
    6565metrics will be used. :class:`kNNLearner` then constructs an instance of  
    6666:class:`FindNearest_BruteForce`. Together with ID of meta feature with  
    67 weights of instances, :attr:`kNNLearner.k` and :attr:`kNNLearner.rankWeight`, 
     67weights of instances, :attr:`kNNLearner.k` and :attr:`kNNLearner.rank_weight`, 
    6868it is passed to a :class:`kNNClassifier`. 
    6969 
     
    7878        :param return_type: return value and probabilities, only value or only 
    7979                            probabilities 
    80         :type return_type: Orange.classifier.getBoth,  
    81                            Orange.classifier.getValue, 
    82                            Orange.classifier.getProbilities 
     80        :type return_type: Orange.classification.Classifier.GetBoth,  
     81                           Orange.classification.Classifier.GetValue, 
     82                           Orange.classification.Classifier.GetProbilities 
    8383         
    8484        :rtype: :class:`Orange.data.Value`, 
    8585                :class:`Orange.statistics.distribution`, or a tuple with both 
    8686         
    87     .. method:: findNearest(instance) 
     87    .. method:: find_nearest(instance) 
    8888     
    8989    A component that finds nearest neighbors of a given instance. 
     
    100100        the square root of the number of examples is used. 
    101101     
    102     .. attribute:: rankWeight 
     102    .. attribute:: rank_weight 
    103103     
    104104        Enables weighting by ranks (default: :obj:`true`). 
    105105     
    106     .. attribute:: weightID 
     106    .. attribute:: weight_ID 
    107107     
    108108        ID of meta attribute with weights of examples 
    109109     
    110     .. attribute:: nExamples 
     110    .. attribute:: n_examples 
    111111     
    112112        The number of learning instances. It is used to compute the number of  
     
    114114 
    115115When called to classify an instance, the classifier first calls  
    116 :meth:`kNNClassifier.findNearest`  
     116:meth:`kNNClassifier.find_nearest`  
    117117to retrieve a list with :attr:`kNNClassifier.k` nearest neighbors. The 
    118 component :meth:`kNNClassifier.findNearest` has  
     118component :meth:`kNNClassifier.find_nearest` has  
    119119a stored table of instances (those that have been passed to the learner)  
    120120together with their weights. If instances are weighted (non-zero  
    121 :obj:`weightID`), weights are considered when counting the neighbors. 
    122  
    123 If :meth:`kNNClassifier.findNearest` returns only one neighbor  
     121:obj:`weight_ID`), weights are considered when counting the neighbors. 
     122 
     123If :meth:`kNNClassifier.find_nearest` returns only one neighbor  
    124124(this is the case if :obj:`k=1`), :class:`kNNClassifier` returns the 
    125125neighbour's class. 
     
    130130neighbours have greater impact on the prediction; weight of instance 
    131131is computed as exp(-t:sup:`2`/s:sup:`2`), where the meaning of t depends 
    132 on the setting of :obj:`rankWeight`. 
    133  
    134 * if :obj:`rankWeight` is :obj:`false`, :obj:`t` is a distance from the 
     132on the setting of :obj:`rank_weight`. 
     133 
     134* if :obj:`rank_weight` is :obj:`false`, :obj:`t` is a distance from the 
    135135  instance being classified 
    136 * if :obj:`rankWeight` is :obj:`true`, neighbors are ordered and :obj:`t` 
     136* if :obj:`rank_weight` is :obj:`true`, neighbors are ordered and :obj:`t` 
    137137  is the position of the neighbor on the list (a rank) 
    138138 
     
    173173does not have a greater and predictable effect on the performance of kNN 
    174174classifiers. So there is not much point in changing the default. If you 
    175 decide to do so, you need to set the distanceConstructor to an instance 
     175decide to do so, you need to set the distance_constructor to an instance 
    176176of one of the classes for distance measuring. This can be seen in the following 
    177177part of (`knnlearner.py`_, uses `iris.tab`_): 
     
    225225        a stored list of instances 
    226226     
    227     .. attribute:: weightID 
     227    .. attribute:: weight_ID 
    228228     
    229229        ID of meta attribute with weight 
     
    242242 
    243243    A class that constructs FindNearest. It calls the inherited  
    244     distanceConstructor and then passes the constructed distance measure, 
    245     among with instances, weightIDand distanceID, to the just constructed 
     244    distance_constructor and then passes the constructed distance measure, 
     245    among with instances, weight_ID and distance_ID, to the just constructed 
    246246    instance of FindNearest_BruteForce. 
    247247     
     
    254254    is called. 
    255255     
    256     .. attribute:: distanceConstructor 
     256    .. attribute:: distance_constructor 
    257257     
    258258        A component of class ExamplesDistanceConstructor that "learns" to 
     
    264264        between instances. 
    265265     
    266     .. attribute:: includeSame 
     266    .. attribute:: include_same 
    267267     
    268268        Tells whether to include the examples that are same as the reference; 
     
    272272     
    273273        Constructs an instance of FindNearest that would return neighbours of 
    274         a given instance, obeying weightID when counting them (also, some  
     274        a given instance, obeying weight_ID when counting them (also, some  
    275275        measures of distance might consider weights as well) and store the  
    276         distances in a meta attribute with ID distanceID. 
     276        distances in a meta attribute with ID distance_ID. 
    277277     
    278278        :param table: table of instances 
    279279        :type table: Orange.data.Table 
    280280         
    281         :param weightID: id of meta attribute with weights of instances 
    282         :type weightID: int 
    283          
    284         :param distanceID: id of meta attribute that will save distances 
    285         :type distanceID: int 
     281        :param weight_ID: id of meta attribute with weights of instances 
     282        :type weight_ID: int 
     283         
     284        :param distance_ID: id of meta attribute that will save distances 
     285        :type distance_ID: int 
    286286         
    287287        :rtype: :class:`FindNearest` 
Note: See TracChangeset for help on using the changeset viewer.