source: trunk/yat/classifier/FeatureSelectorIR.cc @ 831

Last change on this file since 831 was 831, checked in by Peter, 15 years ago

Refs #185.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date ID
File size: 2.1 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://lev.thep.lu.se/trac/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 "InputRanker.h"
29#include "Target.h"
30
31#include <algorithm>
32#include <cassert>
33
34namespace theplu {
35namespace yat {
36namespace classifier {
37
38
39  FeatureSelectorIR::FeatureSelectorIR(statistics::Score& score, size_t N, 
40                                       size_t first)
41    : FeatureSelector(N, first), score_(score)
42  {
43  }
44
45
46
47  FeatureSelectorIR::FeatureSelectorIR(const FeatureSelectorIR& other)
48    : FeatureSelector(other), score_(other.score_)
49  {
50  }
51
52
53
54  FeatureSelectorIR& FeatureSelectorIR::operator=(const FeatureSelectorIR& other)
55  {
56    FeatureSelector::operator=(other);
57    return *this;
58  }
59
60
61  void FeatureSelectorIR::update(const MatrixLookup& data, const Target& target)
62  {
63    assert(data.columns()==target.size());
64    InputRanker ir = InputRanker(data, target, score_);
65    features_.resize(N_);
66    std::copy(ir.rank().begin()+first_, ir.rank().begin()+first_+N_,
67              features_.begin());
68  }
69
70
71  void FeatureSelectorIR::update(const MatrixLookupWeighted& data, 
72                                 const Target& target)
73  {
74    InputRanker ir = InputRanker(data, target, score_);
75    features_.resize(N_);
76    std::copy(ir.rank().begin()+first_, ir.rank().begin()+first_+N_,
77              features_.begin());
78   
79  }
80
81}}} // of namespace classifier, yat, and theplu
Note: See TracBrowser for help on using the repository browser.