ibm-granite / granite-tsfm

Foundation Models for Time Series
Apache License 2.0
328 stars 162 forks source link

TypeError: extend_time_series.<locals>.augment_one_series() got an unexpected keyword argument 'include_groups' #55

Closed OrionStar25 closed 3 months ago

OrionStar25 commented 3 months ago

When I specify an id column in the forecast pipeline, I get the following error:

TypeError: extend_time_series.<locals>.augment_one_series() got an unexpected keyword argument 'include_groups'

However, if I modify my dataset to only have a single time-series (no id column), everything works fine. I think id_column is not handled in the forecast_pipeline code.

I want to do be able to forecast for multi-time series. How do I do it?

This is my code:

from tsfm_public.toolkit.time_series_forecasting_pipeline import TimeSeriesForecastingPipeline
from tsfm_public.toolkit.util import select_by_index

train_end_index = 5000
test_end_index = 7000
test_start_index = test_end_index - context_length - 4

train_data_df = select_by_index(
    df_uni,
    id_columns=id_columns,
    start_index=0,
    end_index=train_end_index,
)
test_data_df = select_by_index(
    df_uni,
    id_columns=id_columns,
    start_index=test_start_index,
    end_index=test_end_index,
)
print(len(train_data_df), len(test_data_df))

column_specifiers = {
    "timestamp_column": timestamp_column,
    "id_columns": id_columns,
    "target_columns": target_columns,
    "control_columns": [],
}

tsp = TimeSeriesPreprocessor(
    **column_specifiers,
    context_length=context_length,
    prediction_length=forecast_length,
    scaling=True,
    encode_categorical=False,
    scale_outputs=True,
    scaler_type="standard",
    freq="1h",
)

tsp.train(train_data_df)

forecast_pipeline = TimeSeriesForecastingPipeline(
    model=zeroshot_model,
    timestamp_column=timestamp_column,
    id_columns=id_columns, ## if I make id_column=[] everywhere and modify my data, everything works fine.
    target_columns=target_columns,
    freq="1h",
    feature_extractor=tsp,
    explode_forecasts=False,
    inverse_scale_outputs=True,
)

forecasts = forecast_pipeline(tsp.preprocess(test_data_df))
wgifford commented 3 months ago

Thanks for filing an issue @OrionStar25. Could you tell me what version of pandas you have in your environment?

I will look into it, as it seems like the include_groups option for pandas groupby-apply was introduced in 2.2.0, but is already deprecated.

OrionStar25 commented 3 months ago

Thank you for your quick response. I was working with pandas==2.0.3 which was the default that got installed after:

! pip install ".[notebooks]"

However, I changed it to:

!pip install pandas==2.2.2
! pip install ".[notebooks]"

And it works fine now, thank you!

wgifford commented 3 months ago

I updated the dependencies, so this should be resolved. Closing for now.