Tempor-ai / sybil

SYBIL: The General-Purpose Forecaster
GNU General Public License v3.0
4 stars 0 forks source link

[bug] Throws error when adding neuralprophet as base model: missing 1 required positional argument: 'external_base_model_config' #103

Closed Kevin-Chen0 closed 5 months ago

Kevin-Chen0 commented 5 months ago

In the api_call_example.ipynb notebook, I have inputted the following custom model_request (with just NeuralProphet base model):

# Onboard NeuralProphet customized model request
np_model_request = {
    "params": {
      "changepoints_range": 0.2,
      "epochs": 2,
      "growth": "off"
    },
    "metrics": [],
    "type": "neuralprophet",
}

# Customized model request
model_request = {
    'type': 'meta_naive',  # 'meta_lr', 'meta_wa'
    'scorers': ['smape', 'mape'],
    'params': {
        'preprocessors': [
            {'type': 'dartsimputer'},
            # {'type': 'simpleimputer', 'params': {'strategy': 'mean'}},
            {'type': 'minmaxscaler'},
        ],
        'base_models': [
            # {'type': 'darts_naive'},
            # {'type': 'darts_seasonalnaive'},
            # {'type': 'darts_autotheta'},
            # # {'type': 'stats_autotheta'},
            # {'type': 'darts_autoets'},
            # # {'type': 'stats_autoets'},
            # {'type': 'darts_autoarima'},
            # # {'type': 'stats_autoarima'},
            # {'type': 'darts_tbats'},
            # {'type': 'darts_linearregression'},
            # {'type': 'darts_lightgbm', 'params': {'lags': 12, 'output_chunk_length': 6, 'verbose': -1}},
            # {'type': 'darts_rnn', 'params': {'model': 'LSTM', 'hidden_dim': 10, 'n_rnn_layers': 3}},
            {'type': 'neuralprophet', 'external_params': np_model_request}  # neuralprophet
        ],
    },
}

When I ran the notebook, I got the following error:

ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/home/kevin/.conda/envs/sybil/lib/python3.9/site-packages/uvicorn/protocols/http/httptools_impl.py", line 426, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "/home/kevin/.conda/envs/sybil/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
    return await self.app(scope, receive, send)
  File "/home/kevin/.conda/envs/sybil/lib/python3.9/site-packages/fastapi/applications.py", line 292, in __call__
    await super().__call__(scope, receive, send)
  File "/home/kevin/.conda/envs/sybil/lib/python3.9/site-packages/starlette/applications.py", line 122, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/kevin/.conda/envs/sybil/lib/python3.9/site-packages/starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "/home/kevin/.conda/envs/sybil/lib/python3.9/site-packages/starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "/home/kevin/.conda/envs/sybil/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
    raise exc
  File "/home/kevin/.conda/envs/sybil/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "/home/kevin/.conda/envs/sybil/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
    raise e
  File "/home/kevin/.conda/envs/sybil/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
    await self.app(scope, receive, send)
  File "/home/kevin/.conda/envs/sybil/lib/python3.9/site-packages/starlette/routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "/home/kevin/.conda/envs/sybil/lib/python3.9/site-packages/starlette/routing.py", line 276, in handle
    await self.app(scope, receive, send)
  File "/home/kevin/.conda/envs/sybil/lib/python3.9/site-packages/starlette/routing.py", line 66, in app
    response = await func(request)
  File "/home/kevin/.conda/envs/sybil/lib/python3.9/site-packages/fastapi/routing.py", line 273, in app
    raw_response = await run_endpoint_function(
  File "/home/kevin/.conda/envs/sybil/lib/python3.9/site-packages/fastapi/routing.py", line 190, in run_endpoint_function
    return await dependant.call(**values)
  File "/home/kevin/workspace/temporai/sybil/src/appserver/routes.py", line 74, in train
    training_info = model.train(dataset)
  File "/home/kevin/workspace/temporai/sybil/src/models/modelwrappers.py", line 78, in train
    self._train(y=y_train, X=X_train)
  File "/home/kevin/workspace/temporai/sybil/src/models/pipeline.py", line 26, in _train
    return self.model._train(y, X)
  File "/home/kevin/workspace/temporai/sybil/src/models/modelwrappers.py", line 271, in _train
    model._train(y_base)
TypeError: _train() missing 1 required positional argument: 'external_base_model_config'
ZhiqianW commented 5 months ago

To fix this issue, we need to add onboard neuralprophet model to the meta_naive the same way as we did for meta_lr and meta_wa

Kevin-Chen0 commented 5 months ago

I have mistakenly used meta_naive, which currently doesn't work, instead of meta_lr. It works with meta_lr. Case closed.