source: trunk/c++_tools/classifier/ConsensusInputRanker.h @ 615

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

ref #60 NOTE: there is most likely a bug around. I have removed the ensemble.build() test in the ensemble_test to get the test go through. I will try to find and remove this bug asap.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date ID
File size: 3.2 KB
Line 
1// $Id$
2
3#ifndef _theplu_classifier_consensusinputranker_
4#define _theplu_classifier_consensusinputranker_
5
6#include <c++_tools/classifier/InputRanker.h>
7
8namespace theplu {
9
10  class statistics::Score;
11
12namespace classifier { 
13
14  class MatrixLookup;
15  class MatrixLookupWeighted;
16  class Sampler;
17
18  ///
19  /// @brief Robust algorithm to rank rows in a data matrix versus a
20  /// target vector.
21  ///
22  /// The idea is to create several (different) ranked lists. The list
23  /// could be different because they are based upon different
24  /// sub-sets of the data, or the different lists could be different
25  /// because they have are generated using different criteria. Having
26  /// \f$ N \f$ lists means each row in the data matrix has \f$ N \f$
27  /// ranks (each corresponding to one list) and a consensus ranked
28  /// list is created by sorting the data rows with respect to their
29  /// median rank.
30  ///
31  /// For the time being there are two ways to build a
32  /// ConsensusInputRanker. 1) Sending a Sampler and a MatrixLookup to
33  /// the constructor will create one ranked list for each of the
34  /// partitions defined in the Sampler. 2) You can generate
35  /// your ranked list outside, using your favourite method, and
36  /// adding it into the ConsensusInputRanker object. This allows
37  /// combining different scores and different sub-sets in a more
38  /// general way.
39  ///
40  class ConsensusInputRanker
41  {
42 
43  public:
44
45    ///
46    /// @brief Default constructor
47    ///
48    /// Truly does nothing but creates a few empty member vectors.
49    ///
50    //ConsensusInputRanker(void);
51   
52    ///
53    /// Iterating through @a sampler creating subsets of @a data, and
54    /// for each subset is an InputRanker is created using the @a
55    /// score. After creation the data rows are sorted with respect to
56    /// the median rank (i.e. update() is called).
57    ///
58    ConsensusInputRanker(const Sampler& sampler, const MatrixLookup&, 
59                         statistics::Score& s);
60   
61    ///
62    /// Iterating through @a sampler creating subsets of @a data, and
63    /// for each subset is an InputRanker is created using the @a
64    /// score. After creation the data rows are sorted with respect to
65    /// the median rank (i.e. update() is called).
66    ///
67    ConsensusInputRanker(const Sampler& sampler, 
68                         const MatrixLookupWeighted& data, 
69                         statistics::Score& score);
70   
71    ///
72    /// @brief add an InputRanker
73    ///
74    /// @note update() must be called to make the added InputRanker to
75    /// influence consensus ids and ranks. If a sequence of
76    /// InputRankers are added, update() need to be called only after
77    /// the last InputRanker is added.
78    ///
79    inline void add(const InputRanker& ir) { input_rankers_.push_back(ir); }
80   
81    ///
82    /// Row with lowest rank (highest score) is ranked as number zero
83    /// @return index of row ranked as number \a i
84    ///
85    inline size_t id(const size_t i) const { return id_[i]; }
86   
87    ///
88    /// Row with lowest rank (highest score) is ranked as number zero
89    /// @return rank for row \a i
90    ///
91    inline size_t rank(const size_t i) const { return rank_[i]; }
92   
93    ///
94    /// update ids and ranks
95    ///
96    void update(void);
97
98
99  private:
100
101    std::vector<size_t> id_;
102    std::vector<InputRanker> input_rankers_;
103    std::vector<size_t> rank_;
104
105  };
106
107}} // of namespace classifier and namespace theplu
108
109#endif
Note: See TracBrowser for help on using the repository browser.