1 | // $Id: concepts.doxygen 1545 2008-10-01 15:14:42Z peter $ |
---|
2 | // |
---|
3 | // Copyright (C) 2008 Peter Johansson, Markus Ringnér |
---|
4 | // |
---|
5 | // This file is part of the yat library, http://dev.thep.lu.se/yat |
---|
6 | // |
---|
7 | // The yat library is free software; you can redistribute it and/or |
---|
8 | // modify it under the terms of the GNU General Public License as |
---|
9 | // published by the Free Software Foundation; either version 3 of the |
---|
10 | // License, or (at your option) any later version. |
---|
11 | // |
---|
12 | // The yat library is distributed in the hope that it will be useful, |
---|
13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
15 | // General Public License for more details. |
---|
16 | // |
---|
17 | // You should have received a copy of the GNU General Public License |
---|
18 | // along with yat. If not, see <http://www.gnu.org/licenses/>. |
---|
19 | |
---|
20 | |
---|
21 | /** |
---|
22 | \page Concepts Concepts |
---|
23 | |
---|
24 | This page lists all the C++ concepts in the yat project. |
---|
25 | |
---|
26 | - \subpage concept_container_2d |
---|
27 | - \subpage concept_mutable_container_2d |
---|
28 | - \subpage concept_distance |
---|
29 | - \subpage concept_neighbor_weighting |
---|
30 | */ |
---|
31 | |
---|
32 | |
---|
33 | /** |
---|
34 | \page concept_container_2d Container2D |
---|
35 | |
---|
36 | \section Description |
---|
37 | |
---|
38 | \ref concept_container_2d is a concept... |
---|
39 | |
---|
40 | \section Requirements |
---|
41 | |
---|
42 | Classes modelling the concept \ref concept_container_2d should implement |
---|
43 | the following public function: ... |
---|
44 | |
---|
45 | \section Implementations |
---|
46 | |
---|
47 | Examples of classes modelling the concept \ref concept_container_2d |
---|
48 | include ... |
---|
49 | |
---|
50 | */ |
---|
51 | |
---|
52 | /** |
---|
53 | \page concept_mutable_container_2d MutableContainer2D |
---|
54 | |
---|
55 | \section Description |
---|
56 | |
---|
57 | \ref concept_mutable_container_2d is a concept... |
---|
58 | |
---|
59 | \section Requirements |
---|
60 | |
---|
61 | \section Implementations |
---|
62 | |
---|
63 | Examples of classes modelling the concept \ref |
---|
64 | concept_mutable_container_2d include ... |
---|
65 | |
---|
66 | */ |
---|
67 | |
---|
68 | /** |
---|
69 | \page concept_distance Distance |
---|
70 | |
---|
71 | \section Description |
---|
72 | |
---|
73 | \ref concept_distance is a concept for classes implementing different |
---|
74 | alternatives to calculate the distance between two points. |
---|
75 | |
---|
76 | \section Requirements |
---|
77 | |
---|
78 | Classes modelling the concept \ref concept_distance should implement |
---|
79 | the following public function: |
---|
80 | |
---|
81 | \verbatim |
---|
82 | template<typename Iter1, typename Iter2> |
---|
83 | double operator() (Iter1 beg1, Iter1 end1, Iter2 beg2) const |
---|
84 | \endverbatim |
---|
85 | |
---|
86 | This function should calculate and return the distance between |
---|
87 | elements of two ranges. The first range is given by [\a beg1, \a end1) |
---|
88 | and the second range starts with \a beg2 and has the same length as |
---|
89 | the first range. The function should support iterators of the category |
---|
90 | std::forward_iterator. The function should provide both a fast |
---|
91 | calculation for unweighted iterators and a calculation for weighted |
---|
92 | iterators. The latter correspond to the case where elements in a range |
---|
93 | have both a value and a weight. The selection between unweighted and |
---|
94 | weighted implementations should utilize |
---|
95 | theplu::yat::utility::unweighted_iterator_tag and |
---|
96 | theplu::yat::utility::weighted_iterator_tag. Moreover |
---|
97 | theplu::yat::utility::weighted_if_any2 should be utilized to provide a |
---|
98 | weighted implementation if any of the two ranges is weighted, and an |
---|
99 | unweighted implementation when both ranges are unweighted. |
---|
100 | |
---|
101 | \section Implementations |
---|
102 | |
---|
103 | Examples of classes modelling the concept \ref concept_distance |
---|
104 | include theplu::yat::statistics::PearsonDistance and |
---|
105 | theplu::yat::statistics::EuclideanDistance. |
---|
106 | |
---|
107 | \see \ref weighted_distance |
---|
108 | |
---|
109 | */ |
---|
110 | |
---|
111 | /** |
---|
112 | \page concept_neighbor_weighting Neighbor Weighting Method |
---|
113 | |
---|
114 | \section Description |
---|
115 | |
---|
116 | \ref concept_neighbor_weighting is a concept used in connection with |
---|
117 | theplu::yat::classifier::KNN - classes used as the template argument |
---|
118 | NeighborWeighting should implement this concept. |
---|
119 | |
---|
120 | \section Requirements |
---|
121 | |
---|
122 | Classes modelling the concept \ref concept_neighbor_weighting should |
---|
123 | implement the following public function: |
---|
124 | |
---|
125 | \verbatim |
---|
126 | void operator()(const utility::VectorBase& distance, |
---|
127 | const std::vector<size_t>& k_sorted, |
---|
128 | const Target& target, |
---|
129 | utility::VectorMutable& prediction) const |
---|
130 | \endverbatim |
---|
131 | |
---|
132 | For a test sample, this function should calculate a total vote |
---|
133 | (i.e. based on all k nearest neighbors) for each class. The vector \a |
---|
134 | distance contains the distances from a test sample to all training |
---|
135 | samples. The vector \a k_sorted contains the indices (for both \a |
---|
136 | distance and \a target) to the k training samples with the smallest |
---|
137 | distances to the test sample. The class for each training sample is |
---|
138 | given by \a target, which is sorted in the same sample order as \a |
---|
139 | distance. For each class the function calculates a total vote based on |
---|
140 | the the nearest neighbors of the test sample that belong to the |
---|
141 | class. The total vote for each class is stored in the vector \a |
---|
142 | prediction. The function should be implemented such that nearest |
---|
143 | neighbors with distance infinity do not vote. |
---|
144 | |
---|
145 | \section Implementations |
---|
146 | |
---|
147 | Examples of classes modelling the concept \ref |
---|
148 | concept_neighbor_weighting include |
---|
149 | theplu::yat::classifier::KNN_Uniform, |
---|
150 | theplu::yat::classifier::KNN_ReciprocalDistance and |
---|
151 | theplu::yat::classifier::KNN_ReciprocalRank. |
---|
152 | |
---|
153 | */ |
---|