A1357
Title: Avoiding future data leakage in lag-based machine learning models for time series forecasting: An XGBoost case study
Authors: Saleem Alharbi - University of Sydney (Australia) [presenting]
Shelton Peiris - University of Sydney (Australia)
Richard Hunt - University of Sydney (Australia)
Abstract: Machine learning models such as XGBoost are increasingly used for time series forecasting through lag-based feature engineering, particularly in energy forecasting applications with strong temporal dependence. However, the introduction of future data leakage due to the improper construction of lagged features during the test period can result in an overly optimistic forecast accuracy that does not accurately reflect real-world performance. Data leakage can occur in multi-step forecasting settings when lag features are constructed using actual future observations rather than predicted values. Although solar power generation data exemplifies the problem, it is applicable to any forecasting problem in which lagged predictors are contingent upon values within the forecast horizon. Two XGBoost forecasting approaches were compared using hourly solar power generation data: a leakage-prone method that improperly incorporates test-period lag values (RMSE = 7.18, MASE = 0.373) and a leakage-safe recursive forecasting procedure (RMSE = 42.80, MASE = 3.365). The results suggest that, in this example, data leakage can understate RMSE by approximately 83\% and MASE by approximately 89\%, thereby creating a misleading impression of model quality. The findings provide practical advice for the implementation of appropriate evaluation protocols when applying machine learning models to time series forecasting problems.