source: trunk/yat/classifier/FeatureSelectorIR.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
File size: 2.2 KB
Line 
1// $Id$
2
3/*
4  Copyright (C) 2006 Jari Häkkinen, Peter Johansson
5  Copyright (C) 2007 Peter Johansson
6
7  This file is part of the yat library, http://trac.thep.lu.se/yat
8
9  The yat library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version.
13
14  The yat library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  General Public License for more details.
18
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22  02111-1307, USA.
23*/
24
25#include "FeatureSelectorIR.h"
26#include "FeatureSelector.h"
27#include "MatrixLookup.h"
28#include "MatrixLookupWeighted.h"
29#include "InputRanker.h"
30#include "Target.h"
31
32#include <algorithm>
33#include <cassert>
34
35namespace theplu {
36namespace yat {
37namespace classifier {
38
39
40  FeatureSelectorIR::FeatureSelectorIR(statistics::Score& score, size_t N, 
41                                       size_t first)
42    : FeatureSelector(N, first), score_(score)
43  {
44  }
45
46
47
48  FeatureSelectorIR::FeatureSelectorIR(const FeatureSelectorIR& other)
49    : FeatureSelector(other), score_(other.score_)
50  {
51  }
52
53
54
55  FeatureSelectorIR& FeatureSelectorIR::operator=(const FeatureSelectorIR& other)
56  {
57    FeatureSelector::operator=(other);
58    return *this;
59  }
60
61
62  void FeatureSelectorIR::update(const MatrixLookup& data, const Target& target)
63  {
64    assert(data.columns()==target.size());
65    InputRanker ir = InputRanker(data, target, score_);
66    features_.resize(N_);
67    std::copy(ir.id().begin()+first_, ir.id().begin()+first_+N_,
68              features_.begin());
69  }
70
71
72  void FeatureSelectorIR::update(const MatrixLookupWeighted& data, 
73                                 const Target& target)
74  {
75    assert(data.columns()==target.size());
76    InputRanker ir = InputRanker(data, target, score_);
77    features_.resize(N_);
78    std::copy(ir.id().begin()+first_, ir.id().begin()+first_+N_,
79              features_.begin());
80   
81  }
82
83}}} // of namespace classifier, yat, and theplu
Note: See TracBrowser for help on using the repository browser.