source: trunk/lib/classifier/NCC.h @ 454

Last change on this file since 454 was 454, checked in by Markus Ringnér, 16 years ago

Added class for Nearest Centroid Classifier

File size: 1.3 KB
Line 
1// $Id$
2
3#ifndef _theplu_classifier_ncc_
4#define _theplu_classifier_ncc_
5
6#include <c++_tools/gslapi/matrix.h>
7#include <c++_tools/statistics/Score.h>
8
9#include <map>
10
11namespace theplu {
12namespace classifier { 
13
14  class Score;
15
16  ///
17  /// Class for Nearest Centroid Classification
18  ///
19
20  class NCC
21  {
22 
23  public:
24    ///
25    /// Default constructor (not implemented)
26    ///
27    NCC();
28
29    ///
30    /// Constructor taking the training data and the target vector as
31    /// input. Performs the training of the NCC.
32    ///
33    NCC(const gslapi::matrix&, const gslapi::vector&);
34
35    ///
36    /// @todo Copy constructor.
37    ///
38    NCC(const NCC&);
39
40    ///
41    /// @todo The istream constructor.
42    ///
43    NCC(std::istream&);
44         
45    const gslapi::matrix& centroids(void) const {return centroids_;}
46
47    const std::map<double,u_int>& classes(void) const {return classes_;}
48   
49
50    ///
51    /// Calculate the scores to each centroid for a test sample
52    ///
53    void predict(const gslapi::vector&, statistics::Score&, 
54                 gslapi::vector&);
55   
56  private:
57    gslapi::matrix centroids_;
58    std::map<double,u_int> classes_;
59  };
60
61  ///
62  /// The output operator for the NCC class.
63  ///
64  std::ostream& operator<< (std::ostream&, const NCC&);
65 
66 
67}} // of namespace svm and namespace theplu
68
69#endif
Note: See TracBrowser for help on using the repository browser.