Changeset 1483
- Timestamp:
- Sep 9, 2008, 6:03:15 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/Makefile.am
r1458 r1483 40 40 iterator_test kernel_lookup_test kernel_test \ 41 41 knn_test large_file_test matrix_lookup_test matrix_test \ 42 nbc_test \42 matrix_weighted_test nbc_test \ 43 43 ncc_test nni_test normalization_test pca_test \ 44 44 range_test regression_test rnd_test roc_test \ … … 81 81 large_file_test_SOURCES = large_file_test.cc 82 82 matrix_test_SOURCES = matrix_test.cc 83 matrix_weighted_test_SOURCES = matrix_weighted_test.cc 83 84 matrix_lookup_test_SOURCES = matrix_lookup_test.cc 84 85 nbc_test_SOURCES = nbc_test.cc -
trunk/test/distance_test.cc
r1437 r1483 29 29 #include "yat/statistics/PearsonDistance.h" 30 30 #include "yat/utility/Matrix.h" 31 #include "yat/utility/MatrixWeighted.h" 31 32 #include "yat/utility/Vector.h" 32 33 … … 227 228 { 228 229 utility::Matrix x=data(); 229 classifier::MatrixLookupWeighted ml(x);230 double dist1 = dist(m l.begin_row(0), ml.end_row(0), ml.begin_row(1));230 utility::MatrixWeighted mw(x); 231 double dist1 = dist(mw.begin_row(0), mw.end_row(0), mw.begin_row(1)); 231 232 double dist2 = dist(x.begin_row(0), x.end_row(0), x.begin_row(1)); 232 233 check_equality(dist1, dist2, suite, "unity weights", N); -
trunk/test/ncc_test.cc
r1437 r1483 46 46 using namespace theplu::yat; 47 47 48 void predict_nan_data_unweighted_data(test::Suite& suite); 49 48 50 int main(int argc,char* argv[]) 49 51 { 50 52 test::Suite suite(argc, argv); 51 53 suite.err() << "testing ncc" << std::endl; 54 55 predict_nan_data_unweighted_data(suite); 52 56 53 57 ///////////////////////////////////////////// … … 253 257 return suite.return_value(); 254 258 } 259 260 void predict_nan_data_unweighted_data(test::Suite& suite) 261 { 262 ////////////////////////////////////////////////////////////////////////// 263 // A test of predictions using weighted training resulting in NaN's 264 // in centroids and unweighted test data 265 ////////////////////////////////////////////////////////////////////////// 266 suite.err() << "test of predictions using nan centroids and unweighted test data\n"; 267 utility::Matrix data1(3,4); 268 for(size_t i=0;i<3;i++) { 269 data1(i,0)=3-i; 270 data1(i,1)=5-i; 271 data1(i,2)=i+1; 272 data1(i,3)=i+3; 273 } 274 std::vector<std::string> vec1(4, "pos"); 275 vec1[0]="neg"; 276 vec1[1]="neg"; 277 278 classifier::MatrixLookup ml1(data1); 279 classifier::Target target1(vec1); 280 utility::Matrix prediction1; 281 utility::Matrix result1(2,4); 282 283 utility::Matrix weights2(3,4,1.0); 284 weights2(1,0)=weights2(1,1)=0.0; 285 286 classifier::MatrixLookupWeighted mlw2(data1,weights2); 287 classifier::NCC<statistics::EuclideanDistance> ncc2; 288 ncc2.train(mlw2,target1); 289 ncc2.predict(ml1,prediction1); 290 result1(0,0)=result1(0,1)=result1(1,2)=result1(1,3)=sqrt(3.0); 291 result1(1,0)=result1(1,1)=sqrt(11.0); 292 result1(0,2)=result1(0,3)=sqrt(15.0); 293 if(!std::isnan(ncc2.centroids()(1,0))) 294 suite.add(false); 295 if (!suite.equal_range(prediction1.begin(), prediction1.end(), 296 result1.begin())) { 297 suite.add(false); 298 suite.err() << "Difference to expected prediction too large\n"; 299 } 300 } -
trunk/yat/classifier/MatrixLookupWeighted.cc
r1482 r1483 88 88 89 89 90 /* 90 91 MatrixLookupWeighted::MatrixLookupWeighted(const utility::Matrix& data) 91 92 : data_(MatrixP(&data, false)) … … 98 99 assert(validate()); 99 100 } 101 */ 100 102 101 103 -
trunk/yat/classifier/MatrixLookupWeighted.h
r1482 r1483 107 107 \brief Create a lookup into entire \a matrix. 108 108 */ 109 MatrixLookupWeighted(const utility::MatrixWeighted& matrix);109 explicit MatrixLookupWeighted(const utility::MatrixWeighted& matrix); 110 110 111 111 /// … … 133 133 /// result of further use is undefined. 134 134 /// 135 MatrixLookupWeighted(const utility::Matrix& matrix);135 //MatrixLookupWeighted(const utility::Matrix& matrix); 136 136 137 137 -
trunk/yat/classifier/NCC.h
r1437 r1483 34 34 #include "yat/statistics/AveragerWeighted.h" 35 35 #include "yat/utility/Matrix.h" 36 #include "yat/utility/MatrixWeighted.h" 36 37 #include "yat/utility/Vector.h" 37 38 #include "yat/utility/stl_utility.h" … … 294 295 utility::Matrix& prediction) const 295 296 { 296 MatrixLookupWeighted weighted_centroids(centroids_);297 utility::MatrixWeighted weighted_centroids(centroids_); 297 298 for(size_t j=0; j<test.columns();j++) 298 299 for(size_t k=0; k<centroids_.columns();k++) -
trunk/yat/utility/MatrixWeighted.cc
r1469 r1483 123 123 assert(data.columns()==weight.columns()); 124 124 columns_ = data.columns(); 125 resize(data.columns(), data.rows()); 125 resize(data.rows(), data.columns()); 126 assert(rows()==data.rows()); 127 assert(columns()==data.columns()); 126 128 std::copy(data.begin(), data.end(), data_iterator(vec_.begin())); 127 129 std::copy(weight.begin(), weight.end(), weight_iterator(vec_.begin())); … … 169 171 columns_ = columns; 170 172 vec_.resize(rows*columns); 173 assert(this->rows()==rows); 174 assert(this->columns()==columns); 171 175 } 172 176
Note: See TracChangeset
for help on using the changeset viewer.