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

Fix edge case bug in layered models. #123

Merged
merged 5 commits into from
Sep 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions merlion/models/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ def _resolve_args(cls, config: LayeredModelConfig, model: ModelBase, **kwargs):
)
elif config is not None and model is not None:
if config.model is None:
if isinstance(model, dict):
model = ModelFactory.create(**model)
config = copy.copy(config)
config.model = model
else:
raise RuntimeError(
Expand Down
10 changes: 5 additions & 5 deletions tests/forecast/test_autosarima.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

from merlion.evaluate.forecast import ForecastMetric
from merlion.models.automl.autosarima import AutoSarima, AutoSarimaConfig
from merlion.models.automl.seasonality import SeasonalityLayer
from merlion.utils import TimeSeries, autosarima_utils
from merlion.models.automl.seasonality import SeasonalityLayer, SeasonalityConfig
from merlion.utils import TimeSeries

logger = logging.getLogger(__name__)
rootdir = dirname(dirname(dirname(abspath(__file__))))
Expand Down Expand Up @@ -801,7 +801,7 @@ def run_test(self, auto_pqPQ: bool, seasonality_layer: bool, expected_sMAPE: flo
)
)
if seasonality_layer:
self.model = SeasonalityLayer(model=model)
self.model = SeasonalityLayer(config=SeasonalityConfig(model=None), model=model)
else:
self.model = model

Expand Down Expand Up @@ -850,12 +850,12 @@ def run_test(self, auto_pqPQ: bool, seasonality_layer: bool, expected_sMAPE: flo
def test_autosarima(self):
print("-" * 80)
logger.info("TestAutoSarima.test_autosarima\n" + "-" * 80 + "\n")
self.run_test(auto_pqPQ=False, seasonality_layer=True, expected_sMAPE=3.4130)
self.run_test(auto_pqPQ=False, seasonality_layer=False, expected_sMAPE=3.4130)

def test_seasonality_layer(self):
print("-" * 80)
logger.info("TestAutoSarima.test_seasonality_layer\n" + "-" * 80 + "\n")
self.run_test(auto_pqPQ=False, seasonality_layer=False, expected_sMAPE=3.4130)
self.run_test(auto_pqPQ=False, seasonality_layer=True, expected_sMAPE=3.4130)


if __name__ == "__main__":
Expand Down