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

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

refs #151 using Functor now in consensusinputranker to retrieve information from inputranker to sort on. Median is still hard-coded so I leave this ticket open.

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