Ignore:
Timestamp:
Mar 5, 2006, 4:20:58 PM (16 years ago)
Author:
Peter
Message:

weights supported in CrossSplitter?

File:
1 edited

Legend:

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

    r540 r541  
    2828      // Dynamically allocated. Must be deleted in destructor.
    2929      training_data_.push_back(data.training_data(training_index_[i]));
     30      training_weight_.push_back
     31        (new MatrixLookup(training_data_.back()->rows(),
     32                          training_data_.back()->columns(),1));
    3033      validation_data_.push_back(data.validation_data(training_index_[i],
    3134                                                    validation_index_[i]));
    32       training_weight_.push_back(new MatrixLookup(0,1));
    33       validation_weight_.push_back(new MatrixLookup(0,1));
     35      validation_weight_.push_back
     36        (new MatrixLookup(validation_data_.back()->rows(),
     37                          validation_data_.back()->columns(),1));
     38
     39
     40      training_target_.push_back(Target(target,training_index_[i]));
     41      validation_target_.push_back(Target(target,validation_index_[i]));
     42    }
     43    assert(training_data_.size()==N);
     44    assert(training_weight_.size()==N);
     45    assert(training_target_.size()==N);
     46    assert(validation_data_.size()==N);
     47    assert(validation_weight_.size()==N);
     48    assert(validation_target_.size()==N);
     49  }
     50
     51  CrossSplitter::CrossSplitter(const Target& target, const DataLookup2D& data,
     52                               const MatrixLookup& weight,
     53                               const size_t N, const size_t k)
     54    : k_(k), state_(0), target_(target)
     55  {
     56    assert(target.size()>1);
     57    assert(target.size()==data.columns());
     58
     59    build(target, N, k);
     60
     61    for (size_t i=0; i<N; i++){
     62     
     63      // Dynamically allocated. Must be deleted in destructor.
     64      training_data_.push_back(data.training_data(training_index_[i]));
     65      validation_data_.push_back(data.validation_data(training_index_[i],
     66                                                    validation_index_[i]));
     67      training_weight_.push_back(weight.training_data(training_index_[i]));
     68      validation_weight_.push_back(weight.validation_data(training_index_[i],
     69                                                          validation_index_[i]));
    3470
    3571
     
    5288    for (size_t i=0; i<validation_data_.size(); i++)
    5389      delete validation_data_[i];
     90    for (size_t i=0; i<training_weight_.size(); i++)
     91      delete training_weight_[i];
     92    for (size_t i=0; i<validation_weight_.size(); i++)
     93      delete validation_weight_[i];
    5494  }
    5595
Note: See TracChangeset for help on using the changeset viewer.