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

added weights in CrossSplitter? - not supported in interface though.

File:
1 edited

Legend:

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

    r517 r540  
    2121    assert(target.size()>1);
    2222    assert(target.size()==data.columns());
     23
     24    build(target, N, k);
     25
     26    for (size_t i=0; i<N; i++){
     27     
     28      // Dynamically allocated. Must be deleted in destructor.
     29      training_data_.push_back(data.training_data(training_index_[i]));
     30      validation_data_.push_back(data.validation_data(training_index_[i],
     31                                                    validation_index_[i]));
     32      training_weight_.push_back(new MatrixLookup(0,1));
     33      validation_weight_.push_back(new MatrixLookup(0,1));
     34
     35
     36      training_target_.push_back(Target(target,training_index_[i]));
     37      validation_target_.push_back(Target(target,validation_index_[i]));
     38    }
     39    assert(training_data_.size()==N);
     40    assert(training_weight_.size()==N);
     41    assert(training_target_.size()==N);
     42    assert(validation_data_.size()==N);
     43    assert(validation_weight_.size()==N);
     44    assert(validation_target_.size()==N);
     45  }
     46
     47  CrossSplitter::~CrossSplitter()
     48  {
     49    assert(training_data_.size()==validation_data_.size());
     50    for (size_t i=0; i<training_data_.size(); i++)
     51      delete training_data_[i];
     52    for (size_t i=0; i<validation_data_.size(); i++)
     53      delete validation_data_[i];
     54  }
     55
     56  void CrossSplitter::build(const Target& target, size_t N, size_t k)
     57  {
    2358    std::vector<std::pair<size_t,size_t> > v;
    2459    for (size_t i=0; i<target.size(); i++)
     
    5388        }
    5489
    55         // Dynamically allocated. Must be deleted in destructor.
    56         training_data_.push_back(data.training_data(training_index));
    57         validation_data_.push_back(data.validation_data(training_index,
    58                                                         validation_index));
    59 
    60         training_target_.push_back(Target(target,training_index));
    61         validation_target_.push_back(Target(target,validation_index));
    6290        training_index_.push_back(training_index);
    6391        validation_index_.push_back(validation_index);
    64 
    6592      }
    6693    }
    67     assert(training_data_.size()==N);
    68     assert(training_target_.size()==N);
    6994    assert(training_index_.size()==N);
    70     assert(validation_data_.size()==N);
    71     assert(validation_target_.size()==N);
    7295    assert(validation_index_.size()==N);
    73   }
    74 
    75   CrossSplitter::~CrossSplitter()
    76   {
    77     assert(training_data_.size()==validation_data_.size());
    78     for (size_t i=0; i<training_data_.size(); i++)
    79       delete training_data_[i];
    80     for (size_t i=0; i<validation_data_.size(); i++)
    81       delete validation_data_[i];
    82   }
     96}
    8397
    8498}} // of namespace classifier and namespace theplu
Note: See TracChangeset for help on using the changeset viewer.