From 841690f98b2718c24ebc90ac4ead1ad2f4de1b42 Mon Sep 17 00:00:00 2001 From: reedts Date: Mon, 13 Aug 2018 14:31:39 +0200 Subject: [PATCH] Capping to zero --- pywatts/__init__.py | 2 +- pywatts/{main.py => routines.py} | 3 ++- pywatts/test_predict.py | 6 +++--- pywatts/test_predict24.py | 2 +- pywatts/test_train.py | 4 ++-- 5 files changed, 9 insertions(+), 8 deletions(-) rename pywatts/{main.py => routines.py} (95%) diff --git a/pywatts/__init__.py b/pywatts/__init__.py index 37f9f3a..f99e5ec 100644 --- a/pywatts/__init__.py +++ b/pywatts/__init__.py @@ -1,5 +1,5 @@ from pywatts import db from pywatts import fetchdata from pywatts import neural -from pywatts import main +from pywatts import routines from pywatts import kcross \ No newline at end of file diff --git a/pywatts/main.py b/pywatts/routines.py similarity index 95% rename from pywatts/main.py rename to pywatts/routines.py index 39950f0..0cdba19 100644 --- a/pywatts/main.py +++ b/pywatts/routines.py @@ -75,7 +75,8 @@ def predict24h(nn, X_pred): for i in range(24): pred = nn.predict1h(pandas.DataFrame.from_dict(input)) - predictions.extend(list([p['predictions'][0] for p in pred])) + # Cap prediction to 0 + predictions.extend(list([max(p['predictions'][0], 0) for p in pred])) # Remove first value and append predicted value del input['dc'][0] input['dc'].append(predictions[-1]) diff --git a/pywatts/test_predict.py b/pywatts/test_predict.py index 7b76a5c..bc125be 100644 --- a/pywatts/test_predict.py +++ b/pywatts/test_predict.py @@ -1,11 +1,11 @@ import tensorflow as tf import pywatts.db -from pywatts.main import * +from pywatts.routines import * PREDICT_QUERY = "query-sample_1hour.json" PREDICT_RESULT = PREDICT_QUERY.replace("query", "result") -QUERY_ID = 1 +QUERY_ID = 0 pred_query = input_query("../sample_data/" + PREDICT_QUERY, QUERY_ID) @@ -21,4 +21,4 @@ prediction = predict(n, pred_query) print(prediction) print(pred_result) -pywatts.main.eval_prediction(prediction, pred_result) +pywatts.routines.eval_prediction(prediction, pred_result) diff --git a/pywatts/test_predict24.py b/pywatts/test_predict24.py index af5ead7..05e2847 100644 --- a/pywatts/test_predict24.py +++ b/pywatts/test_predict24.py @@ -1,6 +1,6 @@ import tensorflow as tf import pywatts.db -from pywatts.main import * +from pywatts.routines import * import matplotlib.pyplot as pp diff --git a/pywatts/test_train.py b/pywatts/test_train.py index a378485..1aa52e3 100644 --- a/pywatts/test_train.py +++ b/pywatts/test_train.py @@ -1,7 +1,7 @@ import peewee import tensorflow as tf import pywatts.db -from pywatts.main import * +from pywatts.routines import * NUM_STATIONS_FROM_DB = 75 NUM_TRAIN_STATIONS = 400 @@ -43,7 +43,7 @@ if TRAIN: if PLOT: # Plot training success rate (with 'average loss') - pywatts.main.plot_training(train_eval) + pywatts.routines.plot_training(train_eval) exit()