1112 |
21 Feb 08 |
markus |
1 |
#ifndef theplu_yat_classifier_knn_uniform_h |
1112 |
21 Feb 08 |
markus |
2 |
#define theplu_yat_classifier_knn_uniform_h |
1112 |
21 Feb 08 |
markus |
3 |
|
1112 |
21 Feb 08 |
markus |
// $Id$ |
1112 |
21 Feb 08 |
markus |
5 |
|
1142 |
25 Feb 08 |
markus |
6 |
/* |
2119 |
12 Dec 09 |
peter |
Copyright (C) 2008 Jari Häkkinen, Peter Johansson, Markus Ringnér |
2986 |
18 Feb 13 |
peter |
Copyright (C) 2013 Jari Häkkinen |
1142 |
25 Feb 08 |
markus |
9 |
|
1437 |
25 Aug 08 |
peter |
This file is part of the yat library, http://dev.thep.lu.se/yat |
1142 |
25 Feb 08 |
markus |
11 |
|
1142 |
25 Feb 08 |
markus |
The yat library is free software; you can redistribute it and/or |
1142 |
25 Feb 08 |
markus |
modify it under the terms of the GNU General Public License as |
1486 |
09 Sep 08 |
jari |
published by the Free Software Foundation; either version 3 of the |
1142 |
25 Feb 08 |
markus |
License, or (at your option) any later version. |
1142 |
25 Feb 08 |
markus |
16 |
|
1142 |
25 Feb 08 |
markus |
The yat library is distributed in the hope that it will be useful, |
1142 |
25 Feb 08 |
markus |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
1142 |
25 Feb 08 |
markus |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1142 |
25 Feb 08 |
markus |
General Public License for more details. |
1142 |
25 Feb 08 |
markus |
21 |
|
1142 |
25 Feb 08 |
markus |
You should have received a copy of the GNU General Public License |
1487 |
10 Sep 08 |
jari |
along with yat. If not, see <http://www.gnu.org/licenses/>. |
1142 |
25 Feb 08 |
markus |
24 |
*/ |
1142 |
25 Feb 08 |
markus |
25 |
|
2966 |
23 Jan 13 |
jari |
26 |
#include <cstddef> |
1112 |
21 Feb 08 |
markus |
27 |
#include <vector> |
1112 |
21 Feb 08 |
markus |
28 |
|
1112 |
21 Feb 08 |
markus |
29 |
namespace theplu { |
1112 |
21 Feb 08 |
markus |
30 |
namespace yat { |
4200 |
19 Aug 22 |
peter |
31 |
|
1112 |
21 Feb 08 |
markus |
32 |
namespace utility { |
1112 |
21 Feb 08 |
markus |
33 |
class VectorBase; |
1112 |
21 Feb 08 |
markus |
34 |
class VectorMutable; |
1112 |
21 Feb 08 |
markus |
35 |
} |
1112 |
21 Feb 08 |
markus |
36 |
|
1112 |
21 Feb 08 |
markus |
37 |
namespace classifier { |
1112 |
21 Feb 08 |
markus |
38 |
|
1112 |
21 Feb 08 |
markus |
39 |
class Target; |
1112 |
21 Feb 08 |
markus |
40 |
|
4200 |
19 Aug 22 |
peter |
41 |
|
1112 |
21 Feb 08 |
markus |
42 |
/// |
1112 |
21 Feb 08 |
markus |
/// @brief A model of the concept \ref concept_neighbor_weighting to |
1112 |
21 Feb 08 |
markus |
/// be used with KNN to weight the votes of the k nearest neighbors |
4200 |
19 Aug 22 |
peter |
/// of a sample. |
1112 |
21 Feb 08 |
markus |
46 |
/// |
1112 |
21 Feb 08 |
markus |
/// KNN_Uniform weights the nearest neighbours uniformly |
1112 |
21 Feb 08 |
markus |
/// so the total vote for a class is equal to the number of nearest |
1112 |
21 Feb 08 |
markus |
/// neighbors belonging to the class. |
1112 |
21 Feb 08 |
markus |
50 |
/// |
1112 |
21 Feb 08 |
markus |
51 |
struct KNN_Uniform |
4200 |
19 Aug 22 |
peter |
52 |
{ |
1112 |
21 Feb 08 |
markus |
53 |
/** |
4200 |
19 Aug 22 |
peter |
The total vote for each class is calculated and returned in prediction. |
1112 |
21 Feb 08 |
markus |
55 |
*/ |
1112 |
21 Feb 08 |
markus |
56 |
void operator()(const utility::VectorBase& distance, |
4200 |
19 Aug 22 |
peter |
57 |
const std::vector<size_t>& k_sorted, |
4200 |
19 Aug 22 |
peter |
58 |
const Target& target, |
4200 |
19 Aug 22 |
peter |
59 |
utility::VectorMutable& prediction) const; |
1112 |
21 Feb 08 |
markus |
60 |
}; |
1112 |
21 Feb 08 |
markus |
61 |
|
1112 |
21 Feb 08 |
markus |
62 |
}}} // of namespace classifier, yat, and theplu |
4200 |
19 Aug 22 |
peter |
63 |
|
1112 |
21 Feb 08 |
markus |
64 |
#endif |