source: trunk/c++_tools/classifier/FeatureSelectorIR.cc @ 640

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

fixes #132 and #95, and refs #135 replaced bool owner in DataLookup2D with ref_count u_int*. When the DataLookup2D does not own underlying data ref_count=NULL otherwise it points to a u_int telling how many owner there are of the data. When the counter reaches zero the data is deleted.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date ID
File size: 1.2 KB
Line 
1// $Id$
2
3#include "FeatureSelectorIR.h"
4
5#include "FeatureSelector.h"
6#include "MatrixLookup.h"
7#include "InputRanker.h"
8
9#include <algorithm>
10
11namespace theplu {
12namespace classifier {
13
14
15  FeatureSelectorIR::FeatureSelectorIR(statistics::Score& score, size_t N, 
16                                       size_t first)
17    : FeatureSelector(N, first), score_(score)
18  {
19  }
20
21
22
23  FeatureSelectorIR::FeatureSelectorIR(const FeatureSelectorIR& other)
24    : FeatureSelector(other), score_(other.score_)
25  {
26  }
27
28
29
30  FeatureSelectorIR& FeatureSelectorIR::operator=(const FeatureSelectorIR& other)
31  {
32    FeatureSelector::operator=(other);
33    return *this;
34  }
35
36
37  void FeatureSelectorIR::update(const MatrixLookup& data, const Target& target)
38  {
39    assert(data.columns()==target.size());
40    InputRanker ir = InputRanker(data, target, score_);
41    features_.resize(N_);
42    std::copy(ir.rank().begin()+first_, ir.rank().begin()+first_+N_,
43              features_.begin());
44  }
45
46
47  void FeatureSelectorIR::update(const MatrixLookupWeighted& data, 
48                                 const Target& target)
49  {
50    InputRanker ir = InputRanker(data, target, score_);
51    features_.resize(N_);
52    std::copy(ir.rank().begin()+first_, ir.rank().begin()+first_+N_,
53              features_.begin());
54   
55  }
56
57
58} // end of namespace classifier
59} // end of namespace theplu
Note: See TracBrowser for help on using the repository browser.