yat/statistics/Score.cc

Code
Comments
Other
Rev Date Author Line
179 04 Oct 04 peter 1 // $Id$
179 04 Oct 04 peter 2
675 10 Oct 06 jari 3 /*
831 27 Mar 07 peter 4   Copyright (C) 2004, 2005 Peter Johansson
4359 23 Aug 23 peter 5   Copyright (C) 2006 Jari Häkkinen, Markus Ringnér
2119 12 Dec 09 peter 6   Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
4359 23 Aug 23 peter 7   Copyright (C) 2012 Peter Johansson
179 04 Oct 04 peter 8
1437 25 Aug 08 peter 9   This file is part of the yat library, http://dev.thep.lu.se/yat
675 10 Oct 06 jari 10
675 10 Oct 06 jari 11   The yat library is free software; you can redistribute it and/or
675 10 Oct 06 jari 12   modify it under the terms of the GNU General Public License as
1486 09 Sep 08 jari 13   published by the Free Software Foundation; either version 3 of the
675 10 Oct 06 jari 14   License, or (at your option) any later version.
675 10 Oct 06 jari 15
675 10 Oct 06 jari 16   The yat library is distributed in the hope that it will be useful,
675 10 Oct 06 jari 17   but WITHOUT ANY WARRANTY; without even the implied warranty of
675 10 Oct 06 jari 18   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
675 10 Oct 06 jari 19   General Public License for more details.
675 10 Oct 06 jari 20
675 10 Oct 06 jari 21   You should have received a copy of the GNU General Public License
1487 10 Sep 08 jari 22   along with yat. If not, see <http://www.gnu.org/licenses/>.
675 10 Oct 06 jari 23 */
675 10 Oct 06 jari 24
2881 18 Nov 12 peter 25 #include <config.h>
2881 18 Nov 12 peter 26
680 11 Oct 06 jari 27 #include "Score.h"
675 10 Oct 06 jari 28
747 11 Feb 07 peter 29 #include "yat/classifier/DataLookup1D.h"
779 05 Mar 07 peter 30 #include "yat/classifier/DataLookupWeighted1D.h"
747 11 Feb 07 peter 31 #include "yat/classifier/Target.h"
747 11 Feb 07 peter 32 #include "yat/classifier/utility.h"
1120 21 Feb 08 peter 33 #include "yat/utility/Vector.h"
747 11 Feb 07 peter 34
779 05 Mar 07 peter 35 #include <cassert>
747 11 Feb 07 peter 36
179 04 Oct 04 peter 37 namespace theplu {
680 11 Oct 06 jari 38 namespace yat {
4200 19 Aug 22 peter 39 namespace statistics {
179 04 Oct 04 peter 40
179 04 Oct 04 peter 41   Score::Score(bool absolute)
779 05 Mar 07 peter 42     : absolute_(absolute)
179 04 Oct 04 peter 43   {
179 04 Oct 04 peter 44   }
179 04 Oct 04 peter 45
703 18 Dec 06 jari 46   Score::~Score(void)
703 18 Dec 06 jari 47   {
703 18 Dec 06 jari 48   }
703 18 Dec 06 jari 49
779 05 Mar 07 peter 50   void Score::absolute(bool absolute)
779 05 Mar 07 peter 51   {
779 05 Mar 07 peter 52     absolute_=absolute;
4200 19 Aug 22 peter 53   }
779 05 Mar 07 peter 54
703 18 Dec 06 jari 55   double Score::score(const classifier::Target& target,
779 05 Mar 07 peter 56                       const classifier::DataLookup1D& value) const
703 18 Dec 06 jari 57   {
703 18 Dec 06 jari 58     assert(target.size()==value.size());
1120 21 Feb 08 peter 59     utility::Vector a(value.size());
703 18 Dec 06 jari 60     classifier::convert(value,a);
703 18 Dec 06 jari 61     return score(target,a);
703 18 Dec 06 jari 62   }
703 18 Dec 06 jari 63
779 05 Mar 07 peter 64
779 05 Mar 07 peter 65   double Score::score(const classifier::Target& target,
779 05 Mar 07 peter 66                       const classifier::DataLookupWeighted1D& value) const
718 26 Dec 06 jari 67   {
779 05 Mar 07 peter 68     assert(target.size()==value.size());
1120 21 Feb 08 peter 69     utility::Vector a(value.size());
1120 21 Feb 08 peter 70     utility::Vector b(value.size());
779 05 Mar 07 peter 71     classifier::convert(value,a,b);
779 05 Mar 07 peter 72     return score(target,a,b);
718 26 Dec 06 jari 73   }
718 26 Dec 06 jari 74
779 05 Mar 07 peter 75
703 18 Dec 06 jari 76   double Score::score(const classifier::Target& target,
703 18 Dec 06 jari 77                       const classifier::DataLookup1D& value,
779 05 Mar 07 peter 78                       const classifier::DataLookup1D& weight) const
703 18 Dec 06 jari 79   {
1120 21 Feb 08 peter 80     utility::Vector a(value.size());
703 18 Dec 06 jari 81     classifier::convert(value,a);
1120 21 Feb 08 peter 82     utility::Vector b(value.size());
703 18 Dec 06 jari 83     classifier::convert(weight,a);
703 18 Dec 06 jari 84     return score(target,a,b);
703 18 Dec 06 jari 85   }
703 18 Dec 06 jari 86
683 11 Oct 06 jari 87 }}} // of namespace statistics, yat, and theplu