Changeset 2335
- Timestamp:
- Oct 15, 2010, 2:22:13 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/classifier/KNN.h
r2334 r2335 199 199 template <typename Distance, typename NeighborWeighting> 200 200 KNN<Distance, NeighborWeighting>::KNN(const Distance& dist) 201 : SupervisedClassifier(),data_ml_(0),data_mlw_(0),target_(0),k_(3), distance_(dist) 201 : SupervisedClassifier(), data_ml_(0), data_mlw_(0), target_(0), k_(3), 202 distance_(dist) 202 203 { 203 204 BOOST_CONCEPT_ASSERT((utility::DistanceConcept<Distance>)); … … 218 219 for(size_t i=0; i<training.columns(); i++) { 219 220 for(size_t j=0; j<test.columns(); j++) { 220 (*distances)(i,j) = distance_(training.begin_column(i), training.end_column(i), 221 (*distances)(i,j) = distance_(training.begin_column(i), 222 training.end_column(i), 221 223 test.begin_column(j)); 222 224 YAT_ASSERT(!std::isnan((*distances)(i,j))); … … 234 236 for(size_t i=0; i<training.columns(); i++) { 235 237 for(size_t j=0; j<test.columns(); j++) { 236 (*distances)(i,j) = distance_(training.begin_column(i), training.end_column(i), 238 (*distances)(i,j) = distance_(training.begin_column(i), 239 training.end_column(i), 237 240 test.begin_column(j)); 238 241 // If the distance is NaN (no common variables with non-zero weights), … … 303 306 304 307 template <typename Distance, typename NeighborWeighting> 305 void KNN<Distance, NeighborWeighting>::predict(const MatrixLookup& test, 306 utility::Matrix& prediction) const 308 void 309 KNN<Distance, NeighborWeighting>::predict(const MatrixLookup& test, 310 utility::Matrix& prediction) const 307 311 { 308 312 // matrix with training samples as rows and test samples as columns … … 336 340 337 341 template <typename Distance, typename NeighborWeighting> 338 void KNN<Distance, NeighborWeighting>::predict(const MatrixLookupWeighted& test, 339 utility::Matrix& prediction) const 342 void 343 KNN<Distance, NeighborWeighting>::predict(const MatrixLookupWeighted& test, 344 utility::Matrix& prediction) const 340 345 { 341 346 // matrix with training samples as rows and test samples as columns … … 387 392 prediction(c,j)=std::numeric_limits<double>::quiet_NaN(); 388 393 } 389 390 391 394 }}} // of namespace classifier, yat, and theplu 392 395 393 396 #endif 394
Note: See TracChangeset
for help on using the changeset viewer.