source: trunk/c++_tools/statistics/Score.h @ 616

Last change on this file since 616 was 616, checked in by Jari Häkkinen, 15 years ago

Removed gslapi namespace and put the code into utility namespace.
Move #ifndef _header_ idiom to top of touched header files.
Removed unneccesary #includes, and added needed #includes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.9 KB
Line 
1#ifndef _theplu_statistics_score_
2#define _theplu_statistics_score_
3
4// $Id: Score.h 616 2006-08-31 08:52:02Z jari $
5
6#include <c++_tools/classifier/utility.h>
7#include <c++_tools/utility/vector.h>
8
9#include <cassert>
10#ifndef NDEGUG
11#include <c++_tools/classifier/Target.h>
12#include <c++_tools/classifier/DataLookup1D.h>
13#endif
14
15namespace theplu {
16namespace classifier {
17  class Target;
18  class DataLookup1D;
19}
20
21namespace statistics {
22
23  ///
24  /// Abstract Base Class defining the interface for the score classes.
25  ///
26  class Score
27  {
28
29  public:
30    ///
31    ///   Constructor
32    ///   
33    Score(bool absolute=true) ;
34   
35    ///
36    ///   Destructor
37    ///
38    virtual ~Score(void) {};
39   
40    ///
41    ///  Function changing mode of Score
42    ///
43    inline void absolute(bool absolute) {absolute_=absolute;}
44
45    ///
46    /// Function calculating the score. In absolute mode, also the
47    /// score using negated class labels is calculated, and the
48    /// largest of the two scores are calculated. Absolute mode should
49    /// be used when two-tailed test is wanted.
50    ///
51    virtual double 
52    score(const classifier::Target& target, 
53          const utility::vector& value) = 0; 
54 
55    ///
56    /// Function calculating the score. In absolute mode, also the
57    /// score using negated class labels is calculated, and the
58    /// largest of the two scores are calculated. Absolute mode should
59    /// be used when two-tailed test is wanted.
60    ///
61    /// @return statistica.
62    ///
63    /// @param target vector of targets (most often +1 -1)
64    /// @param value vector of the values
65    ///
66    inline double 
67    score(const classifier::Target& target, 
68          const classifier::DataLookup1D& value) 
69    { 
70      assert(target.size()==value.size()); 
71      utility::vector a;
72      classifier::convert(value,a);
73      return score(target,a); 
74    }
75 
76    ///
77    /// Function calculating the weighted version of score. In
78    /// absolute mode, also the score using negated class labels is
79    /// calculated, and the largest of the two scores are
80    /// calculated. Absolute mode should be used when two-tailed test
81    /// is wanted.
82    ///
83    virtual double 
84    score(const classifier::Target& target, 
85          const utility::vector& value,
86          const utility::vector& weight) = 0; 
87
88    ///
89    /// Function calculating the weighted version of score. In
90    /// absolute mode, also the score using negated class labels is
91    /// calculated, and the largest of the two scores are
92    /// calculated. Absolute mode should be used when two-tailed test
93    /// is wanted.
94    ///
95    inline double 
96    score(const classifier::Target& target, 
97          const classifier::DataLookup1D& value,
98          const classifier::DataLookup1D& weight) 
99    { 
100      utility::vector a;
101      classifier::convert(value,a);
102      utility::vector b;
103      classifier::convert(weight,a);
104      return score(target,a,b); 
105    }
106
107  protected:
108    inline bool weighted(void) const { return weighted_; }
109
110    bool absolute_;
111    bool weighted_;
112
113  }; // class Score
114
115}} // of namespace statistics and namespace theplu
116
117#endif
Note: See TracBrowser for help on using the repository browser.