davidusb-geek/emhass

Custom machine learning forecast model predict

RikBast opened this issue · 1 comments

Describe the bug
It seems that the model predict lags 2h behind when called

To Reproduce
Perform a mlforecaster fit an predict

Expected behavior
I see that the timestep lag 2 h behind when predict is called

Screenshots
Scherm­afbeelding 2024-07-06 om 19 17 44

Home Assistant installation type

  • Home Assistant OS

Your hardware

  • OS: MacOS/UTM
  • Architecture: M1 Mac chips

EMHASS installation type

  • Add-on

Additional context
I think because the lag of 2 h it will generate this error (not sure ofcourse):

2024-07-06 19:12:00,882 - web_server - INFO - Passed runtime parameters: {'publish_prefix': ''}
2024-07-06 19:12:00,882 - web_server - INFO - >> Setting input data dict
2024-07-06 19:12:00,882 - web_server - INFO - Setting up needed data
2024-07-06 19:12:00,886 - web_server - INFO - >> Publishing data...
2024-07-06 19:12:00,886 - web_server - INFO - Publishing data to HASS instance
2024-07-06 19:12:00,891 - web_server - ERROR - Exception on /action/publish-data [POST]
Traceback (most recent call last):
File "/usr/local/lib/python3.11/dist-packages/pandas/core/arrays/datetimelike.py", line 1917, in _validate_frequency
raise ValueError
ValueError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 1473, in wsgi_app
response = self.full_dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 882, in full_dispatch_request
rv = self.handle_user_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 880, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 865, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/emhass/web_server.py", line 138, in action_call
_ = publish_data(input_data_dict, app.logger)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/emhass/command_line.py", line 807, in publish_data
opt_res_latest.index.freq = input_data_dict["retrieve_hass_conf"]["freq"]
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/pandas/core/indexes/datetimelike.py", line 100, in freq
self._data.freq = value # type: ignore[misc]
^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/pandas/core/arrays/datetimelike.py", line 1883, in freq
self._validate_frequency(self, value)
File "/usr/local/lib/python3.11/dist-packages/pandas/core/arrays/datetimelike.py", line 1928, in _validate_frequency
raise ValueError(
ValueError: Inferred frequency 30T from passed values does not conform to passed frequency 15T

All ok now, running the predict_model solved the issue