Ignore:
Timestamp:
Mar 5, 2008, 6:56:01 PM (14 years ago)
Author:
Peter
Message:

fixes #345

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/classifier/SubsetGenerator.h

    r1201 r1206  
    202202  void SubsetGenerator<T>::build(const MatrixLookup& ml)
    203203  {
     204    if (!f_selector_)// no feature selection
     205      features_.push_back(utility::Index(ml.rows()));
     206
    204207    for (size_t k=0; k<size(); k++){
    205208      training_target_.push_back(Target(target(),training_index(k)));
     
    217220        delete train_data_all_feat;
    218221      }
    219       else // no feature selection
    220         features_.push_back(utility::Index(ml.rows()));
    221 
    222222     
    223223      // Dynamically allocated. Must be deleted in destructor.
     
    234234  void SubsetGenerator<T>::build(const MatrixLookupWeighted& ml)
    235235  {
     236    if (!f_selector_)// no feature selection
     237      features_.push_back(utility::Index(ml.rows()));
     238
    236239    for (u_long k=0; k<size(); k++){
    237240      training_target_.push_back(Target(target(),training_index(k)));
     
    247250        delete train_data_all_feat;
    248251      }
    249       else // no feature selection
    250         features_.push_back(utility::Index(ml.rows()));
    251252
    252253
     
    268269      if (f_selector_){
    269270        if (kernel.weighted()){
    270           utility::SmartPtr<const MatrixLookupWeighted> ml=
    271             kernel.data_weighted();
    272           f_selector_->update(MatrixLookupWeighted(*ml,training_index(k),false),
     271          MatrixLookupWeighted ml = kernel.data_weighted();
     272          f_selector_->update(MatrixLookupWeighted(ml,training_index(k),false),
    273273                              training_target(k));
    274274        }
    275275        else {
    276           utility::SmartPtr<const MatrixLookup> ml=kernel.data();
    277           f_selector_->update(MatrixLookup(*ml,training_index(k), false),
     276          MatrixLookup ml=kernel.data();
     277          f_selector_->update(MatrixLookup(ml,training_index(k), false),
    278278                              training_target(k));
    279279        }
    280280        features_.push_back(f_selector_->features());
    281         utility::SmartPtr<const KernelLookup> kl =
    282           kernel.selected(features_.back());
     281        KernelLookup kl = kernel.selected(features_.back());
    283282        // Dynamically allocated. Must be deleted in destructor.
    284         training_data_.push_back(new KernelLookup(*kl,training_index(k),
     283        training_data_.push_back(new KernelLookup(kl,training_index(k),
    285284                                                  training_index(k)));
    286         validation_data_.push_back(new KernelLookup(*kl, training_index(k),
     285        validation_data_.push_back(new KernelLookup(kl, training_index(k),
    287286                                                    validation_index(k)));
    288287      }
     
    296295     
    297296    }
     297    if (!f_selector_){
     298      if (kernel.weighted())
     299        features_.push_back(utility::Index(kernel.data_weighted().rows()));
     300      else
     301        features_.push_back(utility::Index(kernel.data().rows()));
     302    }
    298303  }
    299304
     
    325330  SubsetGenerator<T>::training_features(size_t i) const
    326331  {
     332    utility::yat_assert<std::runtime_error>(features_.size(),
     333                                           "SubsetGenerator::training_features");
    327334    return f_selector_ ? features_[i] : features_[0];
    328335  }
Note: See TracChangeset for help on using the changeset viewer.