Changeset 667 for trunk


Ignore:
Timestamp:
Oct 6, 2006, 9:03:19 AM (16 years ago)
Author:
Peter
Message:

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.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/c++_tools/classifier/ConsensusInputRanker.cc

    r666 r667  
    44
    55#include <c++_tools/classifier/InputRanker.h>
     6#include <c++_tools/classifier/IRRetrieve.h>
    67#include <c++_tools/classifier/MatrixLookup.h>
    78#include <c++_tools/classifier/MatrixLookupWeighted.h>
     
    1314
    1415#include <cassert>
     16#include <functional>
    1517#include <iostream>
    1618#include <utility>
     
    6567  {
    6668
    67     // Sorting with respect to median rank
     69    // Sorting with respect to median info (from retriever_)
    6870    std::vector<std::pair<double,size_t> > medians(id_.size());
    6971    for (size_t i=0; i<id_.size(); i++){
    70       std::vector<size_t> ranks(input_rankers_.size());
     72      std::vector<double> scores;
     73      scores.reserve(input_rankers_.size());
    7174      for (size_t j=0; j<input_rankers_.size(); j++) {
    72         ranks[j]=input_rankers_[j].rank()[i];
     75        scores.push_back(retriever_(input_rankers_[j],i));
    7376      }
    74       medians[i].first = statistics::median(ranks);
     77      medians[i].first = statistics::median(scores);
    7578      medians[i].second = i;
    7679    }
    7780   
    7881    //sort medians and assign id_ and rank_
    79     sort(medians.begin(), medians.end());
     82    sort(medians.begin(), medians.end(),
     83         std::greater<std::pair<double, size_t> >());
     84         
    8085    for (size_t i=0; i<medians.size(); i++){
    8186      id_[i]=medians[i].second;
  • trunk/c++_tools/classifier/ConsensusInputRanker.h

    r666 r667  
    55
    66#include <c++_tools/classifier/InputRanker.h>
    7 #include <c++_tools/classifier/IRRetrieve.h>
    87
    98namespace theplu {
     
    1312namespace classifier { 
    1413
     14  class IRRetrieve;
    1515  class MatrixLookup;
    1616  class MatrixLookupWeighted;
  • trunk/c++_tools/classifier/IRRank.h

    r666 r667  
    55
    66#include <c++_tools/classifier/InputRanker.h>
     7#include <c++_tools/classifier/IRRetrieve.h>
    78
    89namespace theplu {
     
    2324    inline double operator()(const InputRanker& ranker, size_t i) const
    2425    {
    25       return -ranker.rank()[i];
     26      return -static_cast<double>(ranker.rank()[i]);
    2627    }
    2728  };
  • trunk/test/consensus_inputranker_test.cc

    r666 r667  
    5050  if (cir.id(0)!=2 || cir.id(1)!=0 || cir.id(2)!=1){
    5151    *error << "incorrect id" << endl;
     52    std::cout << cir.id(0) << "=2" << std::endl;
     53    std::cout << cir.id(1) << "=0" << std::endl;
     54    std::cout << cir.id(2) << "=1" << std::endl;
    5255    ok = false;
    5356  }
Note: See TracChangeset for help on using the changeset viewer.