# source:trunk/lib/statistics/Score.h@536

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

fixed problem with ConsensusInputranker? - Now all tests do pass

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