ML//time series
A time series is a sequence of measurements ordered in time whose values resemble their recent past, and it is the data behind every forecast an engineer is asked for: tomorrow's steam demand from the production plan, the next hour of grid load, the vibration level a bearing will reach next month. That resemblance, the autocorrelation, is the obstacle and the opportunity at once. It forbids shuffling rows the way a tabular dataset is shuffled (a model validated on shuffled rows has seen its own future), and it is exactly what makes prediction possible.
A time series is a sequence of measurements ordered in time whose values resemble their recent past, and it is the data behind every forecast an engineer is asked for: tomorrow's steam demand from the production plan, the next hour of grid load, the vibration level a bearing will reach next month. That resemblance, the autocorrelation, is the obstacle and the opportunity at once. It forbids shuffling rows the way a tabular dataset is shuffled (a model validated on shuffled rows has seen its own future), and it is exactly what makes prediction possible.
A recorded series is one realization of a stochastic process, and usually the only one there is, because a plant never runs the same year twice. Fitting a model to it assumes that averaging along that one record says what averaging across many identical machines would say (stationarity and its stronger cousin, ergodicity).
A window of past samples is a state only if it is long enough.
Feeding a model the last NNN samples is a legitimate stand-in for the sufficient state when the window covers the slowest time constant that matters. A one-second window cannot see a battery's temperature or a tool's wear, and the model will blame their effects on chance.
The tools climb in cost. The persistence forecast (in hhh steps, the same as now) is the baseline everything else has to beat. An autoregressive model predicts from a weighted sum of past values, and ARIMA adds noise terms and differencing for series that drift. Lag features turn the series into a table for gradient boosting, which wins when many exogenous inputs (a production plan, the outside temperature) drive the target. Deep sequence models such as the LSTM and the transformer come last: a single linear layer matched or beat several transformers on the standard long-horizon benchmarks1.
1Zeng et al., Are Transformers Effective for Time Series Forecasting?, AAAI 2023.
Hidden trends, levels and seasonal components written as a state-space model are fitted in Python with statsmodels, whose state-space module runs a Kalman filter to fit SARIMAX and unobserved-components models by maximum likelihood and returns the filtered and smoothed components.
Forecasting several steps ahead has two strategies. The recursive one chains one-step predictions, each fed into the next, and accumulates error the way dead reckoning accumulates position error; the direct one trains one model per horizon and pays in models. Either way, a forecast is evaluated at the horizon the decision needs, on a split by time.
The branch also holds data that arrive as events rather than on a clock: the point process, the self-exciting Hawkes process and the EWMA that serves as a cheap activity feature. The hazard function, the risk that the event comes now given that it has not come yet, belongs to survival analysis.