From 2dfe5ef1b6eb54a3431610e997682dadeaf8fcc6 Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Tue, 7 Aug 2018 17:54:05 +0200 Subject: [PATCH 01/23] Fix kcross validation --- pywatts/kcross.py | 28 ++++++++++------------------ pywatts/test_kcross_train.py | 2 +- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/pywatts/kcross.py b/pywatts/kcross.py index f4174b9..dc80205 100644 --- a/pywatts/kcross.py +++ b/pywatts/kcross.py @@ -24,15 +24,8 @@ def split(data, k): bucketsize = int(len(samples) / k) - print(k) - print(len(data)) - print(len(samples)) - print(bucketsize) - # K steps for i in range(k): - eval_dict = [] - train_dict = [] eval_samples = [] train_samples = [] for j in range(k): @@ -41,19 +34,18 @@ def split(data, k): else: train_samples.extend(samples[i*bucketsize:(i+1)*bucketsize]) - for s in eval_samples: - # Create new dictionaries in the eval lists - X_eval.append({'dc': s[:-1]}) - y_eval.append({'dc': s[-1]}) + # Create new dictionaries in the eval lists + X_eval.append({'dc': eval_samples[:-1]}) + y_eval.append({'dc': eval_samples[-1]}) - for s in train_samples: - X_train.append({'dc': s[:-1]}) - y_train.append({'dc': s[-1]}) + X_train.append({'dc': train_samples[:-1]}) + y_train.append({'dc': train_samples[-1]}) - print(len(X_train) / 12) - #print(X_train) - #print(y_train) - exit(0) + print(len(X_eval)) + print(len(y_eval)) + + print(len(X_train)) + print(len(y_train)) return X_train, y_train, X_eval, y_eval diff --git a/pywatts/test_kcross_train.py b/pywatts/test_kcross_train.py index 807c0c4..6201fa2 100644 --- a/pywatts/test_kcross_train.py +++ b/pywatts/test_kcross_train.py @@ -25,7 +25,7 @@ n = pywatts.neural.Net(feature_cols=feature_col) (X_train, y_train, X_eval, y_eval) = kcross.split(df, K) -train_eval = {} +#train_eval = {} if TRAIN: # Train the model with the steps given From 288be08699d5a2837d5d6f214136a862585765c1 Mon Sep 17 00:00:00 2001 From: reedts Date: Thu, 9 Aug 2018 11:54:33 +0200 Subject: [PATCH 02/23] Fixed (?) kcross --- pywatts/db.py | 2 +- pywatts/kcross.py | 36 ++++++++++++++++++++++-------------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/pywatts/db.py b/pywatts/db.py index 37e1b66..234926c 100644 --- a/pywatts/db.py +++ b/pywatts/db.py @@ -6,7 +6,7 @@ from playhouse.sqlite_ext import SqliteExtDatabase import os.path BASE_DIR = os.path.dirname(os.path.abspath(__file__)) -db_path = os.path.join(BASE_DIR, "../pywatts.db") +db_path = os.path.join(BASE_DIR, "pywatts.db") print(db_path) db = SqliteExtDatabase(db_path) diff --git a/pywatts/kcross.py b/pywatts/kcross.py index dc80205..1b8d54d 100644 --- a/pywatts/kcross.py +++ b/pywatts/kcross.py @@ -30,22 +30,32 @@ def split(data, k): train_samples = [] for j in range(k): if j == i: - eval_samples.extend(samples[i*bucketsize:(i+1)*bucketsize]) + eval_samples.extend(samples[j*bucketsize:(j+1)*bucketsize]) else: - train_samples.extend(samples[i*bucketsize:(i+1)*bucketsize]) + train_samples.extend(samples[j*bucketsize:(j+1)*bucketsize]) # Create new dictionaries in the eval lists - X_eval.append({'dc': eval_samples[:-1]}) - y_eval.append({'dc': eval_samples[-1]}) + #X_eval.append({'dc': eval_samples[:-1]}) + #y_eval.append({'dc': eval_samples[-1]}) + X_eval.append({'dc': [x for s in eval_samples for c, x in enumerate(s, 1) if c % 337 != 0]}) + y_eval.append({'dc': [x for s in eval_samples for c, x in enumerate(s, 1) if c % 337 == 0]}) - X_train.append({'dc': train_samples[:-1]}) - y_train.append({'dc': train_samples[-1]}) + #X_train.append({'dc': train_samples[:-1]}) + #y_train.append({'dc': train_samples[-1]}) + X_train.append({'dc': [x for s in train_samples for c, x in enumerate(s, 1) if c % 337 != 0]}) + y_train.append({'dc': [x for s in train_samples for c, x in enumerate(s, 1) if c % 337 == 0]}) - print(len(X_eval)) - print(len(y_eval)) - - print(len(X_train)) - print(len(y_train)) + #print(len(X_eval)) + #print(len(y_eval)) + #print(len(X_train)) + #print(len(y_train)) + #print(len(X_train[0]['dc'])) + #print(len(y_train[0]['dc'])) + #print(len(X_eval[0]['dc'])) + #print(len(y_eval[0]['dc'])) + #print(X_train) + #print(y_train) + #exit(0) return X_train, y_train, X_eval, y_eval @@ -56,12 +66,10 @@ def train(nn, X_train, y_train, X_eval, y_eval, steps=10): for count, train_data in enumerate(X_train): for i in range(steps): nn.train(train_data, y_train[count], batch_size=int(len(train_data['dc'])/336), steps=1) - print(X_eval[count]) - print(len(X_eval[count]['dc'])) - print(y_eval[count]) evaluation.append(nn.evaluate(X_eval[count], y_eval[count], batch_size=int(len(X_eval[count]['dc'])/336))) print("Training %s: %s/%s" % (count, (i+1), steps)) + return evaluation From 0c07241104119acc29f12f0dd2b8b92b16724d13 Mon Sep 17 00:00:00 2001 From: reedts Date: Mon, 13 Aug 2018 10:02:50 +0200 Subject: [PATCH 03/23] Removed unnecessary lines --- pywatts/kcross.py | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/pywatts/kcross.py b/pywatts/kcross.py index 1b8d54d..9c3151d 100644 --- a/pywatts/kcross.py +++ b/pywatts/kcross.py @@ -35,28 +35,12 @@ def split(data, k): train_samples.extend(samples[j*bucketsize:(j+1)*bucketsize]) # Create new dictionaries in the eval lists - #X_eval.append({'dc': eval_samples[:-1]}) - #y_eval.append({'dc': eval_samples[-1]}) X_eval.append({'dc': [x for s in eval_samples for c, x in enumerate(s, 1) if c % 337 != 0]}) y_eval.append({'dc': [x for s in eval_samples for c, x in enumerate(s, 1) if c % 337 == 0]}) - #X_train.append({'dc': train_samples[:-1]}) - #y_train.append({'dc': train_samples[-1]}) X_train.append({'dc': [x for s in train_samples for c, x in enumerate(s, 1) if c % 337 != 0]}) y_train.append({'dc': [x for s in train_samples for c, x in enumerate(s, 1) if c % 337 == 0]}) - #print(len(X_eval)) - #print(len(y_eval)) - #print(len(X_train)) - #print(len(y_train)) - #print(len(X_train[0]['dc'])) - #print(len(y_train[0]['dc'])) - #print(len(X_eval[0]['dc'])) - #print(len(y_eval[0]['dc'])) - #print(X_train) - #print(y_train) - #exit(0) - return X_train, y_train, X_eval, y_eval From fd623c32de511cdde8ef27fc8e071631b8d4a158 Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Mon, 13 Aug 2018 12:38:22 +0200 Subject: [PATCH 04/23] Add tensorboard export script --- pywatts/board.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 pywatts/board.py diff --git a/pywatts/board.py b/pywatts/board.py new file mode 100644 index 0000000..bd951dc --- /dev/null +++ b/pywatts/board.py @@ -0,0 +1,11 @@ +import tensorflow as tf +import subprocess + +writer = tf.summary.FileWriter("tensorboard") +checkpoint = tf.train.get_checkpoint_state('tf_pywatts_model') +with tf.Session() as sess: + saver = tf.train.import_meta_graph(checkpoint.model_checkpoint_path + '.meta') + saver.restore(sess, checkpoint.model_checkpoint_path) +writer.add_graph(sess.graph) + +subprocess.check_output(['tensorboard', '--logdir', 'tensorboard']) \ No newline at end of file From 0e228772dc0bf528d44da4f78645e90d9fa9dc4b Mon Sep 17 00:00:00 2001 From: reedts Date: Mon, 13 Aug 2018 14:19:39 +0200 Subject: [PATCH 05/23] Added 24 hour prediction --- pywatts/main.py | 16 ++++++++++++++++ pywatts/neural.py | 8 ++++---- pywatts/test_predict24.py | 29 +++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 pywatts/test_predict24.py diff --git a/pywatts/main.py b/pywatts/main.py index 414f87d..39950f0 100644 --- a/pywatts/main.py +++ b/pywatts/main.py @@ -68,6 +68,22 @@ def predict(nn, X_pred): return predictions +def predict24h(nn, X_pred): + predictions = [] + + input = {'dc': X_pred['dc'].tolist()} + + for i in range(24): + pred = nn.predict1h(pandas.DataFrame.from_dict(input)) + predictions.extend(list([p['predictions'][0] for p in pred])) + # Remove first value and append predicted value + del input['dc'][0] + input['dc'].append(predictions[-1]) + print(input) + + return predictions + + def eval_prediction(prediction, result): print("The Explained Variance: %.2f" % explained_variance_score( result, prediction)) diff --git a/pywatts/neural.py b/pywatts/neural.py index bbe0b93..4180366 100644 --- a/pywatts/neural.py +++ b/pywatts/neural.py @@ -6,7 +6,6 @@ import tensorflow as tf def pywatts_input_fn(X, y=None, num_epochs=None, shuffle=True, batch_size=1): # Create dictionary for features in hour 0 ... 335 features = {str(idx): [] for idx in range(336)} - #dc_values = X['dc'].tolist() dc_values = X['dc'] # Iterate the empty dictionary always adding the idx-th element from the dc_values list @@ -15,7 +14,6 @@ def pywatts_input_fn(X, y=None, num_epochs=None, shuffle=True, batch_size=1): labels = None if y is not None: - #labels = y['dc'].values labels = y['dc'] if labels is None: @@ -24,9 +22,11 @@ def pywatts_input_fn(X, y=None, num_epochs=None, shuffle=True, batch_size=1): dataset = tf.data.Dataset.from_tensor_slices((dict(features), labels)) if shuffle: - dataset.shuffle(len(features['0'])) + dataset.shuffle(len(features['0']*len(features)*4)) - return dataset.batch(batch_size) + return dataset.repeat().batch(batch_size) + else: + return dataset.batch(batch_size) class Net: diff --git a/pywatts/test_predict24.py b/pywatts/test_predict24.py new file mode 100644 index 0000000..af5ead7 --- /dev/null +++ b/pywatts/test_predict24.py @@ -0,0 +1,29 @@ +import tensorflow as tf +import pywatts.db +from pywatts.main import * +import matplotlib.pyplot as pp + + +PREDICT_QUERY = "query-sample_24hour.json" +PREDICT_RESULT = PREDICT_QUERY.replace("query", "result") +QUERY_ID = 0 + + +pred_query = input_query("../sample_data/" + PREDICT_QUERY, QUERY_ID) +pred_result = input_result("../sample_data/" + PREDICT_RESULT, QUERY_ID) + + +# Define feature columns and initialize Regressor +feature_col = [tf.feature_column.numeric_column(str(idx)) for idx in range(336)] +n = pywatts.neural.Net(feature_cols=feature_col) + +prediction = predict24h(n, pred_query) + +print(prediction) +print(pred_result) + +pp.plot(pred_result, 'black') +pp.plot(prediction, 'red') +pp.show() + +#pywatts.main.eval_prediction(prediction, pred_result) From ba0c7bc2ead50337e7ad5120d1bae66aaa422ede Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Mon, 13 Aug 2018 14:20:38 +0200 Subject: [PATCH 06/23] Add tensorboard to gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index e8cca63..82ed5e9 100644 --- a/.gitignore +++ b/.gitignore @@ -111,3 +111,6 @@ venv.bak/ # Tensorflow Model tf_pywatts_model/ + +# Tensorboard +pywatts/tensorboard From 841690f98b2718c24ebc90ac4ead1ad2f4de1b42 Mon Sep 17 00:00:00 2001 From: reedts Date: Mon, 13 Aug 2018 14:31:39 +0200 Subject: [PATCH 07/23] 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() From 68e9b9ddd0add8a37ca9f8adb7a127e893085fa1 Mon Sep 17 00:00:00 2001 From: reedts Date: Mon, 13 Aug 2018 14:42:31 +0200 Subject: [PATCH 08/23] Cap all prediction values to zero --- pywatts/routines.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pywatts/routines.py b/pywatts/routines.py index 0cdba19..cf4d80e 100644 --- a/pywatts/routines.py +++ b/pywatts/routines.py @@ -64,7 +64,8 @@ def plot_training(evaluation): def predict(nn, X_pred): pred = nn.predict1h(X_pred) - predictions = np.array([p['predictions'] for p in pred]) + # Cap results to 0 + predictions = np.array([max(p['predictions'], 0) for p in pred]) return predictions @@ -80,7 +81,7 @@ def predict24h(nn, X_pred): # Remove first value and append predicted value del input['dc'][0] input['dc'].append(predictions[-1]) - print(input) + print("Prediction for hour %d/%d" % (i+1, 24)) return predictions From 0eef892e0cac00dc3c46181517ceab073e61b7c2 Mon Sep 17 00:00:00 2001 From: reedts Date: Mon, 13 Aug 2018 14:43:19 +0200 Subject: [PATCH 09/23] Removed unnecessary line --- pywatts/test_predict24.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pywatts/test_predict24.py b/pywatts/test_predict24.py index 05e2847..c931f3a 100644 --- a/pywatts/test_predict24.py +++ b/pywatts/test_predict24.py @@ -25,5 +25,3 @@ print(pred_result) pp.plot(pred_result, 'black') pp.plot(prediction, 'red') pp.show() - -#pywatts.main.eval_prediction(prediction, pred_result) From d4da4ca121f8763907fc4bdba6fd4b07e0f424fe Mon Sep 17 00:00:00 2001 From: reedts Date: Mon, 13 Aug 2018 16:35:03 +0200 Subject: [PATCH 10/23] Add eval_training script --- pywatts/eval_training.py | 68 +++++++++++++++++++++++++++++++++++++++ pywatts/test_predict24.py | 2 +- 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 pywatts/eval_training.py diff --git a/pywatts/eval_training.py b/pywatts/eval_training.py new file mode 100644 index 0000000..22ddd42 --- /dev/null +++ b/pywatts/eval_training.py @@ -0,0 +1,68 @@ +import tensorflow as tf +import pywatts.db +from pywatts.routines import * +from pywatts import kcross + +NUM_STATIONS_FROM_DB = 75 +K = 2 +NUM_EVAL_STATIONS = 40 +TRAIN = True +PLOT = True +TRAIN_STEPS = 1 +TOTAL_STEPS = 2 +NUM_QUERIES = 1 +PREDICT_QUERY = "query-sample_24hour.json" +PREDICT_RESULT = PREDICT_QUERY.replace("query", "result") +FIGURE_OUTPUT_DIR = "../figures/" + + +df = pywatts.db.rows_to_df(list(range(1, NUM_STATIONS_FROM_DB))) +X = df +y = df['dc'] + + +# Define feature columns and initialize Regressor +feature_col = [tf.feature_column.numeric_column(str(idx)) for idx in range(336)] +n = pywatts.neural.Net(feature_cols=feature_col) + + +# Training data +(X_train, y_train, X_eval, y_eval) = kcross.split(df, K) + + +if TRAIN: + + train_eval = None + + color_gradient_base = (0.5, 0, 0) + color_step_width = (0.5/TOTAL_STEPS, 0, 0) + + for i in range(TOTAL_STEPS): + # Train the model with the steps given + train_eval = kcross.train(n, X_train, y_train, X_eval, y_eval, TRAIN_STEPS) + + for q in range(NUM_QUERIES): + + pred_query = input_query("../sample_data/" + PREDICT_QUERY, q) + pred_result = input_result("../sample_data/" + PREDICT_RESULT, q) + + prediction = predict24h(n, pred_query) + + pp.figure(q) + + if i == 0: + pp.plot(pred_result, 'black') + + pp.plot(prediction, color=color_gradient_base) + + color_gradient_base = tuple([sum(x) for x in zip(color_gradient_base, color_step_width)]) + + for i in range(NUM_QUERIES): + pp.figure(i) + pp.savefig(FIGURE_OUTPUT_DIR+'{}.pdf'.format(i), orientation='landscape') + + if PLOT: + # Plot training success rate (with 'average loss') + pywatts.routines.plot_training(train_eval) + +exit() diff --git a/pywatts/test_predict24.py b/pywatts/test_predict24.py index c931f3a..42700af 100644 --- a/pywatts/test_predict24.py +++ b/pywatts/test_predict24.py @@ -6,7 +6,7 @@ import matplotlib.pyplot as pp PREDICT_QUERY = "query-sample_24hour.json" PREDICT_RESULT = PREDICT_QUERY.replace("query", "result") -QUERY_ID = 0 +QUERY_ID = 4 pred_query = input_query("../sample_data/" + PREDICT_QUERY, QUERY_ID) From 525298f76114990fec3b395de0311ad4976f3a38 Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Mon, 13 Aug 2018 17:17:37 +0200 Subject: [PATCH 11/23] Fix reference to old main class --- pywatts/test_kcross_train.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pywatts/test_kcross_train.py b/pywatts/test_kcross_train.py index 6201fa2..4e29d0a 100644 --- a/pywatts/test_kcross_train.py +++ b/pywatts/test_kcross_train.py @@ -35,7 +35,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() From 173d5762bc461f7396b5e256ceb37c8053da194f Mon Sep 17 00:00:00 2001 From: reedts Date: Mon, 13 Aug 2018 18:54:34 +0200 Subject: [PATCH 12/23] Fix multiple graphs and plot while evaluating --- pywatts/eval_training.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pywatts/eval_training.py b/pywatts/eval_training.py index 22ddd42..ab95090 100644 --- a/pywatts/eval_training.py +++ b/pywatts/eval_training.py @@ -54,15 +54,21 @@ if TRAIN: pp.plot(pred_result, 'black') pp.plot(prediction, color=color_gradient_base) + pp.savefig(FIGURE_OUTPUT_DIR+'{}.pdf'.format(q), orientation='landscape') color_gradient_base = tuple([sum(x) for x in zip(color_gradient_base, color_step_width)]) for i in range(NUM_QUERIES): - pp.figure(i) - pp.savefig(FIGURE_OUTPUT_DIR+'{}.pdf'.format(i), orientation='landscape') + pp.close(i) if PLOT: # Plot training success rate (with 'average loss') - pywatts.routines.plot_training(train_eval) + loss = [] + for e in train_eval: + loss.append(e['average_loss']) + + pp.plot(loss) + # Needed for execution in PyCharm + pp.show() exit() From e97ba96dd4a6228769e4ca5e81022f4fee87d0e9 Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Mon, 13 Aug 2018 18:57:16 +0200 Subject: [PATCH 13/23] Add figures folder to gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 82ed5e9..aa22a7f 100644 --- a/.gitignore +++ b/.gitignore @@ -114,3 +114,6 @@ tf_pywatts_model/ # Tensorboard pywatts/tensorboard + +# Figures +figures/ From e019f1bee71ac36571e70dc16d705c72b5f8502d Mon Sep 17 00:00:00 2001 From: reedts Date: Tue, 14 Aug 2018 15:21:39 +0200 Subject: [PATCH 14/23] Fixed shuffling --- pywatts/neural.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pywatts/neural.py b/pywatts/neural.py index 4180366..aa377db 100644 --- a/pywatts/neural.py +++ b/pywatts/neural.py @@ -22,9 +22,7 @@ def pywatts_input_fn(X, y=None, num_epochs=None, shuffle=True, batch_size=1): dataset = tf.data.Dataset.from_tensor_slices((dict(features), labels)) if shuffle: - dataset.shuffle(len(features['0']*len(features)*4)) - - return dataset.repeat().batch(batch_size) + return dataset.shuffle(len(features['0']*batch_size*4)).repeat().batch(batch_size) else: return dataset.batch(batch_size) @@ -35,7 +33,7 @@ class Net: def __init__(self, feature_cols=__feature_cols): self.__regressor = tf.estimator.DNNRegressor(feature_columns=feature_cols, - hidden_units=[75, 75], + hidden_units=[64, 128, 64], model_dir='tf_pywatts_model') def train(self, training_data, training_results, batch_size, steps): From 51d0e9cea847610c5214dabdcbc8a6a23be10968 Mon Sep 17 00:00:00 2001 From: reedts Date: Tue, 14 Aug 2018 22:20:40 +0200 Subject: [PATCH 15/23] Added new test configuration --- pywatts/kcross.py | 4 ++-- pywatts/neural.py | 2 +- pywatts/test_kcross_train.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pywatts/kcross.py b/pywatts/kcross.py index 9c3151d..29a7bde 100644 --- a/pywatts/kcross.py +++ b/pywatts/kcross.py @@ -18,7 +18,7 @@ def split(data, k): data_list = data['dc'].tolist() # Each sample has 337 elements - samples = [data_list[i:i+337] for i in range(0, len(data_list) - 337, 337)] + samples = [data_list[i:i+337] for i in range(0, len(data_list) - 337, 20)] # Randomly shuffle samples random.shuffle(samples) @@ -49,7 +49,7 @@ def train(nn, X_train, y_train, X_eval, y_eval, steps=10): evaluation = [] for count, train_data in enumerate(X_train): for i in range(steps): - nn.train(train_data, y_train[count], batch_size=int(len(train_data['dc'])/336), steps=1) + nn.train(train_data, y_train[count], batch_size=30, steps=100) #batch_size=int(len(train_data['dc'])/336), steps=1) evaluation.append(nn.evaluate(X_eval[count], y_eval[count], batch_size=int(len(X_eval[count]['dc'])/336))) print("Training %s: %s/%s" % (count, (i+1), steps)) diff --git a/pywatts/neural.py b/pywatts/neural.py index aa377db..66dc16c 100644 --- a/pywatts/neural.py +++ b/pywatts/neural.py @@ -22,7 +22,7 @@ def pywatts_input_fn(X, y=None, num_epochs=None, shuffle=True, batch_size=1): dataset = tf.data.Dataset.from_tensor_slices((dict(features), labels)) if shuffle: - return dataset.shuffle(len(features['0']*batch_size*4)).repeat().batch(batch_size) + return dataset.shuffle(len(features['0']*len(features)*4)).repeat().batch(batch_size) else: return dataset.batch(batch_size) diff --git a/pywatts/test_kcross_train.py b/pywatts/test_kcross_train.py index 4e29d0a..14550b1 100644 --- a/pywatts/test_kcross_train.py +++ b/pywatts/test_kcross_train.py @@ -4,11 +4,11 @@ import pywatts.db from pywatts import kcross NUM_STATIONS_FROM_DB = 75 -K = 4 +K = 10 NUM_EVAL_STATIONS = 40 TRAIN = True PLOT = True -TRAIN_STEPS = 4 +TRAIN_STEPS = 20 df = pywatts.db.rows_to_df(list(range(1, NUM_STATIONS_FROM_DB))) From c6261134c984c60ff71f325997a5bb72764fa600 Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Sun, 9 Sep 2018 17:25:43 +0200 Subject: [PATCH 16/23] Add prediction script --- pywatts/db.py | 1 - pywatts/kcross.py | 4 +--- pywatts/neural.py | 2 -- pywatts/predict_for_json.py | 30 ++++++++++++++++++++++++++++++ pywatts/routines.py | 20 +++++++++++++++++++- pywatts/test_kcross_train.py | 2 +- pywatts/test_train.py | 2 +- 7 files changed, 52 insertions(+), 9 deletions(-) create mode 100644 pywatts/predict_for_json.py diff --git a/pywatts/db.py b/pywatts/db.py index 234926c..88af8f7 100644 --- a/pywatts/db.py +++ b/pywatts/db.py @@ -7,7 +7,6 @@ import os.path BASE_DIR = os.path.dirname(os.path.abspath(__file__)) db_path = os.path.join(BASE_DIR, "pywatts.db") -print(db_path) db = SqliteExtDatabase(db_path) diff --git a/pywatts/kcross.py b/pywatts/kcross.py index 9c3151d..435390b 100644 --- a/pywatts/kcross.py +++ b/pywatts/kcross.py @@ -1,6 +1,4 @@ import random -import itertools -from pywatts import db def split(data, k): @@ -18,7 +16,7 @@ def split(data, k): data_list = data['dc'].tolist() # Each sample has 337 elements - samples = [data_list[i:i+337] for i in range(0, len(data_list) - 337, 337)] + samples = [data_list[i:i+337] for i in range(0, len(data_list) - 337)] # Randomly shuffle samples random.shuffle(samples) diff --git a/pywatts/neural.py b/pywatts/neural.py index 4180366..f675d17 100644 --- a/pywatts/neural.py +++ b/pywatts/neural.py @@ -1,5 +1,3 @@ -import pandas -import numpy as np import tensorflow as tf diff --git a/pywatts/predict_for_json.py b/pywatts/predict_for_json.py new file mode 100644 index 0000000..98f666f --- /dev/null +++ b/pywatts/predict_for_json.py @@ -0,0 +1,30 @@ +import os +import sys + +import tensorflow as tf + +import pywatts.db +from pywatts.routines import * + +# get rid of TF debug message +os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' + +if len(sys.argv) != 3: + print("Usage: python predict_for_json.py 24h|1h ") + exit(1) + +type = sys.argv[1] # '1h' or '24h' +json_file = sys.argv[2] # json file + +queries = input_queries(json_file) + +feature_col = [tf.feature_column.numeric_column(str(idx)) for idx in range(336)] +n = pywatts.neural.Net(feature_cols=feature_col) + +predictions = [] +for query in queries: + if type == '1h': + predictions.extend(predict(n, query).astype('Float64').tolist()) + else: + predictions.append(predict24h(n, query)) +print(predictions) diff --git a/pywatts/routines.py b/pywatts/routines.py index cf4d80e..e676ba0 100644 --- a/pywatts/routines.py +++ b/pywatts/routines.py @@ -36,6 +36,18 @@ def input_query(json_str, idx=0): 'wind': tmp_df['wind'][idx]} ) +def input_queries(json_str): + tmp_df = pandas.read_json(json_str) + + queries = [] + for i in range(len(tmp_df)): + queries.append(pandas.DataFrame.from_dict( + {'dc': tmp_df['dc'][i], + 'temp': tmp_df['temp'][i], + 'wind': tmp_df['wind'][i]} + )) + return queries + def input_result(json_str, idx=0): tmp_df = pandas.read_json(json_str) @@ -81,7 +93,7 @@ def predict24h(nn, X_pred): # Remove first value and append predicted value del input['dc'][0] input['dc'].append(predictions[-1]) - print("Prediction for hour %d/%d" % (i+1, 24)) + # print("Prediction for hour %d/%d" % (i+1, 24)) return predictions @@ -94,3 +106,9 @@ def eval_prediction(prediction, result): print("The Median Absolute Error: %.2f volt dc" % median_absolute_error( result, prediction)) +def jsonify(predictions): + json_out = "[" + for v in predictions: + json_out += "[" + str(v) + "]," + json_out = json_out[:-1] + "]" + return json_out diff --git a/pywatts/test_kcross_train.py b/pywatts/test_kcross_train.py index 4e29d0a..d88e070 100644 --- a/pywatts/test_kcross_train.py +++ b/pywatts/test_kcross_train.py @@ -1,5 +1,5 @@ -import peewee import tensorflow as tf + import pywatts.db from pywatts import kcross diff --git a/pywatts/test_train.py b/pywatts/test_train.py index 1aa52e3..09f814a 100644 --- a/pywatts/test_train.py +++ b/pywatts/test_train.py @@ -1,5 +1,5 @@ -import peewee import tensorflow as tf + import pywatts.db from pywatts.routines import * From f5735fa2f1ed31111fc81a1507b74e1e0518db4f Mon Sep 17 00:00:00 2001 From: reedts Date: Mon, 10 Sep 2018 19:44:42 +0200 Subject: [PATCH 17/23] Minor fixes --- pywatts/board.py | 2 +- pywatts/kcross.py | 8 ++++---- pywatts/neural.py | 5 ++++- pywatts/routines.py | 6 ++++-- pywatts/test_kcross_train.py | 2 +- pywatts/test_predict24.py | 2 +- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/pywatts/board.py b/pywatts/board.py index bd951dc..dadb303 100644 --- a/pywatts/board.py +++ b/pywatts/board.py @@ -2,7 +2,7 @@ import tensorflow as tf import subprocess writer = tf.summary.FileWriter("tensorboard") -checkpoint = tf.train.get_checkpoint_state('tf_pywatts_model') +checkpoint = tf.train.get_checkpoint_state('tf_pywatts_model_best') with tf.Session() as sess: saver = tf.train.import_meta_graph(checkpoint.model_checkpoint_path + '.meta') saver.restore(sess, checkpoint.model_checkpoint_path) diff --git a/pywatts/kcross.py b/pywatts/kcross.py index 6489c37..ed05c79 100644 --- a/pywatts/kcross.py +++ b/pywatts/kcross.py @@ -16,7 +16,7 @@ def split(data, k): data_list = data['dc'].tolist() # Each sample has 337 elements - samples = [data_list[i:i+337] for i in range(0, len(data_list) - 337, 20)] + samples = [data_list[i:i+337] for i in range(0, len(data_list) - 337, 30)] # Randomly shuffle samples random.shuffle(samples) @@ -42,13 +42,13 @@ def split(data, k): return X_train, y_train, X_eval, y_eval -def train(nn, X_train, y_train, X_eval, y_eval, steps=10): +def train(nn, X_train, y_train, X_eval, y_eval, steps=100): """Trains the Network nn using k-cross-validation""" evaluation = [] for count, train_data in enumerate(X_train): for i in range(steps): - nn.train(train_data, y_train[count], batch_size=30, steps=100) #batch_size=int(len(train_data['dc'])/336), steps=1) - evaluation.append(nn.evaluate(X_eval[count], y_eval[count], batch_size=int(len(X_eval[count]['dc'])/336))) + nn.train(train_data, y_train[count], batch_size=1000, steps=30) #batch_size=int(len(train_data['dc'])/336), steps=1) + evaluation.append(nn.evaluate(X_eval[count], y_eval[count])) print("Training %s: %s/%s" % (count, (i+1), steps)) return evaluation diff --git a/pywatts/neural.py b/pywatts/neural.py index bed842e..1304b8f 100644 --- a/pywatts/neural.py +++ b/pywatts/neural.py @@ -19,6 +19,9 @@ def pywatts_input_fn(X, y=None, num_epochs=None, shuffle=True, batch_size=1): else: dataset = tf.data.Dataset.from_tensor_slices((dict(features), labels)) + if num_epochs is not None: + return dataset.batch(len(features['0'])) + if shuffle: return dataset.shuffle(len(features['0']*len(features)*4)).repeat().batch(batch_size) else: @@ -31,7 +34,7 @@ class Net: def __init__(self, feature_cols=__feature_cols): self.__regressor = tf.estimator.DNNRegressor(feature_columns=feature_cols, - hidden_units=[64, 128, 64], + hidden_units=[128, 512, 128], model_dir='tf_pywatts_model') def train(self, training_data, training_results, batch_size, steps): diff --git a/pywatts/routines.py b/pywatts/routines.py index e676ba0..bf3919f 100644 --- a/pywatts/routines.py +++ b/pywatts/routines.py @@ -66,10 +66,12 @@ def train(nn, X_train, y_train, X_val, y_val, steps=100): def plot_training(evaluation): loss = [] + steps = [] for e in evaluation: - loss.append(e['average_loss']) + loss.append(e['loss']) + steps.append(e['global_step']) - pp.plot(loss) + pp.plot(steps, loss) # Needed for execution in PyCharm pp.show() diff --git a/pywatts/test_kcross_train.py b/pywatts/test_kcross_train.py index 8a2b848..d67db36 100644 --- a/pywatts/test_kcross_train.py +++ b/pywatts/test_kcross_train.py @@ -8,7 +8,7 @@ K = 10 NUM_EVAL_STATIONS = 40 TRAIN = True PLOT = True -TRAIN_STEPS = 20 +TRAIN_STEPS = 10 df = pywatts.db.rows_to_df(list(range(1, NUM_STATIONS_FROM_DB))) diff --git a/pywatts/test_predict24.py b/pywatts/test_predict24.py index 42700af..c931f3a 100644 --- a/pywatts/test_predict24.py +++ b/pywatts/test_predict24.py @@ -6,7 +6,7 @@ import matplotlib.pyplot as pp PREDICT_QUERY = "query-sample_24hour.json" PREDICT_RESULT = PREDICT_QUERY.replace("query", "result") -QUERY_ID = 4 +QUERY_ID = 0 pred_query = input_query("../sample_data/" + PREDICT_QUERY, QUERY_ID) From f668ceaf6a0200ae07e784c62d55ae4b3e89f8db Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Tue, 11 Sep 2018 14:41:52 +0200 Subject: [PATCH 18/23] Rename and fix script --- .../{predict_for_json.py => photovoltaic_gruppe1.py} | 11 +++++------ pywatts/routines.py | 8 +++++++- 2 files changed, 12 insertions(+), 7 deletions(-) rename pywatts/{predict_for_json.py => photovoltaic_gruppe1.py} (69%) diff --git a/pywatts/predict_for_json.py b/pywatts/photovoltaic_gruppe1.py similarity index 69% rename from pywatts/predict_for_json.py rename to pywatts/photovoltaic_gruppe1.py index 98f666f..3889f6c 100644 --- a/pywatts/predict_for_json.py +++ b/pywatts/photovoltaic_gruppe1.py @@ -9,21 +9,20 @@ from pywatts.routines import * # get rid of TF debug message os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' -if len(sys.argv) != 3: - print("Usage: python predict_for_json.py 24h|1h ") +if len(sys.argv) != 2: + print("Usage: python photovoltaic_gruppe1.py ") exit(1) -type = sys.argv[1] # '1h' or '24h' -json_file = sys.argv[2] # json file +json_file = sys.argv[1] # json file -queries = input_queries(json_file) +oneH, queries = input_queries(json_file) feature_col = [tf.feature_column.numeric_column(str(idx)) for idx in range(336)] n = pywatts.neural.Net(feature_cols=feature_col) predictions = [] for query in queries: - if type == '1h': + if oneH: predictions.extend(predict(n, query).astype('Float64').tolist()) else: predictions.append(predict24h(n, query)) diff --git a/pywatts/routines.py b/pywatts/routines.py index bf3919f..54e3beb 100644 --- a/pywatts/routines.py +++ b/pywatts/routines.py @@ -39,6 +39,12 @@ def input_query(json_str, idx=0): def input_queries(json_str): tmp_df = pandas.read_json(json_str) + oneH = False + try: + s = tmp_df['max_temp'][0] + except KeyError: + oneH = True + queries = [] for i in range(len(tmp_df)): queries.append(pandas.DataFrame.from_dict( @@ -46,7 +52,7 @@ def input_queries(json_str): 'temp': tmp_df['temp'][i], 'wind': tmp_df['wind'][i]} )) - return queries + return oneH, queries def input_result(json_str, idx=0): From 70edcea2ca5e7ed919cd1579416dea9cc8af3611 Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Wed, 12 Sep 2018 17:52:05 +0200 Subject: [PATCH 19/23] Rubix changes --- pywatts/db.py | 9 +-------- pywatts/eval_training.py | 8 ++++---- pywatts/neural.py | 4 ++-- ...ovoltaic_gruppe1.py => photovoltaic_gruppe4.py} | 2 +- pywatts/routines.py | 14 ++++---------- 5 files changed, 12 insertions(+), 25 deletions(-) rename pywatts/{photovoltaic_gruppe1.py => photovoltaic_gruppe4.py} (90%) diff --git a/pywatts/db.py b/pywatts/db.py index 88af8f7..b877125 100644 --- a/pywatts/db.py +++ b/pywatts/db.py @@ -34,21 +34,14 @@ class Result(Model): def rows_to_df(indices): - temps = [] dcs = [] - winds = [] db.connect() for result in Result.select().where(Result.id << indices): - temps += result.temperature dcs += result.dc_output - winds += result.wind_speed db.close() return pd.DataFrame( - {'temp': temps, - 'dc': dcs, - 'wind': winds - }) + {'dc': dcs}) diff --git a/pywatts/eval_training.py b/pywatts/eval_training.py index ab95090..439b3bf 100644 --- a/pywatts/eval_training.py +++ b/pywatts/eval_training.py @@ -4,13 +4,13 @@ from pywatts.routines import * from pywatts import kcross NUM_STATIONS_FROM_DB = 75 -K = 2 +K = 10 NUM_EVAL_STATIONS = 40 TRAIN = True PLOT = True -TRAIN_STEPS = 1 -TOTAL_STEPS = 2 -NUM_QUERIES = 1 +TRAIN_STEPS = 10 +TOTAL_STEPS = 6 +NUM_QUERIES = 5 PREDICT_QUERY = "query-sample_24hour.json" PREDICT_RESULT = PREDICT_QUERY.replace("query", "result") FIGURE_OUTPUT_DIR = "../figures/" diff --git a/pywatts/neural.py b/pywatts/neural.py index 1304b8f..e6e42b3 100644 --- a/pywatts/neural.py +++ b/pywatts/neural.py @@ -30,11 +30,11 @@ def pywatts_input_fn(X, y=None, num_epochs=None, shuffle=True, batch_size=1): class Net: __regressor = None - __feature_cols = [tf.feature_column.numeric_column(col) for col in ['dc', 'temp', 'wind']] + __feature_cols = [tf.feature_column.numeric_column(col) for col in ['dc']] def __init__(self, feature_cols=__feature_cols): self.__regressor = tf.estimator.DNNRegressor(feature_columns=feature_cols, - hidden_units=[128, 512, 128], + hidden_units=[64, 128, 64], model_dir='tf_pywatts_model') def train(self, training_data, training_results, batch_size, steps): diff --git a/pywatts/photovoltaic_gruppe1.py b/pywatts/photovoltaic_gruppe4.py similarity index 90% rename from pywatts/photovoltaic_gruppe1.py rename to pywatts/photovoltaic_gruppe4.py index 3889f6c..2378d7c 100644 --- a/pywatts/photovoltaic_gruppe1.py +++ b/pywatts/photovoltaic_gruppe4.py @@ -10,7 +10,7 @@ from pywatts.routines import * os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' if len(sys.argv) != 2: - print("Usage: python photovoltaic_gruppe1.py ") + print("Usage: python photovoltaic_gruppe4.py ") exit(1) json_file = sys.argv[1] # json file diff --git a/pywatts/routines.py b/pywatts/routines.py index 54e3beb..e500cd7 100644 --- a/pywatts/routines.py +++ b/pywatts/routines.py @@ -9,7 +9,7 @@ from random import randint def train_split(data, size): used_idxs = [] - X_values = {'dc': [], 'temp': [], 'wind': []} + X_values = {'dc': []} y_values = [] for i in range(size): rnd_idx = randint(0, data.size / data.shape[1] - 337) @@ -20,8 +20,6 @@ def train_split(data, size): used_idxs.append(rnd_idx) X_values['dc'].extend(data['dc'][rnd_idx:rnd_idx + 336].tolist()) - X_values['temp'].extend(data['temp'][rnd_idx:rnd_idx + 336].tolist()) - X_values['wind'].extend(data['wind'][rnd_idx:rnd_idx + 336].tolist()) y_values.append(data['dc'][rnd_idx + 337].tolist()) return pandas.DataFrame.from_dict(X_values), pandas.DataFrame.from_dict({'dc': y_values}) @@ -31,9 +29,7 @@ def input_query(json_str, idx=0): tmp_df = pandas.read_json(json_str) return pandas.DataFrame.from_dict( - {'dc': tmp_df['dc'][idx], - 'temp': tmp_df['temp'][idx], - 'wind': tmp_df['wind'][idx]} + {'dc': tmp_df['dc'][idx]} ) def input_queries(json_str): @@ -48,9 +44,7 @@ def input_queries(json_str): queries = [] for i in range(len(tmp_df)): queries.append(pandas.DataFrame.from_dict( - {'dc': tmp_df['dc'][i], - 'temp': tmp_df['temp'][i], - 'wind': tmp_df['wind'][i]} + {'dc': tmp_df['dc'][i]} )) return oneH, queries @@ -85,7 +79,7 @@ def plot_training(evaluation): def predict(nn, X_pred): pred = nn.predict1h(X_pred) # Cap results to 0 - predictions = np.array([max(p['predictions'], 0) for p in pred]) + predictions = np.array([max(p['predictions'], [0]) for p in pred]) return predictions From ed68d78d98b6a114cee88aac7b3ee284b0b9c98a Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Thu, 13 Sep 2018 11:28:17 +0200 Subject: [PATCH 20/23] Script output --- pywatts/photovoltaic_gruppe4.py => photovoltaic_gruppe4.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename pywatts/photovoltaic_gruppe4.py => photovoltaic_gruppe4.py (91%) diff --git a/pywatts/photovoltaic_gruppe4.py b/photovoltaic_gruppe4.py similarity index 91% rename from pywatts/photovoltaic_gruppe4.py rename to photovoltaic_gruppe4.py index 2378d7c..1285faf 100644 --- a/pywatts/photovoltaic_gruppe4.py +++ b/photovoltaic_gruppe4.py @@ -26,4 +26,4 @@ for query in queries: predictions.extend(predict(n, query).astype('Float64').tolist()) else: predictions.append(predict24h(n, query)) -print(predictions) +print(predictions, file=open("test_data_gruppe4.json", "w")) From 615428944ad1057a3b814905c01bc44f61cb2e0c Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Thu, 13 Sep 2018 13:29:48 +0200 Subject: [PATCH 21/23] Add fancy schmancy progress bar --- photovoltaic_gruppe4.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/photovoltaic_gruppe4.py b/photovoltaic_gruppe4.py index 1285faf..bbcb24d 100644 --- a/photovoltaic_gruppe4.py +++ b/photovoltaic_gruppe4.py @@ -21,9 +21,26 @@ feature_col = [tf.feature_column.numeric_column(str(idx)) for idx in range(336)] n = pywatts.neural.Net(feature_cols=feature_col) predictions = [] -for query in queries: +total = len(queries) +for idx, query in enumerate(queries): + + percent = idx / total + sys.stdout.write("\r") + progress = "" + for i in range(20): + if i < int(20 * percent): + progress += "=" + else: + progress += " " + sys.stdout.write("[ %s ] %.2f%%" % (progress, percent * 100)) + sys.stdout.flush() + if oneH: predictions.extend(predict(n, query).astype('Float64').tolist()) else: predictions.append(predict24h(n, query)) + print(predictions, file=open("test_data_gruppe4.json", "w")) + +sys.stdout.write("\r") +print("Done!") From 688b4025df511d1d2674ad8041886989cf5b7345 Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Thu, 13 Sep 2018 14:13:41 +0200 Subject: [PATCH 22/23] Fix script again --- photovoltaic_gruppe4.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/photovoltaic_gruppe4.py b/photovoltaic_gruppe4.py index bbcb24d..9183523 100644 --- a/photovoltaic_gruppe4.py +++ b/photovoltaic_gruppe4.py @@ -43,4 +43,4 @@ for idx, query in enumerate(queries): print(predictions, file=open("test_data_gruppe4.json", "w")) sys.stdout.write("\r") -print("Done!") +print("[ ==================== ] 100.00%") From a8fd0844d22ecc0eac67cba89ee426c54703dc3e Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Thu, 13 Sep 2018 14:50:50 +0200 Subject: [PATCH 23/23] Add readme --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..9af26d2 --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +PyWatts - Predict Output of Solar Panels + +# Dependencies + +PyWatts is based on python3.6 and uses the following dependencies: + +* requests (2.19.1) +* pypvwatts (2.1.0) +* numpy (1.15.0) +* peewee (3.5.4) +* scikit-learn (0.19.2) +* pandas (0.23.4) +* tensorflow (1.9.0) +* matplotlib (2.2.3) +* scipy (1.1.0) + +We suggest using a python virtualenv. + +# Execute + +The script can be executed by issuing the follwing command: + +```bash +$ python photovoltaic_gruppe4.py data.json +``` + +The output can be found in the same directory in `test_data_gruppe4.json`