yat/classifier/KNN_ReciprocalRank.h

Code
Comments
Other
Rev Date Author Line
1112 21 Feb 08 markus 1 #ifndef theplu_yat_classifier_knn_reciprocal_rank_h
1112 21 Feb 08 markus 2 #define theplu_yat_classifier_knn_reciprocal_rank_h
1112 21 Feb 08 markus 3
1112 21 Feb 08 markus 4 // $Id$
1112 21 Feb 08 markus 5
1142 25 Feb 08 markus 6 /*
2119 12 Dec 09 peter 7   Copyright (C) 2008 Jari Häkkinen, Peter Johansson, Markus Ringnér
2986 18 Feb 13 peter 8   Copyright (C) 2013 Jari Häkkinen
1112 21 Feb 08 markus 9
1437 25 Aug 08 peter 10   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 12   The yat library is free software; you can redistribute it and/or
1142 25 Feb 08 markus 13   modify it under the terms of the GNU General Public License as
1486 09 Sep 08 jari 14   published by the Free Software Foundation; either version 3 of the
1142 25 Feb 08 markus 15   License, or (at your option) any later version.
1142 25 Feb 08 markus 16
1142 25 Feb 08 markus 17   The yat library is distributed in the hope that it will be useful,
1142 25 Feb 08 markus 18   but WITHOUT ANY WARRANTY; without even the implied warranty of
1142 25 Feb 08 markus 19   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1142 25 Feb 08 markus 20   General Public License for more details.
1142 25 Feb 08 markus 21
1142 25 Feb 08 markus 22   You should have received a copy of the GNU General Public License
1487 10 Sep 08 jari 23   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 43   /// @brief A model of the concept \ref concept_neighbor_weighting to
1112 21 Feb 08 markus 44   /// be used with KNN to weight the votes of the k nearest neighbors
4200 19 Aug 22 peter 45   /// of a sample.
1112 21 Feb 08 markus 46   ///
1112 21 Feb 08 markus 47   /// KNN_ReciprocalRank weights the vote of a nearest neighbor with
1112 21 Feb 08 markus 48   /// its reciprocal rank. The class of the nearest neighbor gets
1112 21 Feb 08 markus 49   /// the vote 1/1, the class of the second nearest neighbor gets the
1112 21 Feb 08 markus 50   /// vote 1/2, and so on
1112 21 Feb 08 markus 51   ///
1112 21 Feb 08 markus 52   struct KNN_ReciprocalRank
4200 19 Aug 22 peter 53   {
1112 21 Feb 08 markus 54     /**
1112 21 Feb 08 markus 55        The total vote for each class is calculated and returned in prediction.
1112 21 Feb 08 markus 56     */
1112 21 Feb 08 markus 57     void operator()(const utility::VectorBase& distance,
1522 23 Sep 08 peter 58                     const std::vector<size_t>& k_sorted,
4200 19 Aug 22 peter 59                     const Target& target,
4200 19 Aug 22 peter 60                     utility::VectorMutable& prediction) const;
1112 21 Feb 08 markus 61   };
1112 21 Feb 08 markus 62
1112 21 Feb 08 markus 63 }}} // of namespace classifier, yat, and theplu
4200 19 Aug 22 peter 64
1112 21 Feb 08 markus 65 #endif