1 | // $Id: Score.h 469 2005-12-19 14:58:29Z peter $ |
---|
2 | |
---|
3 | #ifndef _theplu_statistics_score_ |
---|
4 | #define _theplu_statistics_score_ |
---|
5 | |
---|
6 | namespace theplu { |
---|
7 | namespace classifier { |
---|
8 | class Target; |
---|
9 | class VectorAbstract; |
---|
10 | } |
---|
11 | |
---|
12 | namespace statistics { |
---|
13 | |
---|
14 | /// |
---|
15 | /// Abstract Base Class defining the interface for the score classes. |
---|
16 | /// |
---|
17 | class Score |
---|
18 | { |
---|
19 | |
---|
20 | public: |
---|
21 | /// |
---|
22 | /// Constructor |
---|
23 | /// |
---|
24 | Score(bool absolute=true) ; |
---|
25 | |
---|
26 | /// |
---|
27 | /// Destructor |
---|
28 | /// |
---|
29 | virtual ~Score(void) {}; |
---|
30 | |
---|
31 | /// |
---|
32 | /// Function changing mode of Score |
---|
33 | /// |
---|
34 | inline void absolute(bool absolute) {absolute_=absolute;} |
---|
35 | |
---|
36 | /// |
---|
37 | /// Targets with this label are considered to be in positive |
---|
38 | /// group. All others are considered to be in negative |
---|
39 | /// group. Default is 1. |
---|
40 | /// |
---|
41 | /// @return label for positive class |
---|
42 | /// |
---|
43 | inline int& positive_label(void) { return positive_label_; } |
---|
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 | /// @return statistica. |
---|
52 | /// |
---|
53 | /// @param target vector of targets (most often +1 -1) |
---|
54 | /// @param value vector of the values |
---|
55 | /// |
---|
56 | virtual double |
---|
57 | score(const classifier::Target& target, |
---|
58 | const classifier::VectorAbstract& value) = 0; |
---|
59 | |
---|
60 | /// |
---|
61 | /// Function calculating the weighted version of score. In |
---|
62 | /// absolute mode, also the score using negated class labels is |
---|
63 | /// calculated, and the largest of the two scores are |
---|
64 | /// calculated. Absolute mode should be used when two-tailed test |
---|
65 | /// is wanted. |
---|
66 | /// |
---|
67 | /// @return statistica (weighted version) |
---|
68 | /// |
---|
69 | /// @param target is +1 or -1 |
---|
70 | /// @param value vector of the values |
---|
71 | /// @param weight vector of accompanied weight to the values |
---|
72 | /// @train_set defining which values to use (number of values used |
---|
73 | /// in the calculation is equal to size of \a train_set) |
---|
74 | /// |
---|
75 | virtual double |
---|
76 | score(const classifier::Target& target, |
---|
77 | const classifier::VectorAbstract& value, |
---|
78 | const classifier::VectorAbstract& weight) = 0; |
---|
79 | |
---|
80 | inline bool class_one(int i) const { return i==positive_label_; } |
---|
81 | |
---|
82 | protected: |
---|
83 | inline bool weighted(void) const { return weighted_; } |
---|
84 | |
---|
85 | bool absolute_; |
---|
86 | int positive_label_; |
---|
87 | bool weighted_; |
---|
88 | |
---|
89 | }; // class Score |
---|
90 | |
---|
91 | }} // of namespace statistics and namespace theplu |
---|
92 | |
---|
93 | #endif |
---|