Commit cd21bbc8 authored by Fotis Paraskevopoulos's avatar Fotis Paraskevopoulos
Browse files

Fixing times based on UTC

parent 43f8ebe4
Pipeline #17653 passed with stage
in 1 minute and 30 seconds
......@@ -88,26 +88,28 @@ class ESHybrid(morphemic.handler.ModelHandler,messaging.listener.MorphemicListen
def on_schedule(self, times):
for m in self.metrics:
predictions = self.model.predict(
self.application,
m,
times
)
for t in times:
logging.debug("Sending prediction for time %s(%s) " % (datetime.datetime.fromtimestamp(t), t))
for index,row in predictions.iterrows():
t = row['ds']
payload = {
"metricValue": row['y_hat'],
"timestamp": int(t.strftime('%s')),
"probability": 0.98,
"confidence_interval": [float(8),float(15)],
"predictionTime": int(time.time()),
}
logging.debug("Sending prediction for time %s => %s " % (t, payload) )
self.connector.send_to_topic(
"intermediate_prediction.eshybrid.%s" % m,
{
"metricValue": predictions[t],
"timestamp": int(time.time()),
"probability": 0.98,
"confidence_interval": [float(8),float(15)],
"predictionTime":t,
}
payload
)
def _train_model(self):
self.dataset.make()
......
import logging
import threading
import uuid
from datetime import datetime
import pandas as pd
from ESRNN import ESRNN
......@@ -63,11 +63,14 @@ class Model:
def __init__(self, handler=False) -> None:
self._handler= handler
# integrated here
self._model = False
self._model = None
def _new_model(self) -> UUIDModel:
_logger.debug("Training new model")
config = configuration.get_config('Hourly')
config.get('train_parameters').update({
'batch_size':1
})
model = UUIDModel(uuid.uuid4(),config)
return model
......@@ -95,7 +98,7 @@ class Model:
m_pd_test_x['x'] = m
return beautify(m_pd_train_x),beautify(m_pd_train_y), beautify(m_pd_test_x) , None #beautify(m_pd_test_y)
return beautify(m_pd_train_x),beautify(m_pd_train_y), beautify(m_pd_test_x) , None
def _retrain(self, metrics, data):
......@@ -133,10 +136,13 @@ class Model:
_logger.error("No model trained yet")
return
m_pd = pd.DataFrame(data=times, columns=['ds'])
m_pd = pd.DataFrame(data=[ datetime.fromtimestamp(x) for x in times ], columns=['ds'])
m_pd.insert(0,'unique_id',application)
m_pd.insert(1,'x',metric)
m_pd['ds'] = pd.to_datetime(m_pd['ds'], utc = True)
ret= self._model.model_for_metric(metric).predict(m_pd)
return ret
\ No newline at end of file
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