1 | #ifndef theplu_yat_classifier_knn_uniform_h |
---|
2 | #define theplu_yat_classifier_knn_uniform_h |
---|
3 | |
---|
4 | // $Id: KNN_Uniform.h 2966 2013-01-23 21:42:08Z jari $ |
---|
5 | |
---|
6 | /* |
---|
7 | Copyright (C) 2008 Jari Häkkinen, Peter Johansson, 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 <cstddef> |
---|
27 | #include <vector> |
---|
28 | |
---|
29 | namespace theplu { |
---|
30 | namespace yat { |
---|
31 | |
---|
32 | namespace utility { |
---|
33 | class VectorBase; |
---|
34 | class VectorMutable; |
---|
35 | } |
---|
36 | |
---|
37 | namespace classifier { |
---|
38 | |
---|
39 | class Target; |
---|
40 | |
---|
41 | |
---|
42 | /// |
---|
43 | /// @brief A model of the concept \ref concept_neighbor_weighting to |
---|
44 | /// be used with KNN to weight the votes of the k nearest neighbors |
---|
45 | /// of a sample. |
---|
46 | /// |
---|
47 | /// KNN_Uniform weights the nearest neighbours uniformly |
---|
48 | /// so the total vote for a class is equal to the number of nearest |
---|
49 | /// neighbors belonging to the class. |
---|
50 | /// |
---|
51 | struct KNN_Uniform |
---|
52 | { |
---|
53 | /** |
---|
54 | The total vote for each class is calculated and returned in prediction. |
---|
55 | */ |
---|
56 | void operator()(const utility::VectorBase& distance, |
---|
57 | const std::vector<size_t>& k_sorted, |
---|
58 | const Target& target, |
---|
59 | utility::VectorMutable& prediction) const; |
---|
60 | }; |
---|
61 | |
---|
62 | }}} // of namespace classifier, yat, and theplu |
---|
63 | |
---|
64 | #endif |
---|