From 40a9f26d239fb828d8ab7ca2693b84997ed2ae93 Mon Sep 17 00:00:00 2001
From: Martin Beseda <martin.beseda@vsb.cz>
Date: Wed, 23 Jan 2019 13:58:34 +0100
Subject: [PATCH] ENH: Modified output from MSE evaluation functions

---
 src/ErrorFunction/ErrorFunctions.cpp | 48 +++++++++++++++-------------
 1 file changed, 25 insertions(+), 23 deletions(-)

diff --git a/src/ErrorFunction/ErrorFunctions.cpp b/src/ErrorFunction/ErrorFunctions.cpp
index 29d8fa34..59323bd8 100644
--- a/src/ErrorFunction/ErrorFunctions.cpp
+++ b/src/ErrorFunction/ErrorFunctions.cpp
@@ -105,7 +105,7 @@ namespace lib4neuro {
 
         size_t dim_in = data_set->get_input_dim();
         size_t dim_out = data_set->get_output_dim();
-        double error = 0.0, val, output_norm;
+        double error = 0.0, val, output_norm = 0;
 
         std::vector<std::pair<std::vector<double>, std::vector<double>>>* data = data_set->get_data();
         size_t n_elements = data->size();
@@ -168,20 +168,22 @@ namespace lib4neuro {
 
                 output_norm += denormalized_output * denormalized_output;
             }
+
 #ifdef L4N_DEBUG
-            COUT_DEBUG(i << ": "
-                         << ss_input.str() << " ; "
-                         << ss_real_output.str() << " ; "
-                         << ss_predicted_output.str() << "; "
-                         << std::sqrt(error) << "; "
-                         << 2 * std::sqrt(error) / (std::sqrt(error) + std::sqrt(output_norm)) <<
-                         std::endl);
-
-            *results_file_path << i << ": "
-                               << ss_input.str() << " ; "
-                               << ss_real_output.str() << " ; "
-                               << ss_predicted_output.str() << "; "
-                               << std::sqrt(error) << "; "
+            COUT_DEBUG("[" << i << "] "
+                           << ss_input.str() << " "
+                           << ss_real_output.str() << " "
+                           << ss_predicted_output.str() << " "
+                           << std::sqrt(error) << " "
+                           << 2 * std::sqrt(error) / (std::sqrt(error) + std::sqrt(output_norm))
+                           << std::endl);
+
+            *results_file_path << "["
+                               << i << "] "
+                               << ss_input.str() << " "
+                               << ss_real_output.str() << " "
+                               << ss_predicted_output.str() << " "
+                               << std::sqrt(error) << " "
                                << 2 * std::sqrt(error) / (std::sqrt(error) + std::sqrt(output_norm)) <<
                                std::endl;
 #endif
@@ -214,7 +216,7 @@ namespace lib4neuro {
             THROW_RUNTIME_ERROR("File path: " + results_file_path + " was not successfully opened!");
         }
 
-        ofs << "[Input] [Real output] [Predicted output]" << std::endl;
+        ofs << "[Index ][Input] [Real output] [Predicted output]" << std::endl;
 
         for (auto i = 0; i < data->size(); i++) {  // Iterate through every element in the test set
 
@@ -241,10 +243,10 @@ namespace lib4neuro {
                 } else {
                     denormalized_output = outputs.at(i).at(j);
                 }
-                COUT_DEBUG("Element " << i << ": "
-                                      << data->at(i).first.at(j) << " "
-                                      << data->at(i).second.at(j) << " "
-                                      << denormalized_output << std::endl);
+                COUT_DEBUG("[" << i << "] "
+                               << data->at(i).first.at(j) << " "
+                               << data->at(i).second.at(j) << " "
+                               << denormalized_output << std::endl);
 
                 ofs << data->at(i).first.at(j) << " "
                     << data->at(i).second.at(j) << " "
@@ -306,10 +308,10 @@ namespace lib4neuro {
                 } else {
                     denormalized_output = outputs.at(i).at(j);
                 }
-                COUT_DEBUG("Element " << i << ": "
-                                      << data->at(i).first.at(j) << " "
-                                      << data->at(i).second.at(j) << " "
-                                      << denormalized_output << std::endl);
+                COUT_DEBUG("[" << i << "] "
+                               << data->at(i).first.at(j) << " "
+                               << data->at(i).second.at(j) << " "
+                               << denormalized_output << std::endl);
 
                 val = denormalized_output - data->at(i).second.at(j);
                 error += val * val;
-- 
GitLab