Changeset 1157 for trunk/yat/classifier
- Timestamp:
- Feb 26, 2008, 2:25:19 PM (16 years ago)
- Location:
- trunk/yat/classifier
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/classifier/EnsembleBuilder.h
r1125 r1157 153 153 { 154 154 for(u_long i=0; i<subset_->size();++i) { 155 C* classifier = mother_.make_classifier( subset_->training_data(i),156 subset_->training_target(i));157 classifier->train();155 C* classifier = mother_.make_classifier(); 156 classifier->train(subset_->training_data(i), 157 subset_->training_target(i)); 158 158 classifier_.push_back(classifier); 159 159 } -
trunk/yat/classifier/KNN.h
r1156 r1157 57 57 public: 58 58 /// 59 /// Constructor taking the training data and the target 60 /// as input. 61 /// 62 KNN(const MatrixLookup&, const Target&); 63 64 65 /// 66 /// Constructor taking the training data with weights and the 67 /// target as input. 68 /// 69 KNN(const MatrixLookupWeighted&, const Target&); 70 59 /// @brief Constructor 60 /// 61 KNN(void); 62 63 64 /// 65 /// @brief Destructor 66 /// 71 67 virtual ~KNN(); 72 68 73 //74 // @return the training data75 //76 const DataLookup2D& data(void) const;77 78 69 79 70 /// … … 85 76 86 77 /// 87 /// @brief sets the number of neighbors, k. If the number of 88 /// training samples set is smaller than \a k_in, k is set to the number of 89 /// training samples. 78 /// @brief sets the number of neighbors, k. 90 79 /// 91 80 void k(u_int k_in); 92 81 93 82 94 KNN<Distance,NeighborWeighting>* make_classifier(const DataLookup2D&, 95 const Target&) const; 96 97 /// 98 /// Train the classifier using the training data. 99 /// This function does nothing but is required by the interface. 100 /// 101 void train(); 83 KNN<Distance,NeighborWeighting>* make_classifier(void) const; 84 85 /// 86 /// Train the classifier using training data and target. 87 /// 88 /// If the number of training samples set is smaller than \a k_in, 89 /// k is set to the number of training samples. 90 /// 91 void train(const MatrixLookup&, const Target&); 92 93 /// 94 /// Train the classifier using weighted training data and target. 95 /// 96 void train(const MatrixLookupWeighted&, const Target&); 102 97 103 98 … … 114 109 // data_ has to be of type DataLookup2D to accomodate both 115 110 // MatrixLookup and MatrixLookupWeighted 116 const DataLookup2D& data_; 111 const DataLookup2D* data_; 112 const Target* target_; 117 113 118 114 // The number of neighbors … … 143 139 144 140 template <typename Distance, typename NeighborWeighting> 145 KNN<Distance, NeighborWeighting>::KNN(const MatrixLookup& data, const Target& target) 146 : SupervisedClassifier(target), data_(data),k_(3) 147 { 148 utility::yat_assert<std::runtime_error> 149 (data.columns()==target.size(), 150 "KNN::KNN called with different sizes of target and data"); 151 // k has to be at most the number of training samples. 152 if(data_.columns()>k_) 153 k_=data_.columns(); 154 } 155 156 157 template <typename Distance, typename NeighborWeighting> 158 KNN<Distance, NeighborWeighting>::KNN 159 (const MatrixLookupWeighted& data, const Target& target) 160 : SupervisedClassifier(target), data_(data),k_(3) 161 { 162 utility::yat_assert<std::runtime_error> 163 (data.columns()==target.size(), 164 "KNN::KNN called with different sizes of target and data"); 165 if(data_.columns()>k_) 166 k_=data_.columns(); 167 } 141 KNN<Distance, NeighborWeighting>::KNN() 142 : SupervisedClassifier(),data_(0),target_(0),k_(3) 143 { 144 } 145 168 146 169 147 template <typename Distance, typename NeighborWeighting> … … 178 156 // matrix with training samples as rows and test samples as columns 179 157 utility::Matrix* distances = 180 new utility::Matrix(data_ .columns(),test.columns());158 new utility::Matrix(data_->columns(),test.columns()); 181 159 182 160 … … 186 164 // unweighted training data 187 165 if(const MatrixLookup* training_unweighted = 188 dynamic_cast<const MatrixLookup*>( &data_))166 dynamic_cast<const MatrixLookup*>(data_)) 189 167 calculate_unweighted(*training_unweighted,*test_unweighted,distances); 190 168 // weighted training data 191 169 else if(const MatrixLookupWeighted* training_weighted = 192 dynamic_cast<const MatrixLookupWeighted*>( &data_))170 dynamic_cast<const MatrixLookupWeighted*>(data_)) 193 171 calculate_weighted(*training_weighted,MatrixLookupWeighted(*test_unweighted), 194 172 distances); … … 200 178 // unweighted training data 201 179 if(const MatrixLookup* training_unweighted = 202 dynamic_cast<const MatrixLookup*>( &data_)) {180 dynamic_cast<const MatrixLookup*>(data_)) { 203 181 calculate_weighted(MatrixLookupWeighted(*training_unweighted), 204 182 *test_weighted,distances); … … 206 184 // weighted training data 207 185 else if(const MatrixLookupWeighted* training_weighted = 208 dynamic_cast<const MatrixLookupWeighted*>( &data_))186 dynamic_cast<const MatrixLookupWeighted*>(data_)) 209 187 calculate_weighted(*training_weighted,*test_weighted,distances); 210 188 // Training data can not be of incorrect type … … 252 230 } 253 231 } 254 255 256 template <typename Distance, typename NeighborWeighting>257 const DataLookup2D& KNN<Distance, NeighborWeighting>::data(void) const258 {259 return data_;260 }261 232 262 233 … … 271 242 { 272 243 k_=k; 273 if(k_>data_.columns())274 k_=data_.columns();275 244 } 276 245 … … 278 247 template <typename Distance, typename NeighborWeighting> 279 248 KNN<Distance, NeighborWeighting>* 280 KNN<Distance, NeighborWeighting>::make_classifier(const DataLookup2D& data, 281 const Target& target) const 249 KNN<Distance, NeighborWeighting>::make_classifier() const 282 250 { 283 KNN* knn=0; 284 try { 285 if(data.weighted()) { 286 knn=new KNN<Distance, NeighborWeighting> 287 (dynamic_cast<const MatrixLookupWeighted&>(data),target); 288 } 289 else { 290 knn=new KNN<Distance, NeighborWeighting> 291 (dynamic_cast<const MatrixLookup&>(data),target); 292 } 293 knn->k(this->k()); 294 } 295 catch (std::bad_cast) { 296 std::string str = "Error in KNN<Distance, NeighborWeighting>"; 297 str += "::make_classifier: DataLookup2D of unexpected class."; 298 throw std::runtime_error(str); 299 } 251 KNN* knn=new KNN<Distance, NeighborWeighting>(); 252 knn->k(this->k()); 300 253 return knn; 301 254 } … … 303 256 304 257 template <typename Distance, typename NeighborWeighting> 305 void KNN<Distance, NeighborWeighting>::train() 258 void KNN<Distance, NeighborWeighting>::train(const MatrixLookup& data, 259 const Target& target) 306 260 { 261 utility::yat_assert<std::runtime_error> 262 (data.columns()==target.size(), 263 "KNN::train called with different sizes of target and data"); 264 // k has to be at most the number of training samples. 265 if(data.columns()<k_) 266 k_=data.columns(); 267 data_=&data; 268 target_=⌖ 269 trained_=true; 270 } 271 272 template <typename Distance, typename NeighborWeighting> 273 void KNN<Distance, NeighborWeighting>::train(const MatrixLookupWeighted& data, 274 const Target& target) 275 { 276 utility::yat_assert<std::runtime_error> 277 (data.columns()==target.size(), 278 "KNN::train called with different sizes of target and data"); 279 // k has to be at most the number of training samples. 280 if(data.columns()<k_) 281 k_=data.columns(); 282 data_=&data; 283 target_=⌖ 307 284 trained_=true; 308 285 } … … 313 290 utility::Matrix& prediction) const 314 291 { 315 utility::yat_assert<std::runtime_error>(data_ .rows()==test.rows(),"KNN::predict different number of rows in training and test data");292 utility::yat_assert<std::runtime_error>(data_->rows()==test.rows(),"KNN::predict different number of rows in training and test data"); 316 293 317 294 utility::Matrix* distances=calculate_distances(test); 318 295 319 prediction.resize(target_ .nof_classes(),test.columns(),0.0);296 prediction.resize(target_->nof_classes(),test.columns(),0.0); 320 297 for(size_t sample=0;sample<distances->columns();sample++) { 321 298 std::vector<size_t> k_index; … … 323 300 utility::sort_smallest_index(k_index,k_,dist); 324 301 utility::VectorView pred=prediction.column_view(sample); 325 weighting_(dist,k_index, target_,pred);302 weighting_(dist,k_index,*target_,pred); 326 303 } 327 304 delete distances; … … 329 306 // classes for which there are no training samples should be set 330 307 // to nan in the predictions 331 for(size_t c=0;c<target_ .nof_classes(); c++)332 if(!target_ .size(c))308 for(size_t c=0;c<target_->nof_classes(); c++) 309 if(!target_->size(c)) 333 310 for(size_t j=0;j<prediction.columns();j++) 334 311 prediction(c,j)=std::numeric_limits<double>::quiet_NaN(); -
trunk/yat/classifier/NBC.cc
r1144 r1157 40 40 namespace classifier { 41 41 42 NBC::NBC( const MatrixLookup& data, const Target& target)43 : SupervisedClassifier( target), data_(data)42 NBC::NBC() 43 : SupervisedClassifier() 44 44 { 45 45 } 46 46 47 NBC::NBC(const MatrixLookupWeighted& data, const Target& target)48 : SupervisedClassifier(target), data_(data)49 {50 }51 47 52 48 NBC::~NBC() … … 55 51 56 52 57 const DataLookup2D& NBC::data(void) const 58 { 59 return data_; 60 } 61 62 63 NBC* 64 NBC::make_classifier(const DataLookup2D& data, const Target& target) const 53 NBC* NBC::make_classifier() const 65 54 { 66 NBC* nbc=0; 67 try { 68 if(data.weighted()) { 69 nbc=new NBC(dynamic_cast<const MatrixLookupWeighted&>(data),target); 70 } 71 else { 72 nbc=new NBC(dynamic_cast<const MatrixLookup&>(data),target); 73 } 74 } 75 catch (std::bad_cast) { 76 std::string str = 77 "Error in NBC::make_classifier: DataLookup2D of unexpected class."; 78 throw std::runtime_error(str); 79 } 80 return nbc; 81 } 82 83 84 void NBC::train() 55 return new NBC(); 56 } 57 58 59 void NBC::train(const MatrixLookup& data, const Target& target) 85 60 { 86 sigma2_.resize(data _.rows(), target_.nof_classes());87 centroids_.resize(data _.rows(), target_.nof_classes());88 utility::Matrix nof_in_class(data _.rows(), target_.nof_classes());61 sigma2_.resize(data.rows(), target.nof_classes()); 62 centroids_.resize(data.rows(), target.nof_classes()); 63 utility::Matrix nof_in_class(data.rows(), target.nof_classes()); 89 64 90 // unweighted 91 if (data_.weighted()){ 92 const MatrixLookupWeighted& data = 93 dynamic_cast<const MatrixLookupWeighted&>(data_); 94 for(size_t i=0; i<data_.rows(); ++i) { 95 std::vector<statistics::AveragerWeighted> aver(target_.nof_classes()); 96 for(size_t j=0; j<data_.columns(); ++j) 97 aver[target_(j)].add(data.data(i,j), data.weight(i,j)); 98 99 assert(centroids_.columns()==target_.nof_classes()); 100 for (size_t j=0; j<target_.nof_classes(); ++j){ 101 assert(i<centroids_.rows()); 102 assert(j<centroids_.columns()); 103 assert(i<sigma2_.rows()); 104 assert(j<sigma2_.columns()); 105 if (aver[j].n()>1){ 106 sigma2_(i,j) = aver[j].variance(); 107 centroids_(i,j) = aver[j].mean(); 108 } 65 for(size_t i=0; i<data.rows(); ++i) { 66 std::vector<statistics::Averager> aver(target.nof_classes()); 67 for(size_t j=0; j<data.columns(); ++j) 68 aver[target(j)].add(data(i,j)); 69 70 assert(centroids_.columns()==target.nof_classes()); 71 for (size_t j=0; j<target.nof_classes(); ++j){ 72 assert(i<centroids_.rows()); 73 assert(j<centroids_.columns()); 74 centroids_(i,j) = aver[j].mean(); 75 assert(i<sigma2_.rows()); 76 assert(j<sigma2_.columns()); 77 if (aver[j].n()>1){ 78 sigma2_(i,j) = aver[j].variance(); 79 centroids_(i,j) = aver[j].mean(); 80 } 109 81 else { 110 82 sigma2_(i,j) = std::numeric_limits<double>::quiet_NaN(); 111 83 centroids_(i,j) = std::numeric_limits<double>::quiet_NaN(); 112 84 } 113 } 114 } 115 } 116 else { 117 const MatrixLookup& data = dynamic_cast<const MatrixLookup&>(data_); 118 for(size_t i=0; i<data_.rows(); ++i) { 119 std::vector<statistics::Averager> aver(target_.nof_classes()); 120 for(size_t j=0; j<data_.columns(); ++j) 121 aver[target_(j)].add(data(i,j)); 122 123 assert(centroids_.columns()==target_.nof_classes()); 124 for (size_t j=0; j<target_.nof_classes(); ++j){ 125 assert(i<centroids_.rows()); 126 assert(j<centroids_.columns()); 85 } 86 } 87 trained_=true; 88 } 89 90 91 void NBC::train(const MatrixLookupWeighted& data, const Target& target) 92 { 93 sigma2_.resize(data.rows(), target.nof_classes()); 94 centroids_.resize(data.rows(), target.nof_classes()); 95 utility::Matrix nof_in_class(data.rows(), target.nof_classes()); 96 97 for(size_t i=0; i<data.rows(); ++i) { 98 std::vector<statistics::AveragerWeighted> aver(target.nof_classes()); 99 for(size_t j=0; j<data.columns(); ++j) 100 aver[target(j)].add(data.data(i,j), data.weight(i,j)); 101 102 assert(centroids_.columns()==target.nof_classes()); 103 for (size_t j=0; j<target.nof_classes(); ++j) { 104 assert(i<centroids_.rows()); 105 assert(j<centroids_.columns()); 106 assert(i<sigma2_.rows()); 107 assert(j<sigma2_.columns()); 108 if (aver[j].n()>1){ 109 sigma2_(i,j) = aver[j].variance(); 127 110 centroids_(i,j) = aver[j].mean(); 128 assert(i<sigma2_.rows()); 129 assert(j<sigma2_.columns()); 130 if (aver[j].n()>1){ 131 sigma2_(i,j) = aver[j].variance(); 132 centroids_(i,j) = aver[j].mean(); 133 } 134 else { 135 sigma2_(i,j) = std::numeric_limits<double>::quiet_NaN(); 136 centroids_(i,j) = std::numeric_limits<double>::quiet_NaN(); 137 } 138 } 139 } 140 } 111 } 112 else { 113 sigma2_(i,j) = std::numeric_limits<double>::quiet_NaN(); 114 centroids_(i,j) = std::numeric_limits<double>::quiet_NaN(); 115 } 116 } 117 } 141 118 trained_=true; 142 119 } … … 146 123 utility::Matrix& prediction) const 147 124 { 148 assert(data_.rows()==x.rows());149 125 assert(x.rows()==sigma2_.rows()); 150 126 assert(x.rows()==centroids_.rows()); -
trunk/yat/classifier/NBC.h
r1152 r1157 52 52 public: 53 53 /// 54 /// Constructor taking the training data, the target vector.54 /// @brief Constructor 55 55 /// 56 NBC(const MatrixLookup&, const Target&); 56 NBC(void); 57 58 59 /// 60 /// @brief Destructor 61 /// 62 virtual ~NBC(); 63 64 65 NBC* make_classifier(void) const; 57 66 58 67 /// 59 /// Constructor taking the training data with weights, the target 60 /// vector, the distance measure, and a weight matrix for the 61 /// training data as input. 62 /// 63 NBC(const MatrixLookupWeighted&, const Target&); 64 65 virtual ~NBC(); 66 67 const DataLookup2D& data(void) const; 68 69 70 NBC* make_classifier(const DataLookup2D&, 71 const Target&) const; 72 73 /// 74 /// Train the classifier using the training data. 68 /// Train the classifier using training data and targets. 75 69 /// 76 70 /// For each class mean and variance are estimated for each … … 81 75 /// specific label. 82 76 /// 83 void train(); 77 void train(const MatrixLookup&, const Target&); 78 79 /// 80 /// Train the classifier using weighted training data and targets. 81 /// 82 void train(const MatrixLookupWeighted&, const Target&); 83 84 84 85 85 … … 106 106 utility::Matrix centroids_; 107 107 utility::Matrix sigma2_; 108 const DataLookup2D& data_;109 108 110 109 double sum_logsigma(size_t i) const; -
trunk/yat/classifier/NCC.h
r1144 r1157 65 65 public: 66 66 /// 67 /// Constructor taking the training data and the target vector as 68 /// input 69 /// 70 NCC(const MatrixLookup&, const Target&); 71 72 /// 73 /// Constructor taking the training data with weights and the 74 /// target vector as input. 75 /// 76 NCC(const MatrixLookupWeighted&, const Target&); 77 78 virtual ~NCC(); 67 /// @brief Constructor 68 /// 69 NCC(void); 70 71 72 /// 73 /// @brief Destructor 74 /// 75 virtual ~NCC(void); 79 76 80 77 /// … … 83 80 const utility::Matrix& centroids(void) const; 84 81 85 const DataLookup2D& data(void) const; 86 87 NCC<Distance>* make_classifier(const DataLookup2D&, 88 const Target&) const; 89 90 /// 91 /// Train the classifier using the training data. Centroids are 92 /// calculated for each class. 93 /// 94 void train(); 82 NCC<Distance>* make_classifier(void) const; 83 84 /// 85 /// Train the classifier with a training data set and 86 /// targets. Centroids are calculated for each class. 87 /// 88 void train(const MatrixLookup&, const Target&); 89 90 91 /// 92 /// Train the classifier with a weighted training data set and 93 /// targets. Centroids are calculated for each class. 94 /// 95 void train(const MatrixLookupWeighted&, const Target&); 95 96 96 97 … … 109 110 bool centroids_nan_; 110 111 Distance distance_; 111 112 // data_ has to be of type DataLookup2D to accomodate both113 // MatrixLookup and MatrixLookupWeighted114 const DataLookup2D& data_;115 112 }; 116 113 … … 124 121 125 122 template <typename Distance> 126 NCC<Distance>::NCC(const MatrixLookup& data, const Target& target) 127 : SupervisedClassifier(target), centroids_(0), centroids_nan_(false), data_(data) 128 { 129 } 130 131 template <typename Distance> 132 NCC<Distance>::NCC(const MatrixLookupWeighted& data, const Target& target) 133 : SupervisedClassifier(target), centroids_(0), centroids_nan_(false), data_(data) 134 { 135 } 123 NCC<Distance>::NCC() 124 : SupervisedClassifier(), centroids_(0), centroids_nan_(false) 125 { 126 } 127 136 128 137 129 template <typename Distance> … … 142 134 } 143 135 136 144 137 template <typename Distance> 145 138 const utility::Matrix& NCC<Distance>::centroids(void) const … … 150 143 151 144 template <typename Distance> 152 const DataLookup2D& NCC<Distance>::data(void) const153 {154 return data_;155 }156 157 template <typename Distance>158 145 NCC<Distance>* 159 NCC<Distance>::make_classifier( const DataLookup2D& data, const Target& target) const146 NCC<Distance>::make_classifier() const 160 147 { 161 NCC* ncc=0; 162 try { 163 if(data.weighted()) { 164 ncc=new NCC<Distance>(dynamic_cast<const MatrixLookupWeighted&>(data), 165 target); 166 } 167 else { 168 ncc=new NCC<Distance>(dynamic_cast<const MatrixLookup&>(data), 169 target); 170 } 171 } 172 catch (std::bad_cast) { 173 std::string str = "Error in NCC<Distance>::make_classifier: DataLookup2D of unexpected class."; 174 throw std::runtime_error(str); 175 } 176 return ncc; 177 } 178 179 180 template <typename Distance> 181 void NCC<Distance>::train() 148 return new NCC<Distance>(); 149 } 150 151 template <typename Distance> 152 void NCC<Distance>::train(const MatrixLookup& data, const Target& target) 182 153 { 183 154 if(centroids_) 184 155 delete centroids_; 185 centroids_= new utility::Matrix(data_.rows(), target_.nof_classes()); 186 // data_ is a MatrixLookup or a MatrixLookupWeighted 187 if(data_.weighted()) { 188 const MatrixLookupWeighted* weighted_data = 189 dynamic_cast<const MatrixLookupWeighted*>(&data_); 190 for(size_t i=0; i<data_.rows(); i++) { 191 std::vector<statistics::AveragerWeighted> class_averager; 192 class_averager.resize(target_.nof_classes()); 193 for(size_t j=0; j<data_.columns(); j++) { 194 class_averager[target_(j)].add(weighted_data->data(i,j), 195 weighted_data->weight(i,j)); 156 centroids_= new utility::Matrix(data.rows(), target.nof_classes()); 157 for(size_t i=0; i<data.rows(); i++) { 158 std::vector<statistics::Averager> class_averager; 159 class_averager.resize(target.nof_classes()); 160 for(size_t j=0; j<data.columns(); j++) { 161 class_averager[target(j)].add(data(i,j)); 162 } 163 for(size_t c=0;c<target.nof_classes();c++) { 164 (*centroids_)(i,c) = class_averager[c].mean(); 165 } 166 } 167 trained_=true; 168 } 169 170 171 template <typename Distance> 172 void NCC<Distance>::train(const MatrixLookupWeighted& data, const Target& target) 173 { 174 if(centroids_) 175 delete centroids_; 176 centroids_= new utility::Matrix(data.rows(), target.nof_classes()); 177 for(size_t i=0; i<data.rows(); i++) { 178 std::vector<statistics::AveragerWeighted> class_averager; 179 class_averager.resize(target.nof_classes()); 180 for(size_t j=0; j<data.columns(); j++) 181 class_averager[target(j)].add(data.data(i,j),data.weight(i,j)); 182 for(size_t c=0;c<target.nof_classes();c++) { 183 if(class_averager[c].sum_w()==0) { 184 centroids_nan_=true; 196 185 } 197 for(size_t c=0;c<target_.nof_classes();c++) { 198 if(class_averager[c].sum_w()==0) { 199 centroids_nan_=true; 200 } 201 (*centroids_)(i,c) = class_averager[c].mean(); 202 } 203 } 204 } 205 else { 206 const MatrixLookup* unweighted_data = 207 dynamic_cast<const MatrixLookup*>(&data_); 208 for(size_t i=0; i<data_.rows(); i++) { 209 std::vector<statistics::Averager> class_averager; 210 class_averager.resize(target_.nof_classes()); 211 for(size_t j=0; j<data_.columns(); j++) { 212 class_averager[target_(j)].add((*unweighted_data)(i,j)); 213 } 214 for(size_t c=0;c<target_.nof_classes();c++) { 215 (*centroids_)(i,c) = class_averager[c].mean(); 216 } 217 } 218 } 219 } 186 (*centroids_)(i,c) = class_averager[c].mean(); 187 } 188 } 189 trained_=true; 190 } 191 220 192 221 193 template <typename Distance> … … 226 198 (centroids_,"NCC::predict called for untrained classifier"); 227 199 utility::yat_assert<std::runtime_error> 228 ( data_.rows()==test.rows(),200 (centroids_->rows()==test.rows(), 229 201 "NCC::predict test data with incorrect number of rows"); 230 202 -
trunk/yat/classifier/SupervisedClassifier.cc
r1000 r1157 30 30 namespace classifier { 31 31 32 SupervisedClassifier::SupervisedClassifier( const Target& target)33 : t arget_(target), trained_(false)32 SupervisedClassifier::SupervisedClassifier() 33 : trained_(false) 34 34 { 35 35 } -
trunk/yat/classifier/SupervisedClassifier.h
r1125 r1157 39 39 40 40 class DataLookup2D; 41 class MatrixLookup; 42 class MatrixLookupWeighted; 41 43 class Target; 42 44 … … 50 52 public: 51 53 /// 52 /// @brief Constructor taking a Target object.54 /// @brief Constructor 53 55 /// 54 SupervisedClassifier( const Target&);56 SupervisedClassifier(void); 55 57 56 58 … … 59 61 /// 60 62 virtual ~SupervisedClassifier(void); 61 62 ///63 /// @brief Access to the training data64 ///65 virtual const DataLookup2D& data(void) const =0;66 63 67 64 … … 75 72 /// 76 73 virtual SupervisedClassifier* 77 make_classifier( const DataLookup2D&, const Target&) const =0;74 make_classifier() const =0; 78 75 79 76 … … 88 85 /// Train the classifier. 89 86 /// 90 virtual void train()=0; 87 virtual void train(const MatrixLookup&, const Target&)=0; 88 89 /// 90 /// Train the classifier. 91 /// 92 virtual void train(const MatrixLookupWeighted&, const Target&)=0; 91 93 92 94 93 95 protected: 94 96 95 /// Target to train on.96 const Target& target_;97 97 /// true if classifier successfully trained 98 bool trained_; 99 98 bool trained_; 100 99 101 100 };
Note: See TracChangeset
for help on using the changeset viewer.