Changeset 522
- Timestamp:
- Feb 23, 2006, 9:46:13 AM (17 years ago)
- Location:
- trunk/lib/classifier
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/classifier/ConsensusInputRanker.cc
r502 r522 26 26 assert(sampler.size()); 27 27 size_t nof_inputs = sampler.training_data().rows(); 28 id_.resize(nof_inputs); 29 rank_.resize(nof_inputs); 28 30 while (sampler.more()){ 29 31 // Peter, should support weights also (in sampler???) … … 33 35 sampler.next(); 34 36 } 37 update(); 38 } 35 39 36 40 void ConsensusInputRanker::update(void) 41 { 37 42 38 43 // 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++) { 43 48 ranks[j]=input_rankers_[j].rank(i); 44 49 } … … 49 54 //sort medians and assign id_ and rank_ 50 55 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++){ 54 57 id_[i]=medians[i].second; 55 58 rank_[id_[i]]=i; 56 59 } 57 58 60 } 59 61 -
trunk/lib/classifier/ConsensusInputRanker.h
r482 r522 21 21 22 22 public: 23 /// 24 /// @brief Default constructor 25 /// 26 ConsensusInputRanker(void); 27 23 28 /// 24 29 /// Constructor 30 /// @todo doc 31 ConsensusInputRanker(CrossSplitter&, statistics::Score&); 32 25 33 /// 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 28 43 /// 29 44 /// Row with lowest rank (highest score) is ranked as number zero 30 45 /// @return index of row ranked as number \a i 31 46 /// 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]; } 33 48 34 49 /// 35 36 50 /// Row with lowest rank (highest score) is ranked as number zero 51 /// @return rank for row \a i 37 52 /// 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); 39 59 40 60 41 61 private: 62 42 63 std::vector<size_t> id_; 43 64 std::vector<InputRanker> input_rankers_; 44 65 std::vector<size_t> rank_; 66 45 67 }; 46 68
Note: See TracChangeset
for help on using the changeset viewer.