MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / scaleDataUsingTrainingRanges

Function scaleDataUsingTrainingRanges

src/openms/source/ANALYSIS/SVM/SimpleSVM.cpp:215–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

213}
214
215void scaleDataUsingTrainingRanges(SimpleSVM::PredictorMap& predictors, const map<String, pair<double, double>>& scaling)
216{
217 // scale each feature dimension to the min-max-range
218 for (auto pred_it = predictors.begin();
219 pred_it != predictors.end(); ++pred_it)
220 {
221 if (pred_it->second.empty()) continue; // uninformative predictor
222 auto val_begin = pred_it->second.begin();
223 auto val_end = pred_it->second.end();
224 for (; val_begin != val_end; ++val_begin)
225 {
226 if (scaling.count(pred_it->first) == 0)
227 {
228 //std::cout << "Predictor: '" << pred_it->first << "' not found in scale map because it was uninformative during training." << std::endl;
229 continue;
230 }
231 auto [min, max] = scaling.at(pred_it->first);
232 double range = max - min;
233 *val_begin = (*val_begin - min) / range;
234 }
235 }
236
237}
238
239// predict on novel e.g., test data
240void SimpleSVM::predict(PredictorMap& predictors, vector<Prediction>& predictions) const

Callers 1

predictMethod · 0.85

Calls 5

countMethod · 0.80
atMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected