Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Neuralforecast #1115

Merged
merged 27 commits into from
Sep 30, 2023
Merged

Add support for Neuralforecast #1115

merged 27 commits into from
Sep 30, 2023

Conversation

americast
Copy link
Member

@americast americast commented Sep 14, 2023

Adding support for neuralforecast. Fixes #1112.

DROP TABLE IF EXISTS AirData;

CREATE TABLE AirData (
    unique_id TEXT(30),
    ds TEXT(30),
    y INTEGER);

LOAD CSV 'data/forecasting/air-passengers.csv' INTO AirData;

DROP FUNCTION IF EXISTS Forecast;

CREATE FUNCTION Forecast FROM
(SELECT unique_id, ds, y FROM AirData)
TYPE Forecasting
PREDICT 'y'
HORIZON 12
LIBRARY 'neuralforecast';

SELECT Forecast(12);

One quick issue here is that neuralforecast needs horizon as a parameter while training, unlike statsforecast. Thus, a better way to call the UDF would be simply SELECT Forecast();, which is currently unsupported. @xzdandy Please let me know your thoughts.

List of stuff yet to be done:

@americast americast added this to the v0.3.5 milestone Sep 14, 2023
@americast americast requested a review from xzdandy September 14, 2023 01:05
@xzdandy
Copy link
Collaborator

xzdandy commented Sep 14, 2023

What is the error message when you try SELECT Forecast()? On the other hand, if the Forecast does not need any parameters , why we are not doing SELECT FIT_PREDICT(unique_id, ds, y, 12) FROM Air_DATA; What is the advantage of separating training and inference?

@americast
Copy link
Member Author

What is the error message when you try SELECT Forecast()?

    raise UnexpectedToken(token, e.allowed, state=parser_state, token_history=[last_token], terminals_by_name=self.root_lexer.terminals_by_name)
lark.exceptions.UnexpectedToken: Unexpected token Token('RR_BRACKET', ')') at line 1, column 17.
Expected one of: 
        * MAX
        * AVG
        * DECIMAL_LITERAL
        * SUM
        * ONE_DECIMAL
        * MINUS
        * LR_SQ_BRACKET
        * LR_BRACKET
        * COUNT
        * BIT_NOT_OP
        * TRUE
        * FALSE
        * LOCAL_ID
        * STRING_LITERAL
        * TWO_DECIMAL
        * SEGMENT
        * STAR
        * REVERSE_QUOTE_ID
        * PLUS
        * ID
        * MIN
        * FIRST
        * REAL_LITERAL
        * ANYDIM
        * NOT
        * LAST
        * EXCLAMATION_SYMBOL
        * ZERO_DECIMAL
Previous tokens: [Token('LR_BRACKET', '(')]

@jarulraj
Copy link
Member

You can copy paste the grammar file and the query into this IDE: https://www.lark-parser.org/ide/

@xzdandy xzdandy removed this from the v0.3.5 milestone Sep 20, 2023
@xzdandy xzdandy added AI Engines Features, Bugs, related to AI Engines Integrations 🧩 Pull requests that update an integration labels Sep 22, 2023
@americast americast marked this pull request as ready for review September 25, 2023 15:01
@jarulraj
Copy link
Member

Nice job, @americast :)

@xzdandy
Copy link
Collaborator

xzdandy commented Sep 29, 2023

Great work. Looks perfect. I will also update the notebook and push to this PR. Leave some minors comments to fix. Thanks.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@xzdandy
Copy link
Collaborator

xzdandy commented Sep 29, 2023

Updated the forecast notebook. Found out some new issues. Please check. We'd also like to try the neuralforecast in the notebook to see if it addresses several limitations we found with statsforecast. Create #1236 for the follow up work.

@xzdandy
Copy link
Collaborator

xzdandy commented Sep 30, 2023

The PR looks good. Thanks for the good work! I will update the notebook.

@americast americast merged commit e8a181c into staging Sep 30, 2023
@americast americast deleted the neuralforecast branch September 30, 2023 14:54
a0x8o pushed a commit to alexxx-db/eva that referenced this pull request Oct 30, 2023
Adding support for `neuralforecast`. Fixes georgia-tech-db#1112.

```sql
DROP TABLE IF EXISTS AirData;

CREATE TABLE AirData (
    unique_id TEXT(30),
    ds TEXT(30),
    y INTEGER);

LOAD CSV 'data/forecasting/air-passengers.csv' INTO AirData;

DROP FUNCTION IF EXISTS Forecast;

CREATE FUNCTION Forecast FROM
(SELECT unique_id, ds, y FROM AirData)
TYPE Forecasting
PREDICT 'y'
HORIZON 12
LIBRARY 'neuralforecast';

SELECT Forecast(12);
```
One quick issue here is that `neuralforecast` needs `horizon` as a
parameter while training, unlike `statsforecast`. Thus, a better way to
call the UDF would be simply `SELECT Forecast();`, which is currently
unsupported. @xzdandy Please let me know your thoughts.

