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

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

Added structure to Supervised classifier and NCC to support ranking inputs with a statistics::Score and using only top-scoring inputs in classification.

File size: 1.5 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
10#include <map>
11
12namespace theplu {
13
14  namespace statistics {
15    class Distance;
16    class Score;
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    NCC(const DataLookup2D&, const Target&, const statistics::Distance&, 
40        statistics::Score&, const size_t);
41
42    virtual ~NCC();
43
44    const gslapi::matrix& centroids(void) const {return centroids_;}
45
46    inline SupervisedClassifier* 
47    make_classifier(const DataLookup2D&, const Target&) const;
48   
49    bool train();
50
51
52    ///
53    /// Calculate the scores to each centroid for a test sample
54    ///
55    void predict(const DataLookup1D&, gslapi::vector&) const;
56   
57    ///
58    /// Calculate the scores to each centroid for test samples
59    ///
60    void predict(const DataLookup2D&, gslapi::matrix&) const;
61
62
63  private:
64    gslapi::matrix centroids_;
65    const statistics::Distance& distance_;                 
66    const DataLookup2D& matrix_;
67
68  };
69
70  ///
71  /// The output operator for the NCC class.
72  ///
73  std::ostream& operator<< (std::ostream&, const NCC&);
74 
75 
76}} // of namespace classifier and namespace theplu
77
78#endif
Note: See TracBrowser for help on using the repository browser.