Changeset 531


Ignore:
Timestamp:
Mar 2, 2006, 6:35:12 PM (16 years ago)
Author:
Markus Ringnér
Message:

Note there are some problem when creating MatrixLookups? from MatrixLookups? and index vectors. Halfway on the path to finding the bugs. This means CrossSplitter? and layers of CrossSplitters? do not work properly.

Location:
trunk/lib/classifier
Files:
5 edited

Legend:

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

    r517 r531  
    77namespace theplu {
    88namespace classifier {
     9
     10
     11  DataLookup2D::DataLookup2D()
     12  {
     13  }
    914
    1015
  • trunk/lib/classifier/DataLookup2D.h

    r482 r531  
    1818 
    1919  public:
     20   
     21    ///
     22    /// Default constructor.
     23    ///
     24    DataLookup2D(void);
     25
    2026
    2127    ///
     
    9399    std::vector<size_t> column_index_;
    94100   
    95     ///
    96     /// Default constructor.
    97     ///
    98     DataLookup2D() {};
    99 
    100101  }; 
    101102 
  • trunk/lib/classifier/EnsembleBuilder.cc

    r509 r531  
    3939  }
    4040
     41  void  EnsembleBuilder::predict
     42  (const DataLookup2D& data,
     43   std::vector<std::vector<statistics::Averager> >& result)
     44  {
     45    cross_splitter_.reset();
     46
     47    result.clear();
     48    result.reserve(cross_splitter_.target().nof_classes());   
     49    for(size_t i=0; i<cross_splitter_.target().nof_classes();i++)
     50      result.push_back(std::vector<statistics::Averager>(data.columns()));
     51   
     52    size_t k=0;
     53    gslapi::matrix prediction;   
     54    while(cross_splitter_.more()) {
     55      classifier(k++).predict(data,prediction);
     56
     57      for(size_t i=0; i<prediction.rows();i++)
     58        for(size_t j=0; j<prediction.columns();j++)
     59          result[i][j].add(prediction(i,j));
     60
     61      cross_splitter_.next();
     62    }
     63
     64  }
     65
     66
     67
    4168  const std::vector<std::vector<statistics::Averager> >&
    4269  EnsembleBuilder::validate(void)
  • trunk/lib/classifier/EnsembleBuilder.h

    r520 r531  
    6060    const std::vector<std::vector<statistics::Averager> >& validate(void);
    6161   
     62    ///
     63    /// Predict a dataset using the ensemble
     64    ///
     65    void  predict(const DataLookup2D&,
     66                  std::vector<std::vector<statistics::Averager> > &);
    6267
    6368
  • trunk/lib/classifier/MatrixLookup.cc

    r526 r531  
    2626
    2727
    28   MatrixLookup::MatrixLookup(const MatrixLookup& data,
     28  MatrixLookup::MatrixLookup(const MatrixLookup& ml,
    2929                     const std::vector<size_t>& row,
    3030                     const std::vector<size_t>& col)
    31     : DataLookup2D(row,col), data_(data.data_)
     31    : DataLookup2D(ml,row,col), data_(ml.data_)
    3232  {
    3333  }
     
    4444
    4545
    46   MatrixLookup::MatrixLookup(const MatrixLookup& data,
     46  MatrixLookup::MatrixLookup(const MatrixLookup& ml,
    4747                     const std::vector<size_t>& index, bool row)
    48     : DataLookup2D(index, row), data_(data.data_)
     48    : DataLookup2D(ml,index,row), data_(ml.data_)
    4949  {
    50     if(row){
    51       row_index_=index;
    52       column_index_.reserve((*data_).columns());
    53       for(size_t i=0;i<(*data_).columns();i++)
    54         column_index_.push_back(i);
    55     }
    56     else{
    57       column_index_=index;
    58       row_index_.reserve((*data_).rows());
    59       for(size_t i=0;i<(*data_).rows();i++)
    60         row_index_.push_back(i);
    61     }
    62 
    6350  }
    6451 
Note: See TracChangeset for help on using the changeset viewer.