List of stuff yet to be done:

- [x] Incorporate `neuralforecast`
- [x] Fix `HORIZON` redundancy (UPDATE: Being fixed in georgia-tech-db#1121)
- [x] Reuse model with lower horizon no
- [x] Add support for ~multivariate forecasting~ exogenous variables
- [x] Add tests
- [x] Add docs

---------

Co-authored-by: xzdandy <[email protected]>
a0x8o pushed a commit to alexxx-db/eva that referenced this pull request Oct 30, 2023
Adding support for `neuralforecast`. Fixes georgia-tech-db#1112.

```sql
DROP TABLE IF EXISTS AirData;

CREATE TABLE AirData (
    unique_id TEXT(30),
    ds TEXT(30),
    y INTEGER);

LOAD CSV 'data/forecasting/air-passengers.csv' INTO AirData;

DROP FUNCTION IF EXISTS Forecast;

CREATE FUNCTION Forecast FROM
(SELECT unique_id, ds, y FROM AirData)
TYPE Forecasting
PREDICT 'y'
HORIZON 12
LIBRARY 'neuralforecast';

SELECT Forecast(12);
```
One quick issue here is that `neuralforecast` needs `horizon` as a
parameter while training, unlike `statsforecast`. Thus, a better way to
call the UDF would be simply `SELECT Forecast();`, which is currently
unsupported. @xzdandy Please let me know your thoughts.

List of stuff yet to be done:

- [x] Incorporate `neuralforecast`
- [x] Fix `HORIZON` redundancy (UPDATE: Being fixed in georgia-tech-db#1121)
- [x] Reuse model with lower horizon no
- [x] Add support for ~multivariate forecasting~ exogenous variables
- [x] Add tests
- [x] Add docs

---------

Co-authored-by: xzdandy <[email protected]>
a0x8o pushed a commit to alexxx-db/eva that referenced this pull request Nov 22, 2023
Adding support for `neuralforecast`. Fixes georgia-tech-db#1112.

```sql
DROP TABLE IF EXISTS AirData;

CREATE TABLE AirData (
    unique_id TEXT(30),
    ds TEXT(30),
    y INTEGER);

LOAD CSV 'data/forecasting/air-passengers.csv' INTO AirData;

DROP FUNCTION IF EXISTS Forecast;

CREATE FUNCTION Forecast FROM
(SELECT unique_id, ds, y FROM AirData)
TYPE Forecasting
PREDICT 'y'
HORIZON 12
LIBRARY 'neuralforecast';

SELECT Forecast(12);
```
One quick issue here is that `neuralforecast` needs `horizon` as a
parameter while training, unlike `statsforecast`. Thus, a better way to
call the UDF would be simply `SELECT Forecast();`, which is currently
unsupported. @xzdandy Please let me know your thoughts.

List of stuff yet to be done:

- [x] Incorporate `neuralforecast`
- [x] Fix `HORIZON` redundancy (UPDATE: Being fixed in georgia-tech-db#1121)
- [x] Reuse model with lower horizon no
- [x] Add support for ~multivariate forecasting~ exogenous variables
- [x] Add tests
- [x] Add docs

---------

Co-authored-by: xzdandy <[email protected]>
a0x8o pushed a commit to alexxx-db/eva that referenced this pull request Nov 22, 2023
Adding support for `neuralforecast`. Fixes georgia-tech-db#1112.

```sql
DROP TABLE IF EXISTS AirData;

CREATE TABLE AirData (
    unique_id TEXT(30),
    ds TEXT(30),
    y INTEGER);

LOAD CSV 'data/forecasting/air-passengers.csv' INTO AirData;

DROP FUNCTION IF EXISTS Forecast;

CREATE FUNCTION Forecast FROM
(SELECT unique_id, ds, y FROM AirData)
TYPE Forecasting
PREDICT 'y'
HORIZON 12
LIBRARY 'neuralforecast';

SELECT Forecast(12);
```
One quick issue here is that `neuralforecast` needs `horizon` as a
parameter while training, unlike `statsforecast`. Thus, a better way to
call the UDF would be simply `SELECT Forecast();`, which is currently
unsupported. @xzdandy Please let me know your thoughts.

List of stuff yet to be done:

- [x] Incorporate `neuralforecast`
- [x] Fix `HORIZON` redundancy (UPDATE: Being fixed in georgia-tech-db#1121)
- [x] Reuse model with lower horizon no
- [x] Add support for ~multivariate forecasting~ exogenous variables
- [x] Add tests
- [x] Add docs

---------

Co-authored-by: xzdandy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AI Engines Features, Bugs, related to AI Engines Integrations 🧩 Pull requests that update an integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NeuralForecast support for forecasting
3 participants