Rubix changes
This commit is contained in:
parent
f668ceaf6a
commit
70edcea2ca
5 changed files with 12 additions and 25 deletions
|
@ -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})
|
||||
|
|
|
@ -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/"
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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 <file.json>")
|
||||
print("Usage: python photovoltaic_gruppe4.py <file.json>")
|
||||
exit(1)
|
||||
|
||||
json_file = sys.argv[1] # json file
|
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue