Changeset 607
- Timestamp:
- Aug 29, 2006, 4:42:28 PM (17 years ago)
- Location:
- trunk/c++_tools/classifier
- Files:
-
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/c++_tools/classifier/ConsensusInputRanker.cc
-
Property
svn:keywords
changed from
Author Date Id Revision
toId
-
Property
svn:keywords
changed from
-
trunk/c++_tools/classifier/ConsensusInputRanker.h
-
Property
svn:keywords
changed from
Author Date Id Revision
toId
-
Property
svn:keywords
changed from
-
trunk/c++_tools/classifier/CrossSplitter.cc
-
Property
svn:keywords
changed from
Author Date Id Revision
toId
r558 r607 4 4 #include <c++_tools/classifier/CrossSplitter.h> 5 5 #include <c++_tools/classifier/DataLookup2D.h> 6 #include <c++_tools/classifier/FeatureSelector.h> 6 7 #include <c++_tools/classifier/Target.h> 7 8 #include <c++_tools/random/random.h> … … 41 42 validation_target_.push_back(Target(target,validation_index_[i])); 42 43 } 44 45 // No feature selection, hence features same for all partitions 46 // and can be stored in features_[0] 47 features_.resize(1); 48 features_[0].reserve(data.rows()); 49 for (size_t i=0; i<data.rows(); ++i) 50 features_[0].push_back(i); 51 43 52 assert(training_data_.size()==N); 44 53 assert(training_weight_.size()==N); … … 73 82 validation_target_.push_back(Target(target,validation_index_[i])); 74 83 } 84 assert(training_data_.size()==N); 85 assert(training_weight_.size()==N); 86 assert(training_target_.size()==N); 87 assert(validation_data_.size()==N); 88 assert(validation_weight_.size()==N); 89 assert(validation_target_.size()==N); 90 } 91 92 CrossSplitter::CrossSplitter(const Target& target, const DataLookup2D& data, 93 const size_t N, const size_t k, 94 FeatureSelector& fs) 95 : k_(k), state_(0), target_(target), weighted_(false), f_selector_(&fs) 96 { 97 assert(target.size()>1); 98 assert(target.size()==data.columns()); 99 100 build(target, N, k); 101 features_.reserve(N); 102 training_data_.reserve(N); 103 training_weight_.reserve(N); 104 validation_data_.reserve(N); 105 validation_weight_.reserve(N); 106 107 for (size_t i=0; i<N; i++){ 108 109 // training data with no feature selection 110 const DataLookup2D* train_data_all_feat = 111 data.training_data(training_index_[i]); 112 // use these data to create feature selection 113 f_selector_->update(*train_data_all_feat, training_target_[i]); 114 // get features 115 features_.push_back(f_selector_->features()); 116 delete train_data_all_feat; 117 118 // Dynamically allocated. Must be deleted in destructor. 119 training_data_.push_back(data.training_data(features_[i], 120 training_index_[i])); 121 training_weight_.push_back 122 (new MatrixLookup(training_data_.back()->rows(), 123 training_data_.back()->columns(),1)); 124 validation_data_.push_back(data.validation_data(features_[i], 125 training_index_[i], 126 validation_index_[i])); 127 validation_weight_.push_back 128 (new MatrixLookup(validation_data_.back()->rows(), 129 validation_data_.back()->columns(),1)); 130 131 132 training_target_.push_back(Target(target,training_index_[i])); 133 validation_target_.push_back(Target(target,validation_index_[i])); 134 } 135 136 // No feature selection, hence features same for all partitions 137 // and can be stored in features_[0] 138 features_.resize(1); 139 features_[0].reserve(data.rows()); 140 for (size_t i=0; i<data.rows(); ++i) 141 features_[0].push_back(i); 142 75 143 assert(training_data_.size()==N); 76 144 assert(training_weight_.size()==N); -
Property
svn:keywords
changed from
-
trunk/c++_tools/classifier/CrossSplitter.h
-
Property
svn:keywords
changed from
Author Date Id Revision
toId
r560 r607 14 14 namespace classifier { 15 15 class DataLookup2D; 16 16 class FeatureSelector; 17 17 18 18 /// … … 50 50 /// @parameter k for k-fold crossvalidation 51 51 /// 52 /// @todo This most likely be removed. 52 53 CrossSplitter(const Target& target, const DataLookup2D& data, 53 54 const MatrixLookup& weight, 54 55 const size_t N, const size_t k); 55 56 57 /// 58 /// @brief Constructor 59 /// 60 /// @parameter Target targets 61 /// @parameter data data to split up in validation and training. 62 /// @parameter N total number of partitions 63 /// @parameter k for k-fold crossvalidation 64 /// 65 CrossSplitter(const Target& target, const DataLookup2D& data, 66 const size_t N, const size_t k, FeatureSelector&); 67 56 68 /// 57 69 /// Destructor … … 98 110 /// @note if state is invalid the result is undefined 99 111 /// 112 inline const std::vector<size_t>& training_features(void) const 113 { assert(more()); return f_selector_ ? features_[state_] : features_[0]; } 114 115 116 /// @return training index 117 /// 118 /// @note if state is invalid the result is undefined 119 /// 100 120 inline const std::vector<size_t>& training_index(void) const 101 121 { assert(more()); return training_index_[state_]; } 102 103 122 104 123 /// … … 172 191 std::vector<std::vector<size_t> > validation_index_; 173 192 std::vector<Target> validation_target_; 193 194 FeatureSelector* f_selector_; 195 std::vector<std::vector<size_t> > features_; 196 174 197 }; 175 198 -
Property
svn:keywords
changed from
-
trunk/c++_tools/classifier/DataLookup2D.cc
-
Property
svn:eol-style
set to
native
-
Property
svn:keywords
set to
Id
-
Property
svn:eol-style
set to
-
trunk/c++_tools/classifier/DataLookup2D.h
-
Property
svn:eol-style
set to
native
-
Property
svn:keywords
set to
Id
r604 r607 82 82 83 83 /// 84 /// @return sub-Lookup of the DataLookup2D85 84 /// 86 /// @Note Returns a dynamically allocated DataLookup2D, which has87 /// to be deleted by the caller to avoid memory leaks.88 ///89 virtual const DataLookup2D*90 training_data(const std::vector<size_t>&) const=0;91 92 ///93 /// @return number of rows94 ///95 inline size_t rows(void) const { return row_index_.size(); }96 97 ///98 /// @todo doc99 85 /// 100 86 virtual const DataLookup2D* selected(const std::vector< size_t > &) const=0; … … 107 93 /// 108 94 virtual const DataLookup2D* 95 training_data(const std::vector<size_t>&) const=0; 96 97 /// 98 /// @return sub-Lookup of the DataLookup2D 99 /// 100 /// @Note Returns a dynamically allocated DataLookup2D, which has 101 /// to be deleted by the caller to avoid memory leaks. 102 /// 103 virtual const DataLookup2D* 104 training_data(const std::vector<size_t>& features, 105 const std::vector<size_t>& samples) const=0; 106 107 /// 108 /// @return number of rows 109 /// 110 inline size_t rows(void) const { return row_index_.size(); } 111 112 /// 113 /// @return sub-Lookup of the DataLookup2D 114 /// 115 /// @Note Returns a dynamically allocated DataLookup2D, which has 116 /// to be deleted by the caller to avoid memory leaks. 117 /// 118 virtual const DataLookup2D* 109 119 validation_data(const std::vector<size_t>& train, 120 const std::vector<size_t>& val) const=0; 121 122 /// 123 /// @return sub-Lookup of the DataLookup2D 124 /// 125 /// @Note Returns a dynamically allocated DataLookup2D, which has 126 /// to be deleted by the caller to avoid memory leaks. 127 /// 128 virtual const DataLookup2D* 129 validation_data(const std::vector<size_t>& features, 130 const std::vector<size_t>& train, 110 131 const std::vector<size_t>& val) const=0; 111 132 -
Property
svn:eol-style
set to
-
trunk/c++_tools/classifier/FeatureSelector.cc
-
Property
svn:eol-style
set to
native
-
Property
svn:keywords
set to
Id
-
Property
svn:eol-style
set to
-
trunk/c++_tools/classifier/FeatureSelector.h
-
Property
svn:eol-style
set to
native
-
Property
svn:keywords
set to
Id
r604 r607 36 36 37 37 /// 38 /// 39 /// 40 inline const std::vector<size_t> features(void) const { return features_; } 41 42 /// 38 43 /// Uses @a data to select features. 39 44 /// -
Property
svn:eol-style
set to
-
trunk/c++_tools/classifier/FeatureSelectorIR.cc
-
Property
svn:eol-style
set to
native
-
Property
svn:keywords
set to
Id
-
Property
svn:eol-style
set to
-
trunk/c++_tools/classifier/FeatureSelectorIR.h
-
Property
svn:eol-style
set to
native
-
Property
svn:keywords
set to
Id
-
Property
svn:eol-style
set to
-
trunk/c++_tools/classifier/GaussianKernelFunction.cc
-
Property
svn:keywords
changed from
Author Date Id Revision
toId
-
Property
svn:keywords
changed from
-
trunk/c++_tools/classifier/GaussianKernelFunction.h
-
Property
svn:keywords
changed from
Author Date Id Revision
toId
-
Property
svn:keywords
changed from
-
trunk/c++_tools/classifier/InputRanker.cc
-
Property
svn:keywords
changed from
Author Date Id Revision
toId
-
Property
svn:keywords
changed from
-
trunk/c++_tools/classifier/InputRanker.h
-
Property
svn:keywords
changed from
Author Date Id Revision
toId
-
Property
svn:keywords
changed from
-
trunk/c++_tools/classifier/KernelFunction.h
-
Property
svn:keywords
changed from
Author Date Id Revision
toId
-
Property
svn:keywords
changed from
-
trunk/c++_tools/classifier/KernelLookup.cc
r568 r607 88 88 89 89 const KernelLookup* 90 KernelLookup::training_data(const std::vector<size_t>& features, 91 const std::vector<size_t>& train) const 92 { 93 const Kernel* kernel = kernel_->selected(features); 94 return new KernelLookup(*kernel, train, train, true); 95 } 96 97 98 const KernelLookup* 90 99 KernelLookup::validation_data(const std::vector<size_t>& train, 91 100 const std::vector<size_t>& validation) const 92 101 { 93 102 return new KernelLookup(*this,train,validation); 103 } 104 105 106 const KernelLookup* 107 KernelLookup::validation_data(const std::vector<size_t>& features, 108 const std::vector<size_t>& train, 109 const std::vector<size_t>& validation) const 110 { 111 const Kernel* kernel = kernel_->selected(features); 112 return new KernelLookup(*kernel, train, validation, true); 94 113 } 95 114 -
trunk/c++_tools/classifier/KernelLookup.h
r597 r607 135 135 136 136 /// 137 /// @retun a sub-kernel of kernel calculated using data defined by 138 /// @a features. Each row and each columns corresponds to a traing 139 /// sample defined by @a train. 140 /// 141 /// @return pointer to dynamically allocated sub-Lookup of the KernelLookup 142 /// 143 /// @Note Returns a dynamically allocated DataLookup2D, which has 144 /// to be deleted by the caller to avoid memory leaks. 145 /// 146 const KernelLookup* training_data(const std::vector<size_t>& features, 147 const std::vector<size_t>& train) const; 148 149 150 /// 137 151 /// In returned kernel each row corresponds to a training sample 138 152 /// and each column corresponds to a validation sample. The … … 147 161 const KernelLookup* 148 162 validation_data(const std::vector<size_t>& train, 163 const std::vector<size_t>& validation) const; 164 165 166 /// 167 /// In returned kernel each row corresponds to a training sample 168 /// and each column corresponds to a validation sample. The kernel 169 /// is based on the features defined by @a features. 170 /// 171 /// @Note Returns a dynamically allocated DataLookup2D, which has 172 /// to be deleted by the caller to avoid memory leaks. 173 /// 174 const KernelLookup* 175 validation_data(const std::vector<size_t>& features, 176 const std::vector<size_t>& train, 149 177 const std::vector<size_t>& validation) const; 150 178 -
trunk/c++_tools/classifier/Kernel_MEV.h
-
Property
svn:keywords
changed from
Author Date Id Revision
toId
-
Property
svn:keywords
changed from
-
trunk/c++_tools/classifier/Makefile.am
-
Property
svn:eol-style
set to
native
-
Property
svn:keywords
set to
Id
r604 r607 1 1 ## Process this file with automake to produce Makefile.in 2 2 ## 3 ## $Id : Makefile.am 281 2005-04-20 16:45:02Z peter$3 ## $Id$ 4 4 5 5 # Copyright (C) 2005, 2006 Jari Häkkinen, Peter Johansson, Markus Ringnèr -
Property
svn:eol-style
set to
-
trunk/c++_tools/classifier/MatrixLookup.cc
-
Property
svn:eol-style
set to
native
-
Property
svn:keywords
set to
Id
r604 r607 140 140 141 141 const MatrixLookup* 142 MatrixLookup::training_data(const std::vector<size_t>& features, 143 const std::vector<size_t>& samples) const 144 { 145 return new MatrixLookup(*this, features, samples); 146 } 147 148 149 150 const MatrixLookup* 142 151 MatrixLookup::validation_data(const std::vector<size_t>& train, 143 152 const std::vector<size_t>& val) const 144 153 { 145 154 return new MatrixLookup(*this,val, false); 155 } 156 157 158 159 const MatrixLookup* 160 MatrixLookup::validation_data(const std::vector<size_t>& features, 161 const std::vector<size_t>& train, 162 const std::vector<size_t>& val) const 163 { 164 return new MatrixLookup(*this,features, val); 146 165 } 147 166 -
Property
svn:eol-style
set to
-
trunk/c++_tools/classifier/MatrixLookup.h
-
Property
svn:eol-style
set to
native
-
Property
svn:keywords
set to
Id
r604 r607 181 181 182 182 /// 183 /// The created MatrixLookup corresponds the columns defines by @a 184 /// samples and the rows defined by @a samples in the original 185 /// MatrixLookup. The created MatrixLookup will fullfill: \f$ 186 /// novel_ml(i,j)=original(samp[i],feat[j]) \f$. 187 /// 188 /// @return pointer to sub-Lookup of the MatrixLookup 189 /// 190 /// @note If underlying matrix goes out of scope or is deleted, the 191 /// returned pointer becomes invalid and the result of further use is 192 /// undefined. 193 /// 194 const MatrixLookup* training_data(const std::vector<size_t>& features, 195 const std::vector<size_t>& samples) const; 196 197 /// 183 198 /// The created MatrixLookup corresponds to all rows and the 184 199 /// columns defined by @a index in the original MatrixLookup. The … … 194 209 const MatrixLookup* validation_data(const std::vector<size_t>&, 195 210 const std::vector<size_t>&) const; 211 /// 212 /// The created MatrixLookup corresponds to rows defined by @a features and 213 /// columns defined by @a val in the original MatrixLookup. The 214 /// created MatrixLookup will fullfill: 215 /// \f$ novel_ml(i,j)=original(features[i],val[j]) \f$. 216 /// 217 /// @return pointer to sub-Lookup of the MatrixLookup 218 /// 219 /// @note If underlying matrix goes out of scope or is deleted, the 220 /// returned pointer becomes invalid and the result of further use is 221 /// undefined. 222 /// 223 const MatrixLookup* validation_data(const std::vector<size_t>& features, 224 const std::vector<size_t>& train, 225 const std::vector<size_t>& val) const; 196 226 /// 197 227 /// Access operator -
Property
svn:eol-style
set to
-
trunk/c++_tools/classifier/MatrixLookupWeighted.cc
-
Property
svn:eol-style
set to
native
-
Property
svn:keywords
set to
Id
r604 r607 179 179 180 180 const MatrixLookupWeighted* 181 MatrixLookupWeighted::training_data(const std::vector<size_t>& features, 182 const std::vector<size_t>& samples) const 183 { 184 return new MatrixLookupWeighted(*this,features, samples); 185 } 186 187 188 189 const MatrixLookupWeighted* 181 190 MatrixLookupWeighted::validation_data(const std::vector<size_t>& train, 182 const std::vector<size_t>& val) const191 const std::vector<size_t>& val) const 183 192 { 184 193 return new MatrixLookupWeighted(*this,val, false); 194 } 195 196 197 198 const MatrixLookupWeighted* 199 MatrixLookupWeighted::validation_data(const std::vector<size_t>& features, 200 const std::vector<size_t>& training, 201 const std::vector<size_t>& val) const 202 { 203 return new MatrixLookupWeighted(*this,features, val); 185 204 } 186 205 -
Property
svn:eol-style
set to
-
trunk/c++_tools/classifier/MatrixLookupWeighted.h
-
Property
svn:eol-style
set to
native
-
Property
svn:keywords
set to
Id
r604 r607 179 179 /// 180 180 /// @todo doc 181 /// 182 const MatrixLookupWeighted* 183 selected(const std::vector<size_t>& index) const; 181 /// 182 const MatrixLookupWeighted* selected(const std::vector<size_t>& i) const; 184 183 185 184 /// … … 199 198 200 199 /// 200 /// The created MatrixLookupWeighted corresponds to rows defined 201 /// by @a features and columns defined by @a samples in the 202 /// original MatrixLookupWeighted. The created 203 /// MatrixLookupWeighted will fullfill: 204 /// \f$ novel_ml(i,j)=original(features[i],samples[j]) \f$. 205 /// 206 /// @return pointer to sub-Lookup of the MatrixLookupWeighted 207 /// 208 /// @note If underlying matrix goes out of scope or is deleted, the 209 /// returned pointer becomes invalid and the result of further use is 210 /// undefined. 211 /// 212 const MatrixLookupWeighted* 213 training_data(const std::vector<size_t>& features, 214 const std::vector<size_t>& samples) const; 215 216 /// 201 217 /// The created MatrixLookupWeighted corresponds to all rows and the 202 218 /// columns defined by @a index in the original MatrixLookupWeighted. The … … 212 228 const MatrixLookupWeighted* validation_data(const std::vector<size_t>&, 213 229 const std::vector<size_t>&) const; 230 231 /// 232 /// The created MatrixLookupWeighted corresponds to rows defined 233 /// by @a features and columns defined by @a val in the original 234 /// MatrixLookupWeighted. The created MatrixLookupWeighted will 235 /// fullfill: \f$ novel_ml(i,j)=original(features[i],val[j]) \f$. 236 /// 237 /// @return pointer to sub-Lookup of the MatrixLookupWeighted 238 /// 239 /// @note If underlying matrix goes out of scope or is deleted, the 240 /// returned pointer becomes invalid and the result of further use is 241 /// undefined. 242 /// 243 const MatrixLookupWeighted* 244 validation_data(const std::vector<size_t>& features, 245 const std::vector<size_t>& training, 246 const std::vector<size_t>& val) const; 214 247 215 248 /// -
Property
svn:eol-style
set to
-
trunk/c++_tools/classifier/NCC.cc
-
Property
svn:eol-style
set to
native
-
Property
svn:keywords
set to
Id
-
Property
svn:eol-style
set to
-
trunk/c++_tools/classifier/NCC.h
-
Property
svn:eol-style
set to
native
-
Property
svn:keywords
set to
Id
-
Property
svn:eol-style
set to
-
trunk/c++_tools/classifier/PolynomialKernelFunction.cc
-
Property
svn:keywords
changed from
Author Date Id Revision
toId
-
Property
svn:keywords
changed from
-
trunk/c++_tools/classifier/PolynomialKernelFunction.h
-
Property
svn:keywords
changed from
Author Date Id Revision
toId
-
Property
svn:keywords
changed from
-
trunk/c++_tools/classifier/SVM.cc
-
Property
svn:keywords
changed from
Author Date Id Revision
toId
-
Property
svn:keywords
changed from
-
trunk/c++_tools/classifier/SVM.h
-
Property
svn:keywords
changed from
Author Date Id Revision
toId
-
Property
svn:keywords
changed from
Note: See TracChangeset
for help on using the changeset viewer.