Changeset 1075
- Timestamp:
- Feb 12, 2008, 1:55:31 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/ncc_test.cc
r1052 r1075 86 86 // A test of predictions using unweighted data 87 87 ///////////////////////////////////////////// 88 *error << "test of predictions using unweighted test data\n"; 88 89 utility::matrix data1(3,4); 89 90 for(size_t i=0;i<3;i++) { … … 119 120 // A test of predictions using unweighted training and weighted test data 120 121 ////////////////////////////////////////////////////////////////////////// 122 *error << "test of predictions using unweighted training and weighted test data\n"; 121 123 utility::matrix weights1(3,4,1.0); 122 124 weights1(0,0)=weights1(1,1)=weights1(2,2)=weights1(1,3)=0.0; … … 137 139 // A test of predictions using Sorlie data 138 140 ////////////////////////////////////////////////////////////////////////// 141 *error << "test with Sorlie data\n"; 139 142 std::ifstream is("data/sorlie_centroid_data.txt"); 140 143 utility::matrix data(is,'\t'); … … 150 153 151 154 classifier::MatrixLookupWeighted dataviewweighted(data,weights); 152 classifier::NCC<statistics:: EuclideanDistance> ncc(dataviewweighted,targets);155 classifier::NCC<statistics::PearsonDistance> ncc(dataviewweighted,targets); 153 156 *error << "training...\n"; 154 157 ncc.train(); … … 200 203 classifier::Kernel_MEV kernel(ml,kf); 201 204 classifier::DataLookup2D* dl_kernel = new classifier::KernelLookup(kernel); 205 bool catch_error=false; 202 206 try { 203 ok=0; // should catch error here207 catch_error=false; // should catch error here 204 208 *error << ncc.make_classifier(*dl_kernel,target) << std::endl; 205 209 } 206 210 catch (std::runtime_error) { 207 211 *error << "caught expected bad cast runtime_error" << std::endl; 208 ok=1; 212 catch_error=true; 213 } 214 if(!catch_error) { 215 ok=false; 209 216 } 210 217 try { 211 ok=0; // should catch error here218 catch_error=false; // should catch error here 212 219 ncc.predict(*dl_kernel,prediction); 213 220 } 214 221 catch (std::runtime_error) { 215 222 *error << "caught expected bad cast runtime_error" << std::endl; 216 ok=1; 223 catch_error=true; 224 } 225 if(!catch_error) { 226 ok=false; 217 227 } 218 228 delete dl_kernel; … … 220 230 if(ok) 221 231 *error << "OK" << std::endl; 232 else 233 *error << "FAILED" << std::endl; 222 234 223 235 if (error!=&std::cerr)
Note: See TracChangeset
for help on using the changeset viewer.