Skip to content

Auto-Create Timestamps in prettify_prediction() When test_data is None#1507

Closed
aditisingh02 wants to merge 2 commits intomicrosoft:mainfrom
aditisingh02:feature/auto-create-timestamps
Closed

Auto-Create Timestamps in prettify_prediction() When test_data is None#1507
aditisingh02 wants to merge 2 commits intomicrosoft:mainfrom
aditisingh02:feature/auto-create-timestamps

Conversation

@aditisingh02
Copy link
Copy Markdown

Why are these changes needed?

Currently, the TimeSeriesDataset.prettify_prediction() method in flaml/automl/time_series/ts_data.py throws a NotImplementedError when test_data is None:

# TODO auto-create the timestamps for the time column instead of throwing
raise NotImplementedError("Need a non-None test_data for this to work, for now")

This is frustrating for users who want to make predictions without providing explicit test data timestamps, which is a common use case in time series forecasting.

This PR implements automatic timestamp generation by:

  1. Using the training data's end date (train_data[time_col].max()) as the starting point
  2. Generating future timestamps based on the dataset's inferred frequency
  3. Supporting all input types: np.ndarray, pd.Series, and pd.DataFrame

Example behavior after this change:

# Before: NotImplementedError
# After: Automatically generates timestamps starting from training end + 1 period
y_pred = model.predict(steps=10)  # Works without explicit test_data!

Related issue number

Closes #1506

Checks

  • I've used pre-commit to lint the changes in this PR (black and ruff passed; pyupgrade failed due to Python 3.14 ast module incompatibility - not a code issue).
  • I've included any doc changes needed for https://microsoft.github.io/FLAML/. (No doc changes needed - internal implementation fix)
  • I've added tests (if relevant) corresponding to the changes introduced in this PR.
  • I've made sure all auto checks have passed.

… None

- Removed NotImplementedError and instead generate timestamps automatically
- Uses training data's end_date and frequency to create prediction timestamps
- Supports np.ndarray, pd.Series, and pd.DataFrame inputs
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.

[Feature Request]: Auto-Create Timestamps for Time Series Prediction

1 participant