604 |
29 Aug 06 |
peter |
// $Id$ |
604 |
29 Aug 06 |
peter |
2 |
|
675 |
10 Oct 06 |
jari |
3 |
/* |
2119 |
12 Dec 09 |
peter |
Copyright (C) 2006 Jari Häkkinen, Peter Johansson |
4359 |
23 Aug 23 |
peter |
Copyright (C) 2007 Peter Johansson, Markus Ringnér |
2119 |
12 Dec 09 |
peter |
Copyright (C) 2008 Jari Häkkinen, Peter Johansson |
4359 |
23 Aug 23 |
peter |
Copyright (C) 2012 Peter Johansson |
675 |
10 Oct 06 |
jari |
8 |
|
1437 |
25 Aug 08 |
peter |
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 |
The yat library is free software; you can redistribute it and/or |
675 |
10 Oct 06 |
jari |
modify it under the terms of the GNU General Public License as |
1486 |
09 Sep 08 |
jari |
published by the Free Software Foundation; either version 3 of the |
675 |
10 Oct 06 |
jari |
License, or (at your option) any later version. |
675 |
10 Oct 06 |
jari |
15 |
|
675 |
10 Oct 06 |
jari |
The yat library is distributed in the hope that it will be useful, |
675 |
10 Oct 06 |
jari |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
675 |
10 Oct 06 |
jari |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
675 |
10 Oct 06 |
jari |
General Public License for more details. |
675 |
10 Oct 06 |
jari |
20 |
|
675 |
10 Oct 06 |
jari |
You should have received a copy of the GNU General Public License |
1487 |
10 Sep 08 |
jari |
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 |
|
604 |
29 Aug 06 |
peter |
27 |
#include "FeatureSelectorIR.h" |
604 |
29 Aug 06 |
peter |
28 |
#include "FeatureSelector.h" |
640 |
07 Sep 06 |
peter |
29 |
#include "MatrixLookup.h" |
862 |
10 Sep 07 |
markus |
30 |
#include "MatrixLookupWeighted.h" |
604 |
29 Aug 06 |
peter |
31 |
#include "InputRanker.h" |
747 |
11 Feb 07 |
peter |
32 |
#include "Target.h" |
604 |
29 Aug 06 |
peter |
33 |
|
606 |
29 Aug 06 |
peter |
34 |
#include <algorithm> |
781 |
05 Mar 07 |
peter |
35 |
#include <cassert> |
606 |
29 Aug 06 |
peter |
36 |
|
604 |
29 Aug 06 |
peter |
37 |
namespace theplu { |
680 |
11 Oct 06 |
jari |
38 |
namespace yat { |
604 |
29 Aug 06 |
peter |
39 |
namespace classifier { |
604 |
29 Aug 06 |
peter |
40 |
|
604 |
29 Aug 06 |
peter |
41 |
|
4200 |
19 Aug 22 |
peter |
42 |
FeatureSelectorIR::FeatureSelectorIR(statistics::Score& score, size_t N, |
604 |
29 Aug 06 |
peter |
43 |
size_t first) |
604 |
29 Aug 06 |
peter |
44 |
: FeatureSelector(N, first), score_(score) |
604 |
29 Aug 06 |
peter |
45 |
{ |
604 |
29 Aug 06 |
peter |
46 |
} |
604 |
29 Aug 06 |
peter |
47 |
|
604 |
29 Aug 06 |
peter |
48 |
|
604 |
29 Aug 06 |
peter |
49 |
|
604 |
29 Aug 06 |
peter |
50 |
FeatureSelectorIR::FeatureSelectorIR(const FeatureSelectorIR& other) |
604 |
29 Aug 06 |
peter |
51 |
: FeatureSelector(other), score_(other.score_) |
604 |
29 Aug 06 |
peter |
52 |
{ |
604 |
29 Aug 06 |
peter |
53 |
} |
604 |
29 Aug 06 |
peter |
54 |
|
604 |
29 Aug 06 |
peter |
55 |
|
604 |
29 Aug 06 |
peter |
56 |
|
604 |
29 Aug 06 |
peter |
57 |
FeatureSelectorIR& FeatureSelectorIR::operator=(const FeatureSelectorIR& other) |
604 |
29 Aug 06 |
peter |
58 |
{ |
604 |
29 Aug 06 |
peter |
59 |
FeatureSelector::operator=(other); |
604 |
29 Aug 06 |
peter |
60 |
return *this; |
604 |
29 Aug 06 |
peter |
61 |
} |
604 |
29 Aug 06 |
peter |
62 |
|
604 |
29 Aug 06 |
peter |
63 |
|
624 |
05 Sep 06 |
peter |
64 |
void FeatureSelectorIR::update(const MatrixLookup& data, const Target& target) |
604 |
29 Aug 06 |
peter |
65 |
{ |
640 |
07 Sep 06 |
peter |
66 |
assert(data.columns()==target.size()); |
604 |
29 Aug 06 |
peter |
67 |
InputRanker ir = InputRanker(data, target, score_); |
1134 |
23 Feb 08 |
peter |
68 |
std::vector<size_t>* features = new std::vector<size_t>(N_); |
863 |
10 Sep 07 |
markus |
69 |
std::copy(ir.id().begin()+first_, ir.id().begin()+first_+N_, |
1134 |
23 Feb 08 |
peter |
70 |
features->begin()); |
4200 |
19 Aug 22 |
peter |
71 |
features_ = |
1134 |
23 Feb 08 |
peter |
72 |
utility::Index(utility::SmartPtr<const std::vector<size_t> >(features)); |
604 |
29 Aug 06 |
peter |
73 |
} |
604 |
29 Aug 06 |
peter |
74 |
|
604 |
29 Aug 06 |
peter |
75 |
|
4200 |
19 Aug 22 |
peter |
76 |
void FeatureSelectorIR::update(const MatrixLookupWeighted& data, |
624 |
05 Sep 06 |
peter |
77 |
const Target& target) |
624 |
05 Sep 06 |
peter |
78 |
{ |
862 |
10 Sep 07 |
markus |
79 |
assert(data.columns()==target.size()); |
624 |
05 Sep 06 |
peter |
80 |
InputRanker ir = InputRanker(data, target, score_); |
1134 |
23 Feb 08 |
peter |
81 |
std::vector<size_t>* features = new std::vector<size_t>(N_); |
863 |
10 Sep 07 |
markus |
82 |
std::copy(ir.id().begin()+first_, ir.id().begin()+first_+N_, |
1134 |
23 Feb 08 |
peter |
83 |
features->begin()); |
4200 |
19 Aug 22 |
peter |
84 |
features_ = |
1134 |
23 Feb 08 |
peter |
85 |
utility::Index(utility::SmartPtr<const std::vector<size_t> >(features)); |
624 |
05 Sep 06 |
peter |
86 |
} |
624 |
05 Sep 06 |
peter |
87 |
|
680 |
11 Oct 06 |
jari |
88 |
}}} // of namespace classifier, yat, and theplu |