Changeset 520
- Timestamp:
- Feb 22, 2006, 4:01:10 PM (17 years ago)
- Location:
- trunk/lib/classifier
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/classifier/EnsembleBuilder.h
r505 r520 35 35 36 36 /// 37 /// Generate ensemble 37 /// Generate ensemble. Function trains each member of the Ensemble. 38 38 /// 39 39 void build(void); -
trunk/lib/classifier/SVM.cc
r514 r520 239 239 240 240 epochs++; 241 if (epochs>max_epochs_) 241 if (epochs>max_epochs_){ 242 std::cerr << "WARNING: SVM: maximal number of epochs reached.\n"; 242 243 return false; 244 } 243 245 } 244 246 -
trunk/lib/classifier/SVM.h
r514 r520 117 117 118 118 /// 119 /// @return \f$\alpha\f$ 120 /// 121 inline const gslapi::vector& alpha(void) const { return alpha_; } 122 123 /// 119 124 /// The C-parameter is the balance term (see train()). A very 120 125 /// large C means the training will be focused on getting samples … … 131 136 /// 132 137 inline double C(void) const { return 1/C_inverse_; } 133 134 ///135 /// @return \f$\alpha\f$136 ///137 inline const gslapi::vector& alpha(void) const { return alpha_; }138 138 139 139 /// -
trunk/lib/classifier/Target.cc
r514 r520 25 25 : class_map_(t.class_map_) 26 26 { 27 binary_ .resize(index.size());27 binary_=t.binary_; 28 28 classes_.resize(index.size()); 29 29 for (size_t i=0; i<index.size(); i++) { 30 30 assert(index[i]<t.size()); 31 31 classes_[i]=t.classes_[index[i]]; 32 binary_[i]=t.binary_[index[i]];33 32 } 34 33 labels_ = t.labels_; … … 90 89 } 91 90 // setting binary to false for every class 92 binary_=std::vector< short>(label.size(),0);91 binary_=std::vector<char>(nof_classes(),false); 93 92 94 93 set_binary(0,true); 95 94 96 95 } 97 98 // const Target& Target::operator=(const Target& other)99 //{100 // classes_=other.classes_;101 // class_map_=other.class_map_;102 // labels_=other.labels_;103 // return *this;104 //}105 106 void Target::set_binary(const size_t target, const bool b)107 {108 for (size_t i=0; i<classes_.size(); i++)109 if (classes_[i]==target)110 binary_[i]=b;111 }112 113 96 114 97 std::ostream& operator<<(std::ostream& s, const Target& a) -
trunk/lib/classifier/Target.h
r514 r520 69 69 70 70 /// 71 /// Default binary is set to false for all classes except class 0 71 /// Default binary is set to false for all classes except class 0. 72 72 /// 73 /// @return true if class of sample @a i is set to true73 /// @return binary target for sample @a i 74 74 /// 75 75 /// @see set_binary 76 76 /// 77 77 inline bool binary(const size_t i) const 78 { assert(i<size()); return binary_[ i]; }78 { assert(i<size()); return binary_[operator()(i)]; } 79 79 80 80 /// 81 /// Class @a target is set to @a b. Default is binary set to false 82 /// for each class. 81 /// Binary target for each sample with class @a i is set to @a 82 /// b. Default is binary set to false for each class except class 83 /// 0 which is set to true. 83 84 /// 84 void set_binary(const size_t target, const bool b); 85 inline void set_binary(const size_t i, const bool b) 86 { assert(i<nof_classes()); binary_[i]=b; } 85 87 86 88 /// … … 102 104 103 105 private: 104 std::vector<short> binary_; // avoid using vector<bool> 106 // binary target for class i 107 std::vector<char> binary_; // avoid using vector<bool> 105 108 std::vector<size_t> classes_; // class of sample i 106 109 std::map<std::string,size_t> class_map_;
Note: See TracChangeset
for help on using the changeset viewer.