Changeset 656 for trunk/c++_tools
- Timestamp:
- Sep 22, 2006, 12:07:54 PM (17 years ago)
- Location:
- trunk/c++_tools/classifier
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/c++_tools/classifier/DataLookup2D.h
r648 r656 79 79 80 80 /// 81 /// @return number of rows 82 /// 83 inline size_t rows(void) const { return row_index_.size(); } 84 85 /// 81 86 /// @return Data based on selected features. 82 87 /// … … 99 104 /// 100 105 virtual const DataLookup2D* 101 training_data(const std::vector<size_t>& features,102 const std::vector<size_t>& samples) const=0;103 104 ///105 /// @return number of rows106 ///107 inline size_t rows(void) const { return row_index_.size(); }108 109 ///110 /// @return sub-Lookup of the DataLookup2D111 ///112 /// @Note Returns a dynamically allocated DataLookup2D, which has113 /// to be deleted by the caller to avoid memory leaks.114 ///115 virtual const DataLookup2D*116 106 validation_data(const std::vector<size_t>& train, 117 const std::vector<size_t>& val) const=0;118 119 ///120 /// @return sub-Lookup of the DataLookup2D121 ///122 /// @Note Returns a dynamically allocated DataLookup2D, which has123 /// to be deleted by the caller to avoid memory leaks.124 ///125 virtual const DataLookup2D*126 validation_data(const std::vector<size_t>& features,127 const std::vector<size_t>& train,128 107 const std::vector<size_t>& val) const=0; 129 108 -
trunk/c++_tools/classifier/KernelLookup.h
r654 r656 221 221 222 222 /// 223 /// @todo remove 224 /// @note This function will probably be removed 223 /// Each element in returned KernelLookup is calculated using only 224 /// selected features (defined by @a index). Each element 225 /// corresponds to the same pair of samples as in the original 226 /// KernelLookup. 225 227 /// 226 228 /// @Note Returns a dynamically allocated KernelLookup, which has 227 229 /// to be deleted by the caller to avoid memory leaks. 228 230 /// 229 const KernelLookup* selected(const std::vector<size_t>& ) const;231 const KernelLookup* selected(const std::vector<size_t>& index) const; 230 232 231 233 /// … … 233 235 /// 234 236 inline bool weighted(void) const { return kernel_->weighted(); } 235 236 ///237 /// Each column in returned MatrixLook corresponds to the column238 /// in KernelLookup. If no weights were used in construction of239 /// Kernel, each element in returned MatrixLookup is set to unity.240 ///241 /// @Note Returns a dynamically allocated MatrixLookup2D, which has242 /// to be deleted by the caller to avoid memory leaks.243 ///244 // Peter remove this245 //inline const MatrixLookup* weights(void) const246 //{ return new MatrixLookup(kernel_->weights(),column_index_, false); }247 248 237 249 238 private: -
trunk/c++_tools/classifier/MatrixLookup.cc
r640 r656 155 155 156 156 const MatrixLookup* 157 MatrixLookup::training_data(const std::vector<size_t>& features,158 const std::vector<size_t>& samples) const159 {160 return new MatrixLookup(*this, features, samples);161 }162 163 164 165 const MatrixLookup*166 157 MatrixLookup::validation_data(const std::vector<size_t>& train, 167 158 const std::vector<size_t>& val) const 168 159 { 169 160 return new MatrixLookup(*this,val, false); 170 }171 172 173 174 const MatrixLookup*175 MatrixLookup::validation_data(const std::vector<size_t>& features,176 const std::vector<size_t>& train,177 const std::vector<size_t>& val) const178 {179 return new MatrixLookup(*this,features, val);180 161 } 181 162 -
trunk/c++_tools/classifier/MatrixLookup.h
r648 r656 69 69 /// Constructor creating a lookup into a sub-matrix of @a matrix. 70 70 /// 71 /// If @a row_vectors is true the new MatrixLookup will beconsist71 /// If @a row_vectors is true the new MatrixLookup will consist 72 72 /// of the row vectors defined by @a index. This means that the 73 73 /// created MatrixLookup will fullfill: … … 120 120 /// underlying matrix to avoid multiple lookups. 121 121 /// 122 /// If @a row_vectors is true the new MatrixLookup will beconsist122 /// If @a row_vectors is true the new MatrixLookup will consist 123 123 /// of the row vectors defined by @a index. This means that the 124 124 /// created MatrixLookup will fullfill: 125 125 /// \f$ MatrixLookup(i,j)=ml(i,index[j])\f$ 126 126 /// 127 /// If @a row_vectors is false the new MatrixLookup will beconsist127 /// If @a row_vectors is false the new MatrixLookup will consist 128 128 /// of the rolumn vectors defined by @a index. This means that the 129 129 /// created MatrixLookup will fullfill: … … 156 156 157 157 /// 158 /// Destructor. If MatrixLookup is owner of underlying matrix, the 159 /// matrix is destroyed. 158 /// Destructor. 160 159 /// 161 160 virtual ~MatrixLookup(); 162 161 163 /// 164 /// @todo doc 165 /// 162 /** 163 the new MatrixLookup will consist of the rolumn vectors 164 defined by @a index. This means that the returned MatrixLookup 165 will fullfill: \f$ returned(i,j) = original(index[i],j) \f$ 166 167 @note If underlying matrix goes out of scope or is deleted, the 168 returned pointer becomes invalid and the result of further use is 169 undefined. 170 171 */ 166 172 const MatrixLookup* selected(const std::vector<size_t>&) const; 167 173 … … 177 183 /// returned pointer becomes invalid and the result of further use is 178 184 /// undefined. 185 /// 186 /// @Note Returns a dynamically allocated DataLookup2D, which has 187 /// to be deleted by the caller to avoid memory leaks. 179 188 /// 180 189 const MatrixLookup* training_data(const std::vector<size_t>& index) const; … … 192 201 /// undefined. 193 202 /// 203 /** 194 204 const MatrixLookup* training_data(const std::vector<size_t>& features, 195 205 const std::vector<size_t>& samples) const; 196 206 */ 197 207 /// 198 208 /// The created MatrixLookup corresponds to all rows and the … … 221 231 /// undefined. 222 232 /// 233 /** 223 234 const MatrixLookup* validation_data(const std::vector<size_t>& features, 224 235 const std::vector<size_t>& train, 225 236 const std::vector<size_t>& val) const; 237 */ 226 238 /// 227 239 /// @return false -
trunk/c++_tools/classifier/MatrixLookupWeighted.cc
r640 r656 225 225 226 226 const MatrixLookupWeighted* 227 MatrixLookupWeighted::training_data(const std::vector<size_t>& features,228 const std::vector<size_t>& samples) const229 {230 return new MatrixLookupWeighted(*this,features, samples);231 }232 233 234 235 const MatrixLookupWeighted*236 227 MatrixLookupWeighted::validation_data(const std::vector<size_t>& train, 237 228 const std::vector<size_t>& val) const 238 229 { 239 230 return new MatrixLookupWeighted(*this,val, false); 240 }241 242 243 244 const MatrixLookupWeighted*245 MatrixLookupWeighted::validation_data(const std::vector<size_t>& features,246 const std::vector<size_t>& training,247 const std::vector<size_t>& val) const248 {249 return new MatrixLookupWeighted(*this,features, val);250 231 } 251 232 -
trunk/c++_tools/classifier/MatrixLookupWeighted.h
r648 r656 213 213 214 214 /// 215 /// The created MatrixLookupWeighted corresponds to rows defined216 /// by @a features and columns defined by @a samples in the217 /// original MatrixLookupWeighted. The created218 /// MatrixLookupWeighted will fullfill:219 /// \f$ novel_ml(i,j)=original(features[i],samples[j]) \f$.220 ///221 /// @return pointer to sub-Lookup of the MatrixLookupWeighted222 ///223 /// @note If underlying matrix goes out of scope or is deleted, the224 /// returned pointer becomes invalid and the result of further use is225 /// undefined.226 ///227 const MatrixLookupWeighted*228 training_data(const std::vector<size_t>& features,229 const std::vector<size_t>& samples) const;230 231 ///232 215 /// The created MatrixLookupWeighted corresponds to all rows and the 233 216 /// columns defined by @a index in the original MatrixLookupWeighted. The … … 243 226 const MatrixLookupWeighted* validation_data(const std::vector<size_t>&, 244 227 const std::vector<size_t>&) const; 245 246 ///247 /// The created MatrixLookupWeighted corresponds to rows defined248 /// by @a features and columns defined by @a val in the original249 /// MatrixLookupWeighted. The created MatrixLookupWeighted will250 /// fullfill: \f$ novel_ml(i,j)=original(features[i],val[j]) \f$.251 ///252 /// @return pointer to sub-Lookup of the MatrixLookupWeighted253 ///254 /// @note If underlying matrix goes out of scope or is deleted, the255 /// returned pointer becomes invalid and the result of further use is256 /// undefined.257 ///258 const MatrixLookupWeighted*259 validation_data(const std::vector<size_t>& features,260 const std::vector<size_t>& training,261 const std::vector<size_t>& val) const;262 228 263 229 /// -
trunk/c++_tools/classifier/SubsetGenerator.cc
r640 r656 87 87 88 88 // Dynamically allocated. Must be deleted in destructor. 89 training_data_.push_back(ml->training_data(features_.back(), 90 training_index())); 91 validation_data_.push_back(ml->validation_data(features_.back(), 92 training_index(), 93 validation_index())); 89 training_data_.push_back(new MatrixLookup(*ml,features_.back(), 90 training_index())); 91 validation_data_.push_back(new MatrixLookup(*ml,features_.back(), 92 validation_index())); 94 93 } 95 94 } … … 113 112 114 113 // Dynamically allocated. Must be deleted in destructor. 115 training_data_.push_back(ml->training_data(features_.back(), 116 training_index())); 117 validation_data_.push_back(ml->validation_data(features_.back(), 118 training_index(), 119 validation_index())); 120 114 training_data_.push_back(new MatrixLookupWeighted(*ml, 115 features_.back(), 116 training_index() 117 )); 118 validation_data_.push_back(new MatrixLookupWeighted(*ml, 119 features_.back(), 120 validation_index() 121 )); 121 122 } 122 123 }
Note: See TracChangeset
for help on using the changeset viewer.