Ignore:
Timestamp:
Sep 10, 2007, 3:18:40 PM (14 years ago)
Author:
Markus Ringnér
Message:

Fixed bug in InputRanker? that sometimes gave rise to a bus error crash. Also added more testing in some tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/feature_selection_test.cc

    r831 r862  
    2525#include "yat/classifier/FeatureSelectorIR.h"
    2626#include "yat/classifier/FeatureSelectorRandom.h"
     27#include "yat/classifier/MatrixLookupWeighted.h"
     28#include "yat/classifier/Target.h"
    2729#include "yat/statistics/AUC.h"
    2830
     31#include "yat/utility/matrix.h"
     32
     33#include <algorithm>
     34#include <cmath>
    2935#include <fstream>
     36#include <iterator>
    3037#include <iostream>
    3138#include <string>
     
    4350      std::cout << "feature_selection -v : for printing extra information\n";
    4451  }
    45   *error << "testing ferature_selection" << std::endl;
     52  *error << "testing feature_selection" << std::endl;
    4653  bool ok = true;
    4754
     
    5057  classifier::FeatureSelectorRandom f2(12);
    5158
     59  *error << "Reading in Sorlie data to identify top gene ..." << std::endl;
     60  std::ifstream is("data/sorlie_centroid_data.txt");
     61  utility::matrix data(is,'\t');
     62  is.close();
     63
     64  is.open("data/sorlie_centroid_classes.txt");
     65  classifier::Target targets(is);
     66  is.close();
     67
     68  *error << "... done" << std::endl;
     69
     70  // Generate weight matrix with 0 for missing values and 1 for others.
     71  utility::matrix weights(data.rows(),data.columns(),0.0);
     72  for(size_t i=0;i<data.rows();++i)
     73    for(size_t j=0;j<data.columns();++j)
     74      if(!std::isnan(data(i,j)))
     75        weights(i,j)=1.0;
     76 
     77  classifier::MatrixLookupWeighted dataviewweighted(data,weights);
     78 
     79  f2.update(dataviewweighted,targets);
     80  *error << "\nRandomly ordered features (top 12):\n";
     81  std::vector<size_t> features=f2.features();
     82  std::copy(features.begin(),features.end(),
     83            std::ostream_iterator<size_t>(*error," "));
     84  *error << std::endl;
     85
     86  f.update(dataviewweighted,targets);
     87  *error << "\nAUC ordered ordered features (top 12):\n";
     88  features=f.features();
     89  std::copy(features.begin(),features.end(),
     90            std::ostream_iterator<size_t>(*error," "));
     91  *error << std::endl;
     92
     93
    5294  if (ok)
    5395    return 0;
Note: See TracChangeset for help on using the changeset viewer.