Time Series Analysis and Forecasting
Analyse and forecast time series in Python: decomposition, stationarity, exponential smoothing, SARIMA and gradient boosting, tested with honest backtests and prediction intervals.
Intermediate · Data Science · about 15 hours · 5 modules · certificate on completion
Taught by Thandiwè Dlaminì, Sigríður Björnsdóttìr, AI Learning Companions.
About this course
Every organisation that holds stock, staffs a service or plans a budget forecasts something. This course teaches you to analyse a time series and forecast it well, with the methods professionals rely on and the testing that shows whether they work. You'll work with four years of daily medicine demand from a fictional rural health district, with weekly and seasonal patterns, public holidays, outreach campaigns and gaps in the reporting, the kind of data a district medical store really has to plan from.
You'll clean and decompose the series, test for stationarity and read autocorrelation, fit exponential smoothing and SARIMA models with statsmodels, and build a gradient boosting forecaster on lag and calendar features without leaking the future. Then you'll evaluate them properly: rolling-origin backtests, metrics chosen for the decision (and why MAPE so often misleads), and prediction intervals whose coverage you check. It goes well beyond the forecasting lesson in AI-Powered Business Intelligence Fundamentals and the time-based cross-validation in Feature Engineering and Model Evaluation. Every lab prints real results that your instructor checks, and the capstone produces four-week forecasts with intervals for three medicines.
What you'll learn
- Prepare daily time series in pandas: a regular calendar, gaps filled sensibly, and known future events
- Decompose a series into trend and seasonal components and measure their strength
- Test for stationarity and read ACF and PACF plots to choose differencing and model orders
- Fit, diagnose and compare ETS and SARIMA models with calendar regressors in statsmodels
- Forecast with gradient boosting on lag and calendar features without leaking the future
- Backtest forecasters from rolling origins, choose metrics that fit the decision, and check interval coverage
Skills you'll gain
Time series analysis, Seasonal decomposition, Stationarity testing, Autocorrelation analysis, Exponential smoothing (ETS), ARIMA and SARIMA, Feature-based forecasting, Backtesting, Forecast accuracy metrics, Prediction intervals
Tools
Python 3, pandas, statsmodels, scikit-learn, JupyterLab
Before you start
Python and pandas, as in Data Analysis with Python and pandas, and basic statistics, as in Statistics for Data Science and AI. Machine Learning Foundations with Python helps for module 4. Install Python 3.10 or later, then pip install pandas statsmodels scikit-learn matplotlib; JupyterLab is optional but used in the walkthroughs.
Modules
Time series data, components and baselines
Get a daily series into shape in pandas, see its trend and seasonal patterns with decomposition, and set the baselines that every forecast has to beat.
- Time series data in pandas (12 min)
- Trend, seasonality and decomposition (12 min)
- Baselines and a first honest test (12 min)
- Hands-on lab: Clean, decompose and baseline the demand series
Stationarity and autocorrelation
Learn what stationarity means and why models rely on it, make a series stationary with transformations and differencing, and read autocorrelation to see what structure is left to model.
- Stationarity, transformations and differencing (12 min)
- Testing for stationarity: ADF and KPSS (10 min)
- Autocorrelation: ACF, PACF and white noise (12 min)
- Hands-on lab: Make the series stationary and read its autocorrelation
Exponential smoothing and ARIMA
Fit the two classical families of forecasting models with statsmodels: exponential smoothing (ETS), and SARIMA with regressors for holidays and campaigns, chosen by AIC and checked through their residuals.
- Exponential smoothing and ETS models (12 min)
- ARIMA models (12 min)
- SARIMA and regressors for known events (12 min)
- Hands-on lab: Fit ETS and SARIMA models and compare them
Forecasting with machine learning
Turn a series into a supervised learning problem with lag and calendar features, forecast four weeks ahead with gradient boosting, and avoid the leaks that make such models look better than they are.
- From a series to a table of features (12 min)
- Gradient boosting forecasters: direct and recursive strategies (12 min)
- Hands-on lab: Forecast four weeks ahead with gradient boosting
Backtesting, metrics and prediction intervals
Evaluate forecasters the way they'll be used: backtests from several origins, metrics chosen for the decision, and prediction intervals whose coverage is checked.
- Backtesting with rolling origins (12 min)
- Forecast accuracy metrics, and the traps in MAPE (12 min)
- Prediction intervals and coverage (12 min)
- Hands-on lab: Backtest the forecasters and check their intervals
Project: Four-week medicine forecasts for the district store
The district medical store orders oral rehydration salts, paracetamol and amoxicillin every four weeks, and wants forecasts it can trust for 1 to 28 January 2026. Using demand.csv, forecast all three medicines daily with 80% prediction intervals, backed by a backtest from at least six origins. The series differ: ORS has a strong rainy-season peak and campaign spikes, paracetamol peaks in the cold season, and amoxicillin is small counts with some zero days, so a metric or method that suits one may not suit another. Choose a method per medicine with reasons, check its residuals and its interval coverage, and give the store a 28-day total for each medicine with an upper planning figure. Finish with a one-page note for the store manager.
Part of
The products this course names are trademarks of their owners, who haven't made or endorsed it.