Commit 5056f269 authored by Anna Warno's avatar Anna Warno
Browse files

different frequencies prediction corrected

parent 75c27703
......@@ -97,11 +97,11 @@ def main():
)
# msg1 = Msg()
# msg1.body = '[{"metric": "cpu_usage", "level": 3, "publish_rate": 60000}]'
# msg1.body = '[{"metric": "cpu_usage", "level": 3, "publish_rate": 30000}, {"metric": "response_time", "level": 3, "publish_rate": 60000}]'
# msg2 = Msg()
# msg2.body = (
# "{"
# + f'"metrics": ["cpu_usage"],"timestamp": {int(time.time())}, "epoch_start": {int(time.time()) + 30}, "number_of_forward_predictions": 8,"prediction_horizon": 60'
# + f'"metrics": ["cpu_usage", "response_time"],"timestamp": {int(time.time())}, "epoch_start": {int(time.time()) + 30}, "number_of_forward_predictions": 8,"prediction_horizon": 60'
# + "}"
# )
......
......@@ -79,13 +79,6 @@ def predict(
prediction = model.predict(prediction_input, mode="raw")["prediction"]
it = iter(prediction_input)
first = next(it)
model.train() # turning on dropout (in order to obtaining different prediction and calculate confidence interval)
predictions_with_dropout = [
model.forward(first[0])["prediction"][-1].item() for _ in range(20)
]
predictions_with_dropout = []
model.train()
model.loss = RMSE()
......@@ -94,7 +87,8 @@ def predict(
for x, _ in prediction_input:
# make prediction
out = model(x) # raw output is dictionary
out = model.transform_output(out).item()
out = torch.flatten(model.transform_output(out))[-1]
out = out.item()
predictions_with_dropout.append(out)
# print(model.to_prediction(model.forward(first[0])), "TRANSFORMED")
......@@ -105,9 +99,8 @@ def predict(
scale=st.sem(predictions_with_dropout),
)
predicted_values = list(conf_intervals) + [prediction[-1].item()]
predicted_values = list(conf_intervals) + [torch.flatten(prediction)[-1].item()]
predicted_values.sort() # ensure that predictions and confidence intervals are in correct order
print(predicted_values)
msg = {
target_column: {
......@@ -128,5 +121,5 @@ def predict(
logging.debug(f"prediction msg: {msg}")
future_df["split"] = "val"
future_df[target_column] = prediction[-1].item()
future_df[target_column] = torch.flatten(prediction).numpy()
return (msg, future_df)
......@@ -96,7 +96,7 @@ def main():
)
# msg1 = Msg()
# msg1.body = '[{"metric": "cpu_usage", "level": 3, "publish_rate": 60000}]'
# msg1.body = '[{"metric": "cpu_usage", "level": 3, "publish_rate": 45000}]'
# msg2 = Msg()
# msg2.body = (
# "{"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment