# source:trunk/lib/classifier/NCC.h@523

Last change on this file since 523 was 523, checked in by Peter, 17 years ago

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