Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Melodic
morphemic-preprocessor
Commits
5056f269
Commit
5056f269
authored
Jul 05, 2021
by
Anna Warno
Browse files
different frequencies prediction corrected
parent
75c27703
Changes
3
Hide whitespace changes
Inline
Side-by-side
deployment/nbeats/main.py
View file @
5056f269
...
...
@@ -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'
# + "}"
# )
...
...
deployment/nbeats/src/model_predict.py
View file @
5056f269
...
...
@@ -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
)
deployment/tft/main.py
View file @
5056f269
...
...
@@ -96,7 +96,7 @@ def main():
)
# msg1 = Msg()
# msg1.body = '[{"metric": "cpu_usage", "level": 3, "publish_rate":
60
000}]'
# msg1.body = '[{"metric": "cpu_usage", "level": 3, "publish_rate":
45
000}]'
# msg2 = Msg()
# msg2.body = (
# "{"
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment