Changeset 120 for trunk/src/InputRanker.cc
- Timestamp:
- Jul 20, 2004, 6:25:29 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/InputRanker.cc
r108 r120 39 39 std::vector<pair<size_t, double> > score; 40 40 for (size_t i=0; i<nof_genes; i++){ 41 double area = score_object.score(data_transposed[i], target); 41 double area = score_object.score(data_transposed[i], target, train_set_); 42 std::pair<size_t, double> tmp(i,area); 43 score.push_back(tmp); 44 } 45 //sort the scores and assign id_ and rank_ 46 sort(score.begin(), score.end(), 47 pair_value_compare<size_t, double>()); 48 49 for (size_t i=0; i<nof_genes; i++){ 50 id_[i]=score[i].first; 51 rank_[id_[i]]=i; 52 } 53 } 54 55 InputRanker::InputRanker(const gslapi::matrix& data, 56 const gslapi::vector& target, 57 const gslapi::matrix& weight, 58 Score& score_object, 59 const std::vector<size_t>& train_set) 60 :train_set_(train_set), 61 id_(std::vector<size_t>(data.rows())), 62 rank_(std::vector<size_t>(data.rows())) 63 64 { 65 using namespace std; 66 // Peter, this copying and transposing is done since it seems 67 // problematic to get a column vector from a matrix 68 gslapi::matrix data_transposed = data; 69 data_transposed.transpose(); 70 gslapi::matrix weight_transposed = weight; 71 weight_transposed.transpose(); 72 73 size_t nof_genes = data_transposed.rows(); 74 size_t nof_samples = data_transposed.columns(); 75 if (!train_set_.size()){ 76 train_set_.resize(nof_samples); 77 for (size_t i=0; i<nof_samples; i++) 78 train_set_[i]=i; 79 } 80 //scoring each input 81 std::vector<pair<size_t, double> > score; 82 for (size_t i=0; i<nof_genes; i++){ 83 double area = score_object.score(data_transposed[i], target, 84 weight_transposed[i], train_set_); 42 85 std::pair<size_t, double> tmp(i,area); 43 86 score.push_back(tmp);
Note: See TracChangeset
for help on using the changeset viewer.