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

Last change on this file since 2078 was 2078, checked in by Peter, 14 years ago

remove inclusions not needed

  • 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 2078 2009-10-07 16:33:56Z 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 <cmath>
34
35namespace theplu {
36namespace yat {
37namespace statistics { 
38
39  tScore::tScore(bool b) 
40    : Score(b)
41  {
42  }
43
44
45  double tScore::score(const classifier::Target& target, 
46                       const utility::VectorBase& value) const
47  {
48    return score(target, value, NULL);
49  }
50
51
52  double tScore::score(const classifier::Target& target, 
53                       const utility::VectorBase& value,
54                       double* dof) const
55  {
56    statistics::Averager positive;
57    statistics::Averager negative;
58    for(size_t i=0; i<target.size(); i++){
59      if (target.binary(i))
60        positive.add(value(i));
61      else
62        negative.add(value(i));
63    }
64    return score(positive, negative, dof);
65  }
66
67
68  double tScore::score(const classifier::Target& target, 
69                       const classifier::DataLookupWeighted1D& value) const
70  {
71    return score(target, value, NULL);
72  }
73
74
75  double tScore::score(const classifier::Target& target, 
76                       const classifier::DataLookupWeighted1D& value,
77                       double* dof) const
78  {
79    statistics::AveragerWeighted positive;
80    statistics::AveragerWeighted negative;
81    for(size_t i=0; i<target.size(); i++){
82      if (target.binary(i))
83        positive.add(value.data(i),value.weight(i));
84      else
85        negative.add(value.data(i),value.weight(i));
86    }
87    return score(positive, negative, dof);
88  }
89
90
91  double tScore::score(const classifier::Target& target, 
92                       const utility::VectorBase& value,
93                       const utility::VectorBase& weight) const
94  {
95    return score(target, value, weight, NULL);
96  }
97
98
99  double tScore::score(const classifier::Target& target, 
100                       const utility::VectorBase& value,
101                       const utility::VectorBase& weight,
102                       double* dof) const
103  {
104    statistics::AveragerWeighted positive;
105    statistics::AveragerWeighted negative;
106    for(size_t i=0; i<target.size(); i++){
107      if (target.binary(i))
108        positive.add(value(i),weight(i));
109      else
110        negative.add(value(i),weight(i));
111    }
112    return score(positive, negative, dof);
113  }
114
115}}} // of namespace statistics, yat, and theplu
Note: See TracBrowser for help on using the repository browser.