Changeset 525
- Timestamp:
- Feb 24, 2006, 5:29:22 PM (17 years ago)
- Location:
- trunk/lib/classifier
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/classifier/NCC.cc
r523 r525 5 5 #include <c++_tools/classifier/DataLookup1D.h> 6 6 #include <c++_tools/classifier/DataLookup2D.h> 7 #include <c++_tools/classifier/InputRanker.h> 7 8 #include <c++_tools/classifier/Target.h> 8 9 #include <c++_tools/gslapi/vector.h> … … 24 25 } 25 26 27 NCC::NCC(const DataLookup2D& data, const Target& target, 28 const statistics::Distance& distance, 29 statistics::Score& score, size_t nof_inputs) 30 : SupervisedClassifier(target, &score, nof_inputs), 31 distance_(distance), matrix_(data) 32 { 33 } 34 35 NCC::~NCC() 36 { 37 if(ranker_) 38 delete ranker_; 39 } 40 41 26 42 SupervisedClassifier* 27 43 NCC::make_classifier(const DataLookup2D& data, 28 44 const Target& target) const 29 45 { 30 NCC* sc= new NCC(data,target,this->distance_); 31 return sc; 46 NCC* ncc= new NCC(data,target,this->distance_); 47 ncc->score_=this->score_; 48 ncc->nof_inputs_=this->nof_inputs_; 49 return ncc; 32 50 } 33 51 … … 35 53 bool NCC::train() 36 54 { 55 if(ranker_) 56 delete ranker_; 57 if(score_) 58 ranker_=new InputRanker(matrix_, target_, *score_); 59 // Markus : ranker_ should be taken into account if used!!! 60 37 61 // Calculate the centroids for each class 38 62 centroids_=gslapi::matrix(matrix_.rows(),target_.nof_classes()); … … 54 78 gslapi::vector& prediction) const 55 79 { 80 // Markus : ranker_ should be taken into account if used!!! 81 56 82 prediction=gslapi::vector(centroids_.columns()); 57 83 gslapi::vector w(input.size(),0); … … 68 94 gslapi::matrix& prediction) const 69 95 { 96 // Markus : ranker_ should be taken into account if used!!! 97 70 98 prediction=gslapi::matrix(centroids_.columns(), input.columns()); 71 99 for(size_t j=0; j<input.columns();j++) { -
trunk/lib/classifier/NCC.h
r523 r525 7 7 8 8 #include <c++_tools/classifier/SupervisedClassifier.h> 9 //#include <c++_tools/statistics/Distance.h>10 9 11 10 #include <map> … … 15 14 namespace statistics { 16 15 class Distance; 16 class Score; 17 17 } 18 18 … … 36 36 /// 37 37 NCC(const DataLookup2D&, const Target&, const statistics::Distance&); 38 39 NCC(const DataLookup2D&, const Target&, const statistics::Distance&, 40 statistics::Score&, const size_t); 41 42 virtual ~NCC(); 38 43 39 44 const gslapi::matrix& centroids(void) const {return centroids_;} -
trunk/lib/classifier/SupervisedClassifier.cc
r523 r525 6 6 namespace classifier { 7 7 8 SupervisedClassifier::SupervisedClassifier(const Target& target) 9 : target_(target), trained_(false) 8 SupervisedClassifier::SupervisedClassifier(const Target& target, 9 statistics::Score* score, 10 const size_t nof_inputs) 11 : target_(target), score_(score), ranker_(0), nof_inputs_(nof_inputs), 12 trained_(false) 10 13 { 11 14 } -
trunk/lib/classifier/SupervisedClassifier.h
r523 r525 4 4 #define _theplu_classifier_supervisedclassifier_ 5 5 6 #include <cctype> 6 7 7 8 namespace theplu { … … 12 13 } 13 14 15 namespace statistics { 16 class Score; 17 } 18 19 14 20 namespace classifier { 15 21 16 22 class DataLookup2D; 17 class Target;23 class InputRanker; class Target; 18 24 19 25 … … 29 35 /// Constructor. Taking a vector of target values. 30 36 /// 31 SupervisedClassifier(const Target&); 37 SupervisedClassifier(const Target&, statistics::Score* =0, 38 const size_t=0); 32 39 33 40 /// … … 62 69 63 70 const Target& target_; 71 statistics::Score* score_; 72 classifier::InputRanker* ranker_; 73 size_t nof_inputs_; 64 74 bool trained_; 65 75
Note: See TracChangeset
for help on using the changeset viewer.