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

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

added random_shuffle function in Target class

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