[timeseries] Preserve custom id_column/timestamp_column names in predict() output
Description
Module: timeseries
Problem
TimeSeriesDataFrame accepts custom column names on input via id_column and timestamp_column (e.g. from_data_frame(..., id_column="product", timestamp_column="time")). Columns are renamed internally to canonical names item_id and timestamp, which is reasonable for internal consistency.
However, the original column names are not stored and are not restored on output. In particular:
TimeSeriesPredictor.predict()always returns aTimeSeriesDataFramewith MultiIndex levels nameditem_idandtimestamp.TimeSeriesPredictor.make_future_data_frame()always returns columnsitem_idandtimestamp.TimeSeriesDataFrame.to_data_frame()reflects the canonical index names as well.
This creates a mismatch for users whose upstream/downstream pipelines use custom schema names (databases, ETL, reporting). The forecasting tutorial states that raw column names "can be arbitrary" when constructing a TimeSeriesDataFrame, which can imply end-to-end preservation, but the docs do not mention that outputs always use canonical names.
Current behavior (minimal example)
import pandas as pd
from autogluon.timeseries import TimeSeriesDataFrame, TimeSeriesPredictor
df = pd.DataFrame({
"product": ["A", "A", "A"],
"time": pd.to_datetime(["2020-01-01", "2020-01-02", "2020-01-03"]),
"target": [1.0, 2.0, 3.0],
})
train_data = TimeSeriesDataFrame.from_data_frame(
df, id_column="product", timestamp_column="time"
)
assert train_data.index.names == ["item_id", "timestamp"] # expected internal normalization
predictor = TimeSeriesPredictor(prediction_length=1, freq="D").fit(train_data)
predictions = predictor.predict(train_data)
print(predictions.index.names)
# Actual: ['item_id', 'timestamp']
# Desired: ['product', 'time'] (or configurable)
References
- Tutorial (arbitrary input column names): https://github.com/autogluon/autogluon/blob/master/docs/tutorials/timeseries/forecasting-quick-start.ipynb
TimeSeriesDataFrame(id_column,timestamp_column, internal rename): https://github.com/autogluon/autogluon/blob/master/timeseries/src/autogluon/timeseries/dataset/ts_dataframe.pyTimeSeriesPredictor.predict(): https://github.com/autogluon/autogluon/blob/master/timeseries/src/autogluon/timeseries/predictor.pyTimeSeriesPredictor._to_data_frame()(no column mapping on auto-convert): https://github.com/autogluon/autogluon/blob/master/timeseries/src/autogluon/timeseries/predictor.py#L248-L267make_future_data_frame()(always returnsitem_id,timestamp): https://github.com/autogluon/autogluon/blob/master/timeseries/src/autogluon/timeseries/utils/forecast.py- Test: custom
id_columnon load still yields canonical index names: https://github.com/autogluon/autogluon/blob/master/timeseries/tests/unittests/test_ts_dataset.py#L802-L821 - Test: raw DataFrame with custom column names fails
fit()without prior conversion: https://github.com/autogluon/autogluon/blob/master/timeseries/tests/unittests/test_predictor.py#L575-L584
Source: autogluon/autogluon