Changeset 1142 for trunk/test/ncc_test.cc
- Timestamp:
- Feb 25, 2008, 3:32:35 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/ncc_test.cc
r1132 r1142 159 159 160 160 ////////////////////////////////////////////////////////////////////////// 161 // A test of predictions when a centroid has nan for all variables that a 162 // test sample has non-zero weights for. 163 ////////////////////////////////////////////////////////////////////////// 164 *error << "test of predictions using nan centroids and weighted test data\n"; 165 *error << "... using EuclideanDistance" << std::endl; 166 weights1(0,0)=weights1(2,0)=0; 167 classifier::NCC<statistics::EuclideanDistance> ncc3(mlw2,target1); 168 ncc3.train(); 169 ncc3.predict(mlw1,prediction1); 170 if(!std::isnan(ncc3.centroids()(1,0))) { 171 ok=false; 172 *error << "Training failed: expected nan in centroid" << std::endl; 173 } 174 if(!(std::isnan(prediction1(0,0)) && 175 fabs(prediction1(1,0)-sqrt(3.0))<slack_bound && 176 fabs(prediction1(0,1)-sqrt(3.0))<slack_bound && 177 fabs(prediction1(1,1)-sqrt(15.0))<slack_bound && 178 fabs(prediction1(0,2)-sqrt(27.0))<slack_bound)) { 179 ok=false; 180 *error << "Test failed: predictions incorrect" << std::endl; 181 } 182 *error << "... using PearsonDistance" << std::endl;; 183 classifier::NCC<statistics::PearsonDistance> ncc4(mlw2,target1); 184 ncc4.train(); 185 ncc4.predict(mlw1,prediction1); 186 if(!std::isnan(ncc4.centroids()(1,0))) { 187 ok=false; 188 *error << "Training failed: expected nan in centroid" << std::endl; 189 } 190 if(!(std::isnan(prediction1(0,0)) && 191 std::isnan(prediction1(0,2)) && 192 std::isnan(prediction1(1,0)) && 193 fabs(prediction1(0,1))<slack_bound && 194 fabs(prediction1(1,2))<slack_bound && 195 fabs(prediction1(1,3))<slack_bound && 196 fabs(prediction1(0,3)-2.0)<slack_bound && 197 fabs(prediction1(1,1)-2.0)<slack_bound)) { 198 ok=false; 199 *error << "Test failed: predictions incorrect" << std::endl; 200 } 201 202 203 ////////////////////////////////////////////////////////////////////////// 161 204 // A test of predictions using Sorlie data 162 205 //////////////////////////////////////////////////////////////////////////
Note: See TracChangeset
for help on using the changeset viewer.