Skip to content

    Time Series Forecasting Basics

    Machine Learning · Intermediate

    Definition

    Time series models predict future values from past ordered data, using trend, seasonality and lags.

    Used for sales, stock, weather and demand forecasting.

    Diagram

    past →lag features→ future

    Flowchart

    Plot seriesCheck trend & seasonalityCreate lag featuresSplit by timeForecast

    Example: Moving average forecast

    sales = [10, 12, 14, 16]
    print(sum(sales[-3:]) / 3)

    Output: 14.0

    Key points

    • Never shuffle time series
    • ARIMA, Prophet and LSTMs are common models

    Interview questions

    Why not random train/test split?

    It leaks future information into training.

    More Machine Learning topics