At first I have deleted the load_zonder_wp_forecast_mlf.pkl
file, then I have changed to 10 days and the same problem…
~
❯ curl -i -H 'Content-Type: application/json' -X POST -d '{
"days_to_retrieve": 10,
"model_type": "load_zonder_wp_forecast",
"var_model": "sensor.huidig_verbruik_zonder_wp",
"sklearn_model": "KNeighborsRegressor",
"num_lags": 48,
"split_date_delta": "48h",
"perform_backtest": "True"
}' http://192.168.79.54:5001/action/forecast-model-fit
HTTP/1.1 201 CREATED
Content-Length: 49
Content-Type: text/html; charset=utf-8
Date: Thu, 08 Jun 2023 10:52:19 GMT
Server: waitress
EMHASS >> Action forecast-model-fit executed...
~ 27s
❯ curl -i -H 'Content-Type: application/json' -X POST -d '{
"model_type": "load_zonder_wp_forecast",
"model_predict_publish": "True",
"model_predict_entity_id": "sensor.p_load_zonder_wp_custom_model",
"model_predict_unit_of_measurement": "W",
"model_predict_friendly_name": "Warmtepompboiler custom model"
}' http://192.168.79.54:5001/action/forecast-model-predict
HTTP/1.1 500 INTERNAL SERVER ERROR
Content-Length: 265
Content-Type: text/html; charset=utf-8
Date: Thu, 08 Jun 2023 10:53:04 GMT
Server: waitress
<!doctype html>
<html lang=en>
<title>500 Internal Server Error</title>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>
~
Logs from the addon
2023-06-08 12:52:19,062 - web_server - INFO - Setting up needed data
2023-06-08 12:52:19,068 - web_server - INFO - Retrieve hass get data method initiated...
2023-06-08 12:52:44,891 - web_server - INFO - >> Performing a machine learning forecast model fit...
2023-06-08 12:52:44,892 - web_server - INFO - Performing a forecast model fit for load_zonder_wp_forecast
2023-06-08 12:52:44,899 - web_server - INFO - Training a KNeighborsRegressor model
2023-06-08 12:52:44,926 - web_server - INFO - Elapsed time for model fit: 0.026717424392700195
2023-06-08 12:52:45,132 - web_server - INFO - Prediction R2 score of fitted model on test data: -0.009545803507708062
2023-06-08 12:52:45,135 - web_server - INFO - Performing simple backtesting of fitted model
0%| | 0/8 [00:00<?, ?it/s]
25%|██▌ | 2/8 [00:00<00:00, 17.07it/s]
50%|█████ | 4/8 [00:00<00:00, 17.42it/s]
75%|███████▌ | 6/8 [00:00<00:00, 16.90it/s]
100%|██████████| 8/8 [00:00<00:00, 19.05it/s]
2023-06-08 12:52:45,559 - web_server - INFO - Elapsed backtesting time: 0.42389512062072754
2023-06-08 12:52:45,560 - web_server - INFO - Backtest R2 score: 0.45701203567639437
2023-06-08 12:53:04,109 - web_server - INFO - Setting up needed data
2023-06-08 12:53:04,115 - web_server - INFO - Retrieve hass get data method initiated...
2023-06-08 12:53:04,139 - web_server - ERROR - The retrieved JSON is empty, check that correct day or variable names are passed
2023-06-08 12:53:04,140 - web_server - ERROR - Either the names of the passed variables are not correct or days_to_retrieve is larger than the recorded history of your sensor (check your recorder settings)
2023-06-08 12:53:04,142 - web_server - ERROR - Exception on /action/forecast-model-predict [POST]
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 2190, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1486, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1484, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1469, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/usr/local/lib/python3.9/dist-packages/emhass/web_server.py", line 174, in action_call
input_data_dict = set_input_data_dict(config_path, str(data_path), costfun,
File "/usr/local/lib/python3.9/dist-packages/emhass/command_line.py", line 146, in set_input_data_dict
rh.get_data(days_list, var_list)
File "/usr/local/lib/python3.9/dist-packages/emhass/retrieve_hass.py", line 147, in get_data
self.df_final = pd.concat([self.df_final, df_day], axis=0)
UnboundLocalError: local variable 'df_day' referenced before assignment
And when trying the tune
❯ curl -i -H 'Content-Type: application/json' -X POST -d '{
"model_type": "load_zonder_wp_forecast"
}' http://192.168.79.54:5001/action/forecast-model-tune
HTTP/1.1 500 INTERNAL SERVER ERROR
Content-Length: 265
Content-Type: text/html; charset=utf-8
Date: Thu, 08 Jun 2023 11:49:13 GMT
Server: waitress
<!doctype html>
<html lang=en>
<title>500 Internal Server Error</title>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>
Errors in the addon log
2023-06-08 13:49:13,471 - web_server - ERROR - Either the names of the passed variables are not correct or days_to_retrieve is larger than the recorded history of your sensor (check your recorder settings)
2023-06-08 13:49:13,471 - web_server - ERROR - Exception on /action/forecast-model-tune [POST]
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 2190, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1486, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1484, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1469, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/usr/local/lib/python3.9/dist-packages/emhass/web_server.py", line 174, in action_call
input_data_dict = set_input_data_dict(config_path, str(data_path), costfun,
File "/usr/local/lib/python3.9/dist-packages/emhass/command_line.py", line 146, in set_input_data_dict
rh.get_data(days_list, var_list)
File "/usr/local/lib/python3.9/dist-packages/emhass/retrieve_hass.py", line 147, in get_data
self.df_final = pd.concat([self.df_final, df_day], axis=0)
UnboundLocalError: local variable 'df_day' referenced before assignment