source: trunk/yat/statistics/tScore.cc @ 1797

Last change on this file since 1797 was 1797, checked in by Peter, 15 years ago

updating copyright statements

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.1 KB
Line 
1// $Id: tScore.cc 1797 2009-02-12 18:07:10Z peter $
2
3/*
4  Copyright (C) 2004 Jari Häkkinen, Peter Johansson
5  Copyright (C) 2005 Peter Johansson
6  Copyright (C) 2006 Jari Häkkinen, Peter Johansson, Markus Ringnér
7  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
8
9  This file is part of the yat library, http://dev.thep.lu.se/yat
10
11  The yat library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 3 of the
14  License, or (at your option) any later version.
15
16  The yat library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20
21  You should have received a copy of the GNU General Public License
22  along with yat. If not, see <http://www.gnu.org/licenses/>.
23*/
24
25#include "tScore.h"
26#include "Averager.h"
27#include "AveragerWeighted.h"
28#include "yat/classifier/DataLookup1D.h"
29#include "yat/classifier/DataLookupWeighted1D.h"
30#include "yat/classifier/Target.h"
31#include "yat/utility/VectorBase.h"
32
33#include <cassert>
34#include <cmath>
35
36namespace theplu {
37namespace yat {
38namespace statistics { 
39
40  tScore::tScore(bool b) 
41    : Score(b)
42  {
43  }
44
45
46  double tScore::score(const classifier::Target& target, 
47                       const utility::VectorBase& value) const
48  {
49    return score(target, value, NULL);
50  }
51
52
53  double tScore::score(const classifier::Target& target, 
54                       const utility::VectorBase& value,
55                       double* dof) const
56  {
57    statistics::Averager positive;
58    statistics::Averager negative;
59    for(size_t i=0; i<target.size(); i++){
60      if (target.binary(i))
61        positive.add(value(i));
62      else
63        negative.add(value(i));
64    }
65    return score(positive, negative, dof);
66  }
67
68
69  double tScore::score(const classifier::Target& target, 
70                       const classifier::DataLookupWeighted1D& value) const
71  {
72    return score(target, value, NULL);
73  }
74
75
76  double tScore::score(const classifier::Target& target, 
77                       const classifier::DataLookupWeighted1D& value,
78                       double* dof) const
79  {
80    statistics::AveragerWeighted positive;
81    statistics::AveragerWeighted negative;
82    for(size_t i=0; i<target.size(); i++){
83      if (target.binary(i))
84        positive.add(value.data(i),value.weight(i));
85      else
86        negative.add(value.data(i),value.weight(i));
87    }
88    return score(positive, negative, dof);
89  }
90
91
92  double tScore::score(const classifier::Target& target, 
93                       const utility::VectorBase& value,
94                       const utility::VectorBase& weight) const
95  {
96    return score(target, value, weight, NULL);
97  }
98
99
100  double tScore::score(const classifier::Target& target, 
101                       const utility::VectorBase& value,
102                       const utility::VectorBase& weight,
103                       double* dof) const
104  {
105    statistics::AveragerWeighted positive;
106    statistics::AveragerWeighted negative;
107    for(size_t i=0; i<target.size(); i++){
108      if (target.binary(i))
109        positive.add(value(i),weight(i));
110      else
111        negative.add(value(i),weight(i));
112    }
113    return score(positive, negative, dof);
114  }
115
116}}} // of namespace statistics, yat, and theplu
Note: See TracBrowser for help on using the repository browser.