AbdullahO / tspdb

tspdb: Time Series Predict DB
Apache License 2.0
185 stars 58 forks source link

Predict Function "could not broadcast input array from (2,) to (28,) #35

Open brodymaddox opened 1 year ago

brodymaddox commented 1 year ago

I'm writing an application using tspDB that receives live input and makes a prediction based off of it, and while the first two feeds of live data go smoothly and produce a prediction, the third causes the following error:

Any help would be greatly appreciated!

Traceback (most recent call last): File "/usr/local/lib/python3.10/dist-packages/pandas/io/sql.py", line 2018, in execute cur.execute(*args, **kwargs) psycopg2.errors.ExternalRoutineException: ValueError: could not broadcast input array from shape (2,) into shape (28,) CONTEXT: Traceback (most recent call last): PL/Python function "predict", line 13, in prediction,interval = get_prediction( indexname, table_name, value_column, plpyimp(plpy), t, uq, projected = projected, uq_method = uq_method, c = c) PL/Python function "predict", line 225, in get_prediction PL/Python function "predict", line 493, in _get_forecast_range PL/Python function "predict"

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

Traceback (most recent call last): File "/home/brodymadd/Autotrader/main.py", line 67, in c.run(handle_msg=handle_msg) File "/home/brodymadd/.local/lib/python3.10/site-packages/polygon/websocket/init.py", line 180, in run asyncio.run(self.connect(handle_msg_wrapper, close_timeout, *kwargs)) File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete return future.result() File "/home/brodymadd/.local/lib/python3.10/site-packages/polygon/websocket/init.py", line 146, in connect await processor(cmsg) # type: ignore File "/home/brodymadd/.local/lib/python3.10/site-packages/polygon/websocket/init.py", line 178, in handle_msg_wrapper handle_msg(msgs) File "/home/brodymadd/Autotrader/main.py", line 64, in handle_msg predictor.predict_single(ta_row) File "/home/brodymadd/Autotrader/tspDB.py", line 89, in predict_single pdf = pd.read_sql_query(q%int(data[0]), conn) File "/usr/local/lib/python3.10/dist-packages/pandas/io/sql.py", line 397, in read_sql_query return pandas_sql.read_query( File "/usr/local/lib/python3.10/dist-packages/pandas/io/sql.py", line 2078, in read_query cursor = self.execute(args) File "/usr/local/lib/python3.10/dist-packages/pandas/io/sql.py", line 2030, in execute raise ex from exc pandas.errors.DatabaseError: Execution failed on sql 'select * from predict('aapl1m', 'close', 2184940, 'pindex_aapl1m', c => 98);': ValueError: could not broadcast input array from shape (2,) into shape (28,) CONTEXT: Traceback (most recent call last): PL/Python function "predict", line 13, in prediction,interval = get_prediction( indexname, table_name, value_column, plpyimp(plpy), t, uq, projected = projected, uq_method = uq_method, c = c) PL/Python function "predict", line 225, in get_prediction PL/Python function "predict", line 493, in _get_forecast_range PL/Python function "predict"