Rename and fix script
This commit is contained in:
parent
f5735fa2f1
commit
f668ceaf6a
2 changed files with 12 additions and 7 deletions
|
@ -9,21 +9,20 @@ from pywatts.routines import *
|
||||||
# get rid of TF debug message
|
# get rid of TF debug message
|
||||||
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
|
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
|
||||||
|
|
||||||
if len(sys.argv) != 3:
|
if len(sys.argv) != 2:
|
||||||
print("Usage: python predict_for_json.py 24h|1h <file.json>")
|
print("Usage: python photovoltaic_gruppe1.py <file.json>")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
type = sys.argv[1] # '1h' or '24h'
|
json_file = sys.argv[1] # json file
|
||||||
json_file = sys.argv[2] # 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)]
|
feature_col = [tf.feature_column.numeric_column(str(idx)) for idx in range(336)]
|
||||||
n = pywatts.neural.Net(feature_cols=feature_col)
|
n = pywatts.neural.Net(feature_cols=feature_col)
|
||||||
|
|
||||||
predictions = []
|
predictions = []
|
||||||
for query in queries:
|
for query in queries:
|
||||||
if type == '1h':
|
if oneH:
|
||||||
predictions.extend(predict(n, query).astype('Float64').tolist())
|
predictions.extend(predict(n, query).astype('Float64').tolist())
|
||||||
else:
|
else:
|
||||||
predictions.append(predict24h(n, query))
|
predictions.append(predict24h(n, query))
|
|
@ -39,6 +39,12 @@ def input_query(json_str, idx=0):
|
||||||
def input_queries(json_str):
|
def input_queries(json_str):
|
||||||
tmp_df = pandas.read_json(json_str)
|
tmp_df = pandas.read_json(json_str)
|
||||||
|
|
||||||
|
oneH = False
|
||||||
|
try:
|
||||||
|
s = tmp_df['max_temp'][0]
|
||||||
|
except KeyError:
|
||||||
|
oneH = True
|
||||||
|
|
||||||
queries = []
|
queries = []
|
||||||
for i in range(len(tmp_df)):
|
for i in range(len(tmp_df)):
|
||||||
queries.append(pandas.DataFrame.from_dict(
|
queries.append(pandas.DataFrame.from_dict(
|
||||||
|
@ -46,7 +52,7 @@ def input_queries(json_str):
|
||||||
'temp': tmp_df['temp'][i],
|
'temp': tmp_df['temp'][i],
|
||||||
'wind': tmp_df['wind'][i]}
|
'wind': tmp_df['wind'][i]}
|
||||||
))
|
))
|
||||||
return queries
|
return oneH, queries
|
||||||
|
|
||||||
|
|
||||||
def input_result(json_str, idx=0):
|
def input_result(json_str, idx=0):
|
||||||
|
|
Loading…
Reference in a new issue