Hiring Partners
Segilola Resources Operating LimitedTaviatech TechnologiesFCMBMTN NigeriaAdvans La Fayette Microfinance BankAboki AfricaFirst Bank of NigeriaOPay
← Machine Learning for Finance & Accounting Level Two · Lesson 6 of 9

Module Five

📖 Every lesson in this course is free to read right here, no account needed. Create a free account to track your progress, take the exam, and earn your certificate.
6
Module 5: Time Series Forecasting Fundamentals for Young Coders
⭐ Module 5 · Level Two

Time Series
Forecasting Fundamentals

📅 Teaching machines to see the future in past numbers

🎯 What you'll learn in this module

  • ✔ The three components of a time series: trend, seasonality, noise
  • ✔ How moving averages and exponential smoothing work
  • ✔ The basics of ARIMA for financial data
  • ✔ How to split time series for training and testing (without cheating!)
  • ✔ How to forecast revenue, expenses, and cash flow
  • ✔ How to evaluate forecast accuracy with the right metrics
⏳
What Is a Time Series?
The Big Idea

A time series is a sequence of numbers recorded over time, in order. Monthly sales, daily stock prices, hourly cash levels — they all have one thing in common: the order matters.

This is very different from regular data where the order is arbitrary. In a time series, yesterday's values usually tell you something about today's. A good forecasting model respects that connection — it never peeks into the future.

📖 A time series is like a story in a book: page 5 only makes sense because you read pages 1–4. Shuffle the pages and the story falls apart.
🧩
Trend, Seasonality & Noise
Structure

Every time series is a blend of three things:

Component What It Means Example
📈 Trend Long‑term direction Sales growing every year
🔁 Seasonality Repeating patterns More sales every December
🎲 Noise Random up/down wiggle Random bad week

Good forecasts separate the signal (trend + seasonality) from the noise. If you mix them up, you'll overreact to random wiggles.

🎵 A song has melody (trend), rhythm (seasonality), and static (noise). To hum along, you follow the melody, not the static.
🌊
Moving Averages & Exponential Smoothing
Classical

A moving average smooths out noise by averaging the last N values. Each new period adds a value and drops the oldest. Simple, powerful, and easy to explain.

Exponential smoothing goes further: recent values get more weight than older ones. The model "forgets" slowly, focusing on what's happening right now. It's the workhorse of business forecasting since the 1950s.

M1
M2
M3
M4
M5
M6
M7
Forecast
🎚️ A moving average is like a camera stabilizer: individual shakes smooth out, and you see the steady path underneath.
📊
ARIMA: The Classic Heavyweight
Classical

ARIMA (Auto‑Regressive Integrated Moving Average) is the Swiss Army knife of time‑series forecasting. It combines three ideas:

AR — yesterday's values predict today's. I — differencing removes trend so you forecast changes, not raw values. MA — past errors predict future corrections.

ARIMA has been the standard in finance and economics for decades. It's interpretable, well‑studied, and often surprisingly strong. A useful baseline before any ML model.

🎯 ARIMA is a classic archer: not flashy, but decades of practice make it dependable.
✂️
Splitting Time Series: Never Peek Into the Future!
Validation

Here's the biggest trap in time series forecasting: if you split data randomly (like other ML problems), your model will "see the future" during training and look amazing — but fail in real life.

The right way: split by time. Train on Jan–Sep, test on Oct. Then retrain on Jan–Oct, test on Nov. Repeat. That's rolling‑origin evaluation: it mimics how you'd actually use the model — predicting the future from the past, again and again.

📅 Jan–Sep → train
→
🔍 Oct → test
→
📅 Jan–Oct → retrain
→
🔍 Nov → test
🎓 Taking a test where the questions come from the same chapter you studied. If you had the answers in advance, the score wouldn't tell you anything.
💰
Forecasting Revenue, Expenses & Cash Flow
Application

The three most common financial forecasts:

Revenue: how much will we sell next quarter? Affected by seasonality, marketing, and price.

Expenses: how much will we spend? Usually more predictable — many costs are recurring (rent, salaries).

Cash flow: how much cash will we have? The most critical forecast for small businesses — running out of cash is the #1 reason startups fail, even profitable ones!

🩺 Cash flow forecasting is like monitoring a patient's pulse. If you don't watch it, you might miss the moment it stops.
🎯
Evaluating Forecast Accuracy
Evaluation

You can't improve what you don't measure. Key forecasting metrics:

Metric What It Measures Best For
MAE Avg absolute error Easy to explain to business
RMSE Avg error, punishing big misses When big errors are costly
MAPE Error as % of actual Comparing across different scales

MAPE is popular in business because it says "we're off by 8% on average" — intuitive. But it blows up for values near zero, so use carefully.

🌡️ Like a weather forecast: "off by 3°C on average" (MAE) or "off by 5%" (MAPE). Which is more useful depends on the question.
⚠️ The #1 time‑series trap: Look‑ahead bias. If you split your data randomly, your model will get tricked into "seeing the future" during training, look amazing in testing, and then fail catastrophically in production. Always split by time, and always test on data the model has never seen.

🛠️ Hands-on activities (no boring stuff!)

1

Spot the components: Look at a 12‑month revenue chart (real or invented). Which months are the highest? Is there a trend? Is there a repeating pattern? Write one sentence about each: trend, seasonality, noise.

2

Moving average by hand: Given 6 monthly values (e.g., 100, 120, 110, 130, 140, 150), compute the 3‑month moving average for months 3, 4, 5, and 6. Notice how smoothing makes the numbers less jumpy.

3

Naive forecast baseline: Write down what a "naive forecast" would be — predicting next month = this month. Then try a "seasonal naive" — predicting next month = same month last year. Which feels smarter for a school supply store?

4

Rolling split demo: Take 12 months of sales data. Design a 3‑step rolling split: train on M1–M9 / test M10; train on M1–M10 / test M11; train on M1–M11 / test M12. Sketch the training windows.

5

Cash flow scenario: A bakery's monthly cash flow is +$5,000 in months 1–6, then −$2,000 in months 7–12 (summer slump). What forecast would you give? Why does this matter for business survival?

6

MAPE math: A forecast says $105k; actual was $100k. What's the absolute error? What's the MAPE? Now do the same with a forecast of $50k vs. actual $45k. Which forecast is "worse" in percentage terms?

🏆

By the end of this module, you'll be able to: identify trend, seasonality, and noise; apply moving averages and exponential smoothing; explain ARIMA basics; split time series correctly; and evaluate forecasts with MAE, RMSE, and MAPE.

🏆 Get Certified

🔒

Earn this certificate

Every lesson is already free to read. Sign up, finish the lessons, pass the exam (₦2,000 or 20,000 coins), and get a verified certificate with your name on it.

🎓 Sign Up to Get Certified
🛠️ Practice Tools
Hands-on simulators & labs - subscription required.
→
🎯 Internship Tasks
Real-world tasks to build your portfolio - unlock them with a subscription.
→