1 | #ifndef theplu_yat_classifier_knn_uniform_h |
---|

2 | #define theplu_yat_classifier_knn_uniform_h |
---|

3 | |
---|

4 | // $Id: KNN_Uniform.h 1142 2008-02-25 14:32:35Z markus $ |
---|

5 | |
---|

6 | /* |
---|

7 | Copyright (C) 2008 Markus Ringnér |
---|

8 | |
---|

9 | This file is part of the yat library, http://trac.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 2 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 this program; if not, write to the Free Software |
---|

23 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
---|

24 | 02111-1307, USA. |
---|

25 | */ |
---|

26 | |
---|

27 | |
---|

28 | #include <vector> |
---|

29 | |
---|

30 | namespace theplu { |
---|

31 | namespace yat { |
---|

32 | |
---|

33 | namespace utility { |
---|

34 | class VectorBase; |
---|

35 | class VectorMutable; |
---|

36 | } |
---|

37 | |
---|

38 | namespace classifier { |
---|

39 | |
---|

40 | class Target; |
---|

41 | |
---|

42 | |
---|

43 | /// |
---|

44 | /// @brief A model of the concept \ref concept_neighbor_weighting to |
---|

45 | /// be used with KNN to weight the votes of the k nearest neighbors |
---|

46 | /// of a sample. |
---|

47 | /// |
---|

48 | /// KNN_Uniform weights the nearest neighbours uniformly |
---|

49 | /// so the total vote for a class is equal to the number of nearest |
---|

50 | /// neighbors belonging to the class. |
---|

51 | /// |
---|

52 | struct KNN_Uniform |
---|

53 | { |
---|

54 | /** |
---|

55 | The total vote for each class is calculated and returned in prediction. |
---|

56 | */ |
---|

57 | void operator()(const utility::VectorBase& distance, |
---|

58 | const std::vector<size_t> k_sorted, |
---|

59 | const Target& target, |
---|

60 | utility::VectorMutable& prediction) const; |
---|

61 | }; |
---|

62 | |
---|

63 | }}} // of namespace classifier, yat, and theplu |
---|

64 | |
---|

65 | #endif |
---|