source: trunk/yat/classifier/KNN_ReciprocalDistance.h @ 1615

Last change on this file since 1615 was 1522, checked in by Peter, 13 years ago

passing by reference rather than by value

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.6 KB
Line 
1#ifndef theplu_yat_classifier_knn_reciprocal_distance_h
2#define theplu_yat_classifier_knn_reciprocal_distance_h
3
4// $Id: KNN_ReciprocalDistance.h 1522 2008-09-23 13:41:19Z peter $
5
6/*
7  Copyright (C) 2008 Markus Ringnér
8
9  This file is part of the yat library, http://dev.thep.lu.se/yat
10
11  The yat library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 3 of the
14  License, or (at your option) any later version.
15
16  The yat library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20
21  You should have received a copy of the GNU General Public License
22  along with yat. If not, see <http://www.gnu.org/licenses/>.
23*/
24
25
26#include <vector>
27
28namespace theplu {
29namespace yat {
30 
31  namespace utility {
32    class VectorBase;
33    class VectorMutable;
34  }
35
36namespace classifier {
37
38  class Target;
39 
40  ///
41  /// @brief A model of the concept \ref concept_neighbor_weighting to
42  /// be used with KNN to weight the votes of the k nearest neighbors
43  /// of a sample.
44  ///
45  /// KNN_ReciprocalDistance weights the vote of a nearest neighbor with
46  /// its reciprocal rank.
47  struct KNN_ReciprocalDistance
48  {   
49    /**
50       The total vote for each class is calculated and returned in prediction.
51    */
52    void operator()(const utility::VectorBase& dist,
53                    const std::vector<size_t>& k_sorted,
54                    const Target& target, 
55                    utility::VectorMutable& prediction) const;   
56  };
57
58}}} // of namespace classifier, yat, and theplu
59   
60#endif
Note: See TracBrowser for help on using the repository browser.