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

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

ref #96 included FeatureSelection? in CrossSplitter?. Also happened to add properties to files

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