Changeset 1206 for trunk/yat/classifier/EnsembleBuilder.h
 Timestamp:
 Mar 5, 2008, 6:56:01 PM (14 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/yat/classifier/EnsembleBuilder.h
r1157 r1206 115 115 SubsetGenerator<Data>* subset_; 116 116 std::vector<Classifier*> classifier_; 117 KernelLookup test_data(const KernelLookup&, size_t k); 118 MatrixLookup test_data(const MatrixLookup&, size_t k); 119 MatrixLookupWeighted test_data(const MatrixLookupWeighted&, size_t k); 117 120 std::vector<std::vector<statistics::Averager> > validation_result_; 118 121 … … 169 172 170 173 template <class C, class D> 171 u_long EnsembleBuilder<C, D>::size(void) const172 {173 return classifier_.size();174 }175 176 177 template <class C, class D>178 174 void EnsembleBuilder<C, D>::predict 179 175 (const D& data, std::vector<std::vector<statistics::Averager> >& result) … … 187 183 188 184 for(u_long k=0;k<subset_>size();++k) { 189 const D* sub_data = 190 data.selected(subset_>training_features(k)); 191 assert(sub_data); 192 classifier(k).predict(*sub_data,prediction); 193 delete sub_data; 185 D sub_data = test_data(data, k); 186 classifier(k).predict(sub_data,prediction); 194 187 } 195 188 … … 200 193 201 194 195 template <class C, class D> 196 u_long EnsembleBuilder<C, D>::size(void) const 197 { 198 return classifier_.size(); 199 } 200 201 202 template <class C, class D> 203 MatrixLookup EnsembleBuilder<C, D>::test_data(const MatrixLookup& data, 204 size_t k) 205 { 206 return MatrixLookup(data, subset_>training_features(k), true); 207 } 208 209 210 template <class C, class D> 211 MatrixLookupWeighted 212 EnsembleBuilder<C, D>::test_data(const MatrixLookupWeighted& data, size_t k) 213 { 214 return MatrixLookupWeighted(data, subset_>training_features(k), true); 215 } 216 217 218 template <class C, class D> 219 KernelLookup 220 EnsembleBuilder<C, D>::test_data(const KernelLookup& kernel, size_t k) 221 { 222 // weighted case 223 if (kernel.weighted()){ 224 assert(false); 225 // no feature selection 226 if (kernel.data_weighted().rows()==subset_>training_features(k).size()) 227 return KernelLookup(kernel, subset_>training_index(k), true); 228 MatrixLookupWeighted mlw = test_data(kernel.data_weighted(), k); 229 return subset_>training_data(k).test_kernel(mlw); 230 231 } 232 // unweighted case 233 234 // no feature selection 235 if (kernel.data().rows()==subset_>training_features(k).size()) 236 return KernelLookup(kernel, subset_>training_index(k), true); 237 238 // feature selection 239 return subset_>training_data(k).test_kernel(test_data(kernel.data(),k)); 240 } 241 242 202 243 template <class C, class D> 203 244 const std::vector<std::vector<statistics::Averager> >&
Note: See TracChangeset
for help on using the changeset viewer.