Changeset 522


Ignore:
Timestamp:
Feb 23, 2006, 9:46:13 AM (16 years ago)
Author:
Peter
Message:

added function to add InputRanker? to ConsensusInputRanker?

Location:
trunk/lib/classifier
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/classifier/ConsensusInputRanker.cc

    r502 r522  
    2626    assert(sampler.size());
    2727    size_t nof_inputs = sampler.training_data().rows();
     28    id_.resize(nof_inputs);
     29    rank_.resize(nof_inputs);
    2830    while (sampler.more()){
    2931      // Peter, should support weights also (in sampler???)
     
    3335      sampler.next();
    3436    }
     37    update();
     38  }
    3539
    36 
     40  void ConsensusInputRanker::update(void)
     41  {
    3742
    3843    // Sorting with respect to median rank
    39     std::vector<std::pair<double,size_t> > medians(nof_inputs);
    40     for (size_t i=0; i<nof_inputs; i++){
    41       std::vector<size_t> ranks(sampler.size());
    42       for (size_t j=0; j<sampler.size(); j++) {
     44    std::vector<std::pair<double,size_t> > medians(id_.size());
     45    for (size_t i=0; i<id_.size(); i++){
     46      std::vector<size_t> ranks(input_rankers_.size());
     47      for (size_t j=0; j<input_rankers_.size(); j++) {
    4348        ranks[j]=input_rankers_[j].rank(i);
    4449      }
     
    4954    //sort medians and assign id_ and rank_
    5055    sort(medians.begin(), medians.end());
    51     id_.resize(nof_inputs);
    52     rank_.resize(nof_inputs);
    53     for (size_t i=0; i<nof_inputs; i++){
     56    for (size_t i=0; i<medians.size(); i++){
    5457      id_[i]=medians[i].second;
    5558      rank_[id_[i]]=i;
    5659    }
    57 
    5860  }
    5961
  • trunk/lib/classifier/ConsensusInputRanker.h

    r482 r522  
    2121 
    2222  public:
     23    ///
     24    /// @brief Default constructor
     25    ///
     26    ConsensusInputRanker(void);
     27   
    2328    ///
    2429    /// Constructor
     30    /// @todo doc
     31    ConsensusInputRanker(CrossSplitter&, statistics::Score&);
     32   
    2533    ///
    26     ConsensusInputRanker(CrossSplitter&, statistics::Score&);
    27 
     34    /// @brief add an InputRanker
     35    ///
     36    /// @note update() must be called to make the added InputRanker to
     37    /// influence consensus ids and ranks. If a sequence of
     38    /// InputRankers are added, update() need to be called only after
     39    /// the last InputRanker is added.
     40    ///
     41    inline void add(const InputRanker& ir) { input_rankers_.push_back(ir); }
     42   
    2843    ///
    2944    /// Row with lowest rank (highest score) is ranked as number zero
    3045    /// @return index of row ranked as number \a i
    3146    ///
    32     inline size_t id(const size_t i) const {return id_[i];}
     47    inline size_t id(const size_t i) const { return id_[i]; }
    3348   
    3449    ///
    35     /// Row with lowest rank (highest score) is ranked as number zero
    36     /// @return rank for row \a i
     50    /// Row with lowest rank (highest score) is ranked as number zero
     51    /// @return rank for row \a i
    3752    ///
    38     inline size_t rank(const size_t i) const {return rank_[i];}
     53    inline size_t rank(const size_t i) const { return rank_[i]; }
     54   
     55    ///
     56    /// update ids and ranks
     57    ///
     58    void update(void);
    3959
    4060
    4161  private:
     62
    4263    std::vector<size_t> id_;
    4364    std::vector<InputRanker> input_rankers_;
    4465    std::vector<size_t> rank_;
     66
    4567  };
    4668
Note: See TracChangeset for help on using the changeset viewer.