Menu

Time-Series Validation in Python: Keep Future Data Out of Training
📰

Time-Series Validation in Python: Keep Future Data Out of Training

DEV Community: machinelearning·Gueta Quant·about 19 hours ago
#2yMRBx3B
Reading 0:00
15s threshold

A random split can mix later observations into training and produce a misleading evaluation. For ordered data, evaluate on later observations and fit transformations using only each training partition.

Educational and simulation content only. This is not financial advice, intermediation or an investment recommendation. Historical results do not guarantee future results.

Where leakage appears

Suppose a feature is standardized using the mean and standard deviation of the entire dataset, including the test period. Even if a model never receives a future date, the transformation has incorporated information from that period. Fit the transformation on training data, then apply the fitted transformation to the test data.

A chronological split reduces leakage, but does not eliminate every form. A label that depends on prices over the next five days can cross the split boundary. Exclude observations with overlapping label horizons according to the label design.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.