From ee3b0a5decf9c23119441700e055e73d09b13a4c Mon Sep 17 00:00:00 2001 From: Martin Beseda <martin.beseda@vsb.cz> Date: Mon, 21 Jan 2019 17:47:49 +0100 Subject: [PATCH] ENH: added de_normalize() method to DataSet class. --- src/DataSet/DataSet.cpp | 19 +++++++++++++++++++ src/DataSet/DataSet.h | 5 +++++ 2 files changed, 24 insertions(+) diff --git a/src/DataSet/DataSet.cpp b/src/DataSet/DataSet.cpp index 214c9873..71b28846 100644 --- a/src/DataSet/DataSet.cpp +++ b/src/DataSet/DataSet.cpp @@ -351,6 +351,25 @@ namespace lib4neuro { } } + void DataSet::de_normalize() { + std::vector<double> tmp_inp(this->data.at(0).first.size()); + std::vector<double> tmp_out(this->data.at(0).second.size()); + + for(auto& pair: this->data) { + for(size_t i=0; i < pair.first.size(); i++) { + tmp_inp.at(i) = this->normalization_strategy->de_normalize(pair.first.at(i)); + } + pair.first = tmp_inp; + } + + for(auto& pair: this->data) { + for(size_t i=0; i < pair.second.size(); i++) { + tmp_out.at(i) = this->normalization_strategy->de_normalize(pair.second.at(i)); + } + pair.second = tmp_out; + } + } + void DataSet::de_normalize_single(std::vector<double> &d1, std::vector<double> &d2){ assert(d1.size() == d2.size()); for (size_t j = 0; j < d1.size(); ++j) { diff --git a/src/DataSet/DataSet.h b/src/DataSet/DataSet.h index 52ed4e74..7793b748 100644 --- a/src/DataSet/DataSet.h +++ b/src/DataSet/DataSet.h @@ -233,6 +233,11 @@ namespace lib4neuro { */ LIB4NEURO_API void normalize(); + /** + * Denormalizes the data set + */ + LIB4NEURO_API void de_normalize(); + /** * stores the de-normalized vector @d1 into @d2 * @param d1 -- GitLab