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

[timeseries] Speed up data preparation for local models #2587

Merged
merged 2 commits into from
Dec 22, 2022

Conversation

shchur
Copy link
Collaborator

@shchur shchur commented Dec 20, 2022

Description of changes:

  • Convert the target column into a pd.Series before splitting individual time series. This is much faster than calling .loc on a TimeSeriesDataFrame. For TSDF we end up subsetting the static_features for each iteration in the loop, but these static features aren't used by the underlying models.

Testing on a subset of 5000 items from the M5 competition dataset:

Using code currently on master:

Loaded dataset with 7559974 rows and 5000 items.
Fitting Naive: 35.2s

After current PR:

Loaded dataset with 7559974 rows and 5000 items.
Fitting Naive: 19.9s
Code for reproducing the results
import time
import pandas as pd
from autogluon.timeseries import TimeSeriesDataFrame
from autogluon.timeseries.models import NaiveModel


prediction_length = 28
raw_data = pd.read_parquet("../m5/data/subset.parquet")
static = pd.read_parquet("../m5/data/static.parquet")

raw_data["item_id"] = raw_data["item_id"].astype("str")
static["item_id"] = static["item_id"].astype("str")
static.set_index("item_id", inplace=True)

print(f"Loaded dataset with {len(raw_data)} rows and {raw_data['item_id'].nunique()} items.")
df = TimeSeriesDataFrame(raw_data, static_features=static)

model = NaiveModel(prediction_length=28, target="demand")
start_time = time.time()
model.fit(train_data=df)
preds = model.predict(data=df)
print(f"Fitting Naive: {time.time() - start_time:.1f}s")

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@github-actions
Copy link

Job PR-2587-efc023c is done.
Docs are uploaded to http://autogluon-staging.s3-website-us-west-2.amazonaws.com/PR-2587/efc023c/index.html

@shchur shchur added this to the 0.6.2 Release milestone Dec 21, 2022
@shchur shchur merged commit 7858406 into autogluon:master Dec 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants