Changeset 1121 for trunk/yat/classifier/KNN.h
 Timestamp:
 Feb 22, 2008, 4:29:56 PM (15 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/yat/classifier/KNN.h
r1115 r1121 32 32 #include "SupervisedClassifier.h" 33 33 #include "Target.h" 34 #include "yat/utility/ matrix.h"34 #include "yat/utility/Matrix.h" 35 35 #include "yat/utility/yat_assert.h" 36 36 … … 107 107 /// 108 108 /// 109 void predict(const DataLookup2D&, utility:: matrix&) const;109 void predict(const DataLookup2D&, utility::Matrix&) const; 110 110 111 111 … … 129 129 /// generated and needs to be deleted by the caller. 130 130 /// 131 utility:: matrix* calculate_distances(const DataLookup2D&) const;131 utility::Matrix* calculate_distances(const DataLookup2D&) const; 132 132 133 133 void calculate_unweighted(const MatrixLookup&, 134 134 const MatrixLookup&, 135 utility:: matrix*) const;135 utility::Matrix*) const; 136 136 void calculate_weighted(const MatrixLookupWeighted&, 137 137 const MatrixLookupWeighted&, 138 utility:: matrix*) const;138 utility::Matrix*) const; 139 139 }; 140 140 … … 162 162 163 163 template <typename Distance, typename NeighborWeighting> 164 utility:: matrix* KNN<Distance, NeighborWeighting>::calculate_distances164 utility::Matrix* KNN<Distance, NeighborWeighting>::calculate_distances 165 165 (const DataLookup2D& test) const 166 166 { 167 167 // matrix with training samples as rows and test samples as columns 168 utility:: matrix* distances =169 new utility:: matrix(data_.columns(),test.columns());168 utility::Matrix* distances = 169 new utility::Matrix(data_.columns(),test.columns()); 170 170 171 171 … … 210 210 void KNN<Distance, NeighborWeighting>::calculate_unweighted 211 211 (const MatrixLookup& training, const MatrixLookup& test, 212 utility:: matrix* distances) const212 utility::Matrix* distances) const 213 213 { 214 214 for(size_t i=0; i<training.columns(); i++) { … … 226 226 KNN<Distance, NeighborWeighting>::calculate_weighted 227 227 (const MatrixLookupWeighted& training, const MatrixLookupWeighted& test, 228 utility:: matrix* distances) const228 utility::Matrix* distances) const 229 229 { 230 230 for(size_t i=0; i<training.columns(); i++) { … … 295 295 template <typename Distance, typename NeighborWeighting> 296 296 void KNN<Distance, NeighborWeighting>::predict(const DataLookup2D& test, 297 utility:: matrix& prediction) const297 utility::Matrix& prediction) const 298 298 { 299 299 utility::yat_assert<std::runtime_error>(data_.rows()==test.rows()); 300 300 301 utility:: matrix* distances=calculate_distances(test);301 utility::Matrix* distances=calculate_distances(test); 302 302 303 303 prediction.resize(target_.nof_classes(),test.columns(),0.0);
Note: See TracChangeset
for help on using the changeset viewer.