pywatts/photovoltaic_gruppe4.py

47 lines
1.1 KiB
Python
Raw Permalink Normal View History

2018-09-09 17:25:43 +02:00
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'
2018-09-11 14:41:52 +02:00
if len(sys.argv) != 2:
2018-09-12 17:52:05 +02:00
print("Usage: python photovoltaic_gruppe4.py <file.json>")
2018-09-09 17:25:43 +02:00
exit(1)
2018-09-11 14:41:52 +02:00
json_file = sys.argv[1] # json file
2018-09-09 17:25:43 +02:00
2018-09-11 14:41:52 +02:00
oneH, queries = input_queries(json_file)
2018-09-09 17:25:43 +02:00
feature_col = [tf.feature_column.numeric_column(str(idx)) for idx in range(336)]
n = pywatts.neural.Net(feature_cols=feature_col)
predictions = []
2018-09-13 13:29:48 +02:00
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()
2018-09-11 14:41:52 +02:00
if oneH:
2018-09-09 17:25:43 +02:00
predictions.extend(predict(n, query).astype('Float64').tolist())
else:
predictions.append(predict24h(n, query))
2018-09-13 13:29:48 +02:00
2018-09-13 11:28:17 +02:00
print(predictions, file=open("test_data_gruppe4.json", "w"))
2018-09-13 13:29:48 +02:00
sys.stdout.write("\r")
2018-09-13 14:13:41 +02:00
print("[ ==================== ] 100.00%")