- Timestamp:
- Mar 5, 2008, 3:56:13 AM (16 years ago)
- Location:
- trunk/yat/classifier
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/classifier/KernelLookup.cc
r1168 r1201 28 28 29 29 #include <cassert> 30 #ifndef NDEBUG31 #include <algorithm>32 #endif33 30 34 31 namespace theplu { … … 187 184 188 185 189 const KernelLookup*186 utility::SmartPtr<const KernelLookup> 190 187 KernelLookup::selected(const utility::Index& inputs) const 191 188 { … … 203 200 kernel = kernel_->make_kernel(*ms,true); 204 201 } 205 return new KernelLookup(*kernel, true); 206 } 207 208 209 const KernelLookup* KernelLookup::test_kernel(const MatrixLookup& data) const 210 { 211 202 return utility::SmartPtr<const KernelLookup> 203 (new KernelLookup(*kernel, true)); 204 } 205 206 207 utility::SmartPtr<const KernelLookup> 208 KernelLookup::test_kernel(const MatrixLookup& data) const 209 { 212 210 if (!weighted()){ 213 211 assert(data.rows()==kernel_->data().rows()); … … 242 240 kernel_->make_kernel(*tmp, true); 243 241 244 return new KernelLookup(*kernel, utility::Index(row_index), 245 utility::Index(column_index), true); 242 return utility::SmartPtr<const KernelLookup> 243 (new KernelLookup(*kernel, utility::Index(row_index), 244 utility::Index(column_index), true)); 246 245 } 247 246 … … 281 280 *weight_all, true); 282 281 const Kernel* kernel = kernel_->make_kernel(*tmp, true); 283 return new KernelLookup(*kernel, row_index_, 284 utility::Index(column_index), true); 285 } 286 287 288 289 const KernelLookup* 282 283 284 return utility::SmartPtr<const KernelLookup> 285 (new KernelLookup(*kernel, row_index_, 286 utility::Index(column_index), true)); 287 } 288 289 290 291 utility::SmartPtr<const KernelLookup> 290 292 KernelLookup::test_kernel(const MatrixLookupWeighted& data) const 291 293 { … … 329 331 const Kernel* kernel = 330 332 kernel_->make_kernel(MatrixLookupWeighted(*data_all, *weight_all, true)); 331 return new KernelLookup(*kernel, row_index_, 332 utility::Index(column_index), true); 333 return utility::SmartPtr<const KernelLookup> 334 (new KernelLookup(*kernel, row_index_, 335 utility::Index(column_index), true)); 333 336 } 334 337 -
trunk/yat/classifier/KernelLookup.h
r1170 r1201 267 267 corresponds to the same pair of samples as in the original 268 268 KernelLookup. 269 270 \note Returns a dynamically allocated KernelLookup, which has 271 to be deleted by the caller to avoid memory leaks. 272 */ 273 const KernelLookup* selected(const utility::Index& index) const; 269 */ 270 utility::SmartPtr<const KernelLookup> 271 selected(const utility::Index& index) const; 274 272 273 /** 274 This function is useful when predicting on an independent data 275 set using a kernel-based classifier. In returned KernelLookup 276 column \f$ i \f$ corresponds to column \f$ i \f$ in @a 277 data. Row \f$ i \f$ in returned KernelLookup corresponds to 278 same sample as row \f$ i \f$ in @a this. In other words, this 279 function returns a KernelLookup containing the kernel elements 280 between the passed @a data and the internal underlying data @a 281 this was built from. 282 */ 283 utility::SmartPtr<const KernelLookup> 284 test_kernel(const MatrixLookup& data) const; 285 275 286 /** 276 287 This function is useful when predicting on an independent data … … 286 297 to be deleted by the caller to avoid memory leaks. 287 298 */ 288 const KernelLookup* test_kernel(const MatrixLookup& data) const; 289 290 /** 291 This function is useful when predicting on an independent data 292 set using a kernel-based classifier. In returned KernelLookup 293 column \f$ i \f$ corresponds to column \f$ i \f$ in @a 294 data. Row \f$ i \f$ in returned KernelLookup corresponds to 295 same sample as row \f$ i \f$ in @a this. In other words, this 296 function returns a KernelLookup containing the kernel elements 297 between the passed @a data and the internal underlying data @a 298 this was built from. 299 300 @note Returns a dynamically allocated KernelLookup, which has 301 to be deleted by the caller to avoid memory leaks. 302 */ 303 const KernelLookup* test_kernel(const MatrixLookupWeighted& data) const; 299 utility::SmartPtr<const KernelLookup> 300 test_kernel(const MatrixLookupWeighted& data) const; 304 301 305 302 /** -
trunk/yat/classifier/SubsetGenerator.h
r1186 r1201 33 33 #include "Sampler.h" 34 34 #include "yat/utility/Index.h" 35 #include "yat/utility/SmartPtr.h" 35 36 #include "yat/utility/yat_assert.h" 36 37 … … 278 279 } 279 280 features_.push_back(f_selector_->features()); 280 const KernelLookup* kl = kernel.selected(features_.back()); 281 utility::SmartPtr<const KernelLookup> kl = 282 kernel.selected(features_.back()); 281 283 // Dynamically allocated. Must be deleted in destructor. 282 training_data_.push_back(new KernelLookup( kernel,training_index(k),284 training_data_.push_back(new KernelLookup(*kl,training_index(k), 283 285 training_index(k))); 284 validation_data_.push_back(new KernelLookup( kernel, training_index(k),286 validation_data_.push_back(new KernelLookup(*kl, training_index(k), 285 287 validation_index(k))); 286 utility::yat_assert<std::runtime_error>(kl);287 delete kl;288 288 } 289 289 else {// no feature selection
Note: See TracChangeset
for help on using the changeset viewer.