Changeset 1115
- Timestamp:
- Feb 21, 2008, 8:20:59 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/concepts.doxygen
r1113 r1115 36 36 \section Description 37 37 38 \ref concept_distance is a concept .. 38 \ref concept_distance is a concept for classes implementing different 39 alternatives to calculate the distance between two points. 39 40 40 41 \section Requirements 41 42 42 Classes modelling the concept \ref concept_distance should implement ... 43 Classes modelling the concept \ref concept_distance should implement 44 the following public function: 45 46 \verbatim 47 template<typename Iter1, typename Iter2> 48 double operator() (Iter1 beg1, Iter1 end1, Iter2 beg2) const 49 \endverbatim 50 51 This function should calculate and return the distance between 52 elements of two ranges. The first range is given by [\a beg1, \a end1) 53 and the second range starts with \a beg2 and has the same length as 54 the first range. The function should support iterators of the category 55 std::forward_iterator. The function should provide both a fast 56 calculation for unweighted iterators and a calculation for weighted 57 iterators. The latter correspond to the case where elements in a range 58 have both a value and a weight. The selection between unweighted and 59 weighted implementations should utilize 60 theplu::yat::utility::weighted_iterator_tag. Moreover 61 theplu::yat::utility::weighted_if_any2 should be utilized to provide a 62 weighted implementation if any of the two ranges is weighted, and an 63 unweighted implementation when both ranges are unweighted. 64 65 \section Implementations 43 66 44 67 Examples of classes modelling the concept \ref concept_distance … … 60 83 61 84 Classes modelling the concept \ref concept_neighbor_weighting should 62 implement the following function:85 implement the following public function: 63 86 64 87 \verbatim … … 78 101 class. The total vote for each class is stored in the vector \a prediction. 79 102 103 \section Implementations 104 80 105 Examples of classes modelling the concept \ref 81 106 concept_neighbor_weighting include -
trunk/yat/classifier/KNN.h
r1112 r1115 46 46 /// @brief Class for Nearest Neigbor Classification. 47 47 /// 48 /// The template argument Distance should be a class implementing48 /// The template argument Distance should be a class modelling 49 49 /// the concept \ref concept_distance. 50 /// The template argument NeigborWeighting should be a class implementing50 /// The template argument NeigborWeighting should be a class modelling 51 51 /// the concept \ref concept_neighbor_weighting. 52 52 -
trunk/yat/classifier/NCC.h
r1112 r1115 56 56 /// @brief Class for Nearest Centroid Classification. 57 57 /// 58 /// The template argument Distance should be a class implementing58 /// The template argument Distance should be a class modelling 59 59 /// the concept \ref concept_distance. 60 60 /// -
trunk/yat/statistics/EuclideanDistance.h
r1093 r1115 38 38 /// 39 39 /// @brief Calculates the Euclidean distance between two points 40 /// stored in 1-dimensional containers. Implements the concept \ref 41 /// concept_distance. 40 /// given by elements of ranges. 41 /// 42 /// This class is modelling the concept \ref concept_distance. 42 43 /// 43 44 /// … … 45 46 { 46 47 /** 47 \brief Calculates the Euclidean distance between two ranges. 48 \brief Calculates the Euclidean distance between elements of 49 two ranges. 48 50 49 If both ranges are unweighted the distance is calculated as \f$ 50 \sqrt{\sum (x_i-y_i)^2 } \f$ 51 If elements of both ranges are unweighted the distance is 52 calculated as \f$ \sqrt{\sum (x_i-y_i)^2 } \f$, where \f$ x_i 53 \f$ and \f$ y_i \f$ are elements of the first and second range, 54 respectively. 51 55 52 Else distance is calculated as \f$ N \frac{\sum 53 w_xw_y(x-y)^2}{\sum w_xw_y} \f$ 56 If elements of one or both of ranges have weights the distance 57 is calculated as \f$ \sqrt{N \sum 58 w_{x,i}w_{y,i}(x_i-y_i)^2/\sum w_{x,i}w_{y,i}} \f$, where \f$ N 59 \f$ is the number of elements in the two ranges and \f$ w_x \f$ 60 and \f$ w_y \f$ are weights for the elements of the first and 61 the second range, respectively. If the elements of one of the 62 two ranges are unweighted, the weights for these elements are 63 set to unity. 54 64 */ 55 65 template <typename Iter1, typename Iter2> -
trunk/yat/statistics/PearsonDistance.h
r1092 r1115 35 35 36 36 /// 37 /// @brief Calculates the %Pearson correlation distance between two points stored in 1-dimensional containers. Implements the concept \ref concept_distance.37 /// @brief Calculates the %Pearson correlation distance between two points given by elements of ranges. 38 38 /// 39 /// This class is modelling the concept \ref concept_distance. 39 40 /// 40 41 struct PearsonDistance 41 42 { 42 /// 43 /// @brief Calculates the %Pearson correlation distance between two ranges. 44 /// 43 /** 44 \brief Calculates the %Pearson correlation distance between 45 elements of two ranges. 46 47 If elements of both ranges are unweighted the distance is 48 calculated as \f$ 1-\mbox{C}(x,y) \f$, where \f$ x \f$ and \f$ 49 y \f$ are the two points and C is the %Pearson correlation. 50 51 If elements of one or both of ranges have weights the distance 52 is calculated as \f$ 1-[\sum w_{x,i}w_{y,i}(x_i-y_i)^2/(\sum 53 w_{x,i}w_{y,i}(x_i-m_x)^2\sum w_{x,i}w_{y,i}(y_i-m_y)^2)] \f$, 54 where and \f$ w_x \f$ and \f$ w_y \f$ are weights for the 55 elements of the first and the second range, respectively, and 56 \f$ m_x=\sum w_{x,i}w_{y,i}x_i/\sum w_{x,i}w_{y,i} \f$ and 57 correspondingly for \f$ m_y \f$. If the elements of one of the 58 two ranges are unweighted, the weights for these elements are 59 set to unity. 60 */ 45 61 template <typename Iter1, typename Iter2> 46 62 double operator() -
trunk/yat/utility/iterator_traits.h
r1092 r1115 37 37 /** 38 38 Struct to be used to make compile-time decision that Iterator is 39 weighted. Some algorithms come in also in a weighted version in39 weighted. Some algorithms come also in a weighted version and 40 40 this tag could be used to decide on using them (rather than 41 unweighted cousin).41 the corresponding unweighted algorithm). 42 42 */ 43 43 struct weighted_iterator_tag {}; … … 109 109 110 110 /** 111 \brief traits to make unweighted iterator work in asa weighted111 \brief traits to make unweighted iterator work as in a weighted 112 112 113 113 This class must be implemented for every iterator that can be weighted.
Note: See TracChangeset
for help on using the changeset viewer.