source: trunk/yat/statistics/Score.cc @ 1000

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

trac moved to new location.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.3 KB
Line 
1// $Id: Score.cc 1000 2007-12-23 20:09:15Z jari $
2
3/*
4  Copyright (C) 2004, 2005 Peter Johansson
5  Copyright (C) 2006 Jari Häkkinen, Markus Ringnér, Peter Johansson
6  Copyright (C) 2007 Jari Häkkinen, Peter Johansson
7
8  This file is part of the yat library, http://trac.thep.lu.se/yat
9
10  The yat library is free software; you can redistribute it and/or
11  modify it under the terms of the GNU General Public License as
12  published by the Free Software Foundation; either version 2 of the
13  License, or (at your option) any later version.
14
15  The yat library is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  General Public License for more details.
19
20  You should have received a copy of the GNU General Public License
21  along with this program; if not, write to the Free Software
22  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23  02111-1307, USA.
24*/
25
26#include "Score.h"
27
28#include "yat/classifier/DataLookup1D.h"
29#include "yat/classifier/DataLookupWeighted1D.h"
30#include "yat/classifier/Target.h"
31#include "yat/classifier/utility.h"
32#include "yat/utility/vector.h"
33
34#include <cassert>
35
36namespace theplu {
37namespace yat {
38namespace statistics { 
39
40  Score::Score(bool absolute)
41    : absolute_(absolute)
42  {
43  }
44
45  Score::~Score(void)
46  {
47  }
48
49  void Score::absolute(bool absolute)
50  {
51    absolute_=absolute;
52  } 
53
54  double Score::score(const classifier::Target& target,
55                      const classifier::DataLookup1D& value) const
56  {
57    assert(target.size()==value.size());
58    utility::vector a(value.size());
59    classifier::convert(value,a);
60    return score(target,a);
61  }
62
63
64  double Score::score(const classifier::Target& target,
65                      const classifier::DataLookupWeighted1D& value) const
66  {
67    assert(target.size()==value.size());
68    utility::vector a(value.size());
69    utility::vector b(value.size());
70    classifier::convert(value,a,b);
71    return score(target,a,b);
72  }
73
74
75  double Score::score(const classifier::Target& target,
76                      const classifier::DataLookup1D& value,
77                      const classifier::DataLookup1D& weight) const
78  {
79    utility::vector a(value.size());
80    classifier::convert(value,a);
81    utility::vector b(value.size());
82    classifier::convert(weight,a);
83    return score(target,a,b);
84  }
85
86}}} // of namespace statistics, yat, and theplu
Note: See TracBrowser for help on using the repository browser.