From 0f8ebcff231189f0c0626d8644e008f47285d3ba Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Mon, 11 Jun 2018 16:42:13 +0200 Subject: [PATCH] Add evaluation method --- pywatts/main.py | 17 +++++++++++++++++ pywatts/neural.py | 5 ++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/pywatts/main.py b/pywatts/main.py index f687b9a..343654a 100644 --- a/pywatts/main.py +++ b/pywatts/main.py @@ -1,6 +1,8 @@ +import numpy as np import tensorflow as tf import matplotlib.pyplot as pp import pywatts.neural +from sklearn.metrics import explained_variance_score, mean_absolute_error, median_absolute_error from sklearn.model_selection import train_test_split @@ -33,3 +35,18 @@ def plot_training(evaluation): loss.append(e['loss']) pp.plot(loss) + +def predict(X_pred): + pred = n.predict1h(X_pred) + predictions = np.array([p['predictions'][0] for p in pred]) + return predictions + + +def eval_prediction(prediction): + print("The Explained Variance: %.2f" % explained_variance_score( + y_test, prediction)) + print("The Mean Absolute Error: %.2f volt dc" % mean_absolute_error( + y_test, prediction)) + print("The Median Absolute Error: %.2f volt dc" % median_absolute_error( + y_test, prediction)) + diff --git a/pywatts/neural.py b/pywatts/neural.py index acd6008..673adc9 100644 --- a/pywatts/neural.py +++ b/pywatts/neural.py @@ -24,6 +24,5 @@ class Net: def evaluate(self, eval_data, eval_results): return self.__regressor.evaluate(input_fn=pywatts_input_fn(eval_data, y=eval_results, num_epochs=1, shuffle=False), steps=1) - def predict1h(self, df): - df = df.drop(['month', 'day', 'hour']) - return self.__regressor.predict(input_fn=pywatts_input_fn(df, num_epochs=1, shuffle=False)) + def predict1h(self, predict_data): + return self.__regressor.predict(input_fn=pywatts_input_fn(predict_data, num_epochs=1, shuffle=False))