Skip to content

Cash Flow Forecasting with Machine Learning: A Step-by-Step Guide

Predictive Analytics · · 6 min read · Updated

By Chief Technology Officer
Finance manager studying a cash flow forecast chart with a widening forecast range

Most cash flow forecasting still happens in a spreadsheet that one person in finance understands. It works until that person is on vacation, a large customer starts paying late or the business grows past what the formulas were built for. Machine learning offers a different approach: a model that learns how money actually moves through your business and updates its forecast every day.

This guide walks through what that involves, step by step, in terms a managing director can use to brief a finance team or judge a proposal.

Why cash flow forecasting keeps getting harder

You are not imagining it. In Strategic Treasurer's 2025 Cash Forecasting and Visibility Survey, the share of companies calling cash forecasting "easy" fell from 28% in 2018 to 14% in 2025, while 53% now call it difficult. In the same survey, 68% said management expected more from the forecast than before.

The reasons are familiar to anyone who has run a month-end:

  • Customers pay on their own schedule, not on your invoice terms.

  • Data sits in several places: the ERP, bank portals, a CRM, the sales team's pipeline sheet.

  • Spreadsheets assume patterns stay the same. Seasons, price changes and new product lines break those assumptions quietly.

  • Nobody checks last quarter's forecast against what really happened, so errors repeat.

Finance teams are responding. A Gartner survey found that 58% of finance functions were using AI in 2024, up 21 percentage points from 2023.

What machine learning changes, and what it doesn't

A spreadsheet forecast is a set of rules someone wrote: "customers pay in 45 days, payroll goes out on the 25th." A machine learning model works the other way round. It looks at years of your actual invoices, payments and bank movements and finds the patterns itself, including ones nobody wrote down.

Spreadsheet forecast

Machine learning forecast

How it predicts receipts

Average payment terms

Each customer's real payment habits, by month and season

How often it updates

When someone has time

Daily or weekly, from live ERP and bank data

What you get

One number per week

A likely figure with a range around it

Who maintains it

Usually one person

A documented model, retrained on a schedule

How you know it works

Gut feel

Accuracy measured against actual results

Machine learning is good at one thing in particular: finding patterns across many related series at once, such as hundreds of customers who each pay a little differently.

In the M5 forecasting competition, which asked teams to forecast tens of thousands of related Walmart sales series, all the top-performing methods were machine learning approaches, and they clearly beat the statistical benchmarks. Retail sales are not cash, but the lesson carries over: many related series and outside factors are exactly where these models earn their keep.

What machine learning will not do is predict a shock nobody has seen before. A new tariff, a lost contract or a bank failure will not be in your history. That is why the forecast should advise and your finance team should decide.

A step-by-step guide to cash flow forecasting with machine learning

Step 1: Pick the decision the forecast must support

"A better forecast" is too vague to build. Name the decision instead. For example: when to draw on the credit line, which supplier payments can move, how much cash can safely go on deposit. The decision tells you the horizon (13 weeks? 12 months?) and how precise the forecast needs to be.

Step 2: Gather the history you already have

You need at least two years of history, ideally three or more, so the model can see each season more than once. The usual sources are:

  • Invoices and payments from your ERP or accounting system

  • Bank statements from every account

  • Payroll, rent, tax and loan schedules

  • Open orders and the sales pipeline, if they are kept in a system

The data does not need to be perfect. It needs to be complete enough that the model sees the same customers and suppliers over time.

Step 3: Split cash into streams

Do not forecast "cash" as one number. Forecast its parts separately: customer receipts, supplier payments, payroll, tax, financing. Fixed items like payroll and loan repayments need no model at all; they come straight from schedules. Machine learning goes where the uncertainty is, which is usually receipts.

Step 4: Start with a simple benchmark

Before building anything clever, record how accurate your current method is. Then build a simple statistical forecast as a second benchmark. A machine learning model is only worth keeping if it beats both on your own data.

Step 5: Train the model and test it on the past

The model is trained on older history and then asked to forecast a period it has not seen, such as last year. Because you know what really happened, you can measure the error week by week. This is called back-testing, and it is the most important evidence you will get before going live.

Step 6: Show the range, not just the number

A forecast that says "$1.2 million on March 14" sounds precise and is almost certainly wrong. As the textbook Forecasting: Principles and Practice puts it, the further ahead you forecast, the more uncertain you are, and a good forecast comes with a prediction interval that shows that range. Your team should see a likely figure plus a low and high case, and plan the tight weeks against the low case.

Step 7: Put it where your finance team already works

A forecast that lives in a separate tool gets ignored. Feed it into the dashboard or report your finance team already opens each week, refreshed automatically from the ERP and bank data.

Step 8: Measure accuracy every week and retrain

Compare each forecast with what actually happened and show the hit rate beside the forecast. When accuracy drifts, because a big customer changed habits or the business mix shifted, the model is retrained. This one habit does more for trust than any choice of algorithm.

Mistakes that sink forecasting projects

  • Starting with the algorithm. The choice of model matters far less than clean history and a clear decision to support.

  • Forecasting everything at once. One stream done well earns more trust than six done roughly.

  • Hiding the uncertainty. A single number invites false confidence. A range invites planning.

  • Skipping the comparison. If nobody measures the new forecast against the old one, nobody can say it is better.

Signs you are ready to try it

  • Your invoices, payments and bank data are in systems, not paper files.

  • You have a recurring decision that a better cash view would change.

  • Your current forecast takes someone days each month to prepare.

  • You would rather see a range of outcomes than a single confident number.

If most of these are true, a pilot on one stream, usually customer receipts, is a sensible first step. It is the approach our predictive analytics work follows: forecasts with a range, built from your own records, shown in the dashboards you already read, with accuracy checked against what actually happened.

Frequently asked questions

How much historical data do we need?

Two years is a workable minimum, because the model needs to see each season at least twice. More helps, provided the business has not changed so much that old data misleads.

Will the model replace our treasury or finance team?

No. It replaces the hours spent assembling the spreadsheet. Your team still decides what to do with the forecast and adds what the model cannot know, such as a contract about to be signed.

Does our financial data have to leave our systems?

It shouldn't need to. The model can run inside your own cloud account, reading from your ERP and bank data where they already sit.

How accurate will it be?

Nobody can promise a figure in advance. Back-testing on your own history shows how accurate it would have been, and that number, compared with your current method, is the honest basis for deciding.

If cash planning is the decision you guess at most, a 5-day free audit of your finance team is a low-risk way to find out whether your data can support a forecast like this. Or book a 30-minute call with a founder and talk it through first.

Common questions

How much historical data do we need for a machine learning cash flow forecast?

Two years is a workable minimum, because the model needs to see each season at least twice, and three or more is better. Older data helps only if the business has not changed so much that it misleads the model.

How is a machine learning cash forecast different from a spreadsheet forecast?

A spreadsheet applies rules someone wrote, such as average payment terms, and updates when someone has time. A machine learning model learns each customer's actual payment habits from your records, refreshes from live ERP and bank data, and gives a range rather than one number.

How accurate is machine learning cash flow forecasting?

Nobody can promise a figure in advance. Back-testing on your own history shows how accurate the model would have been, and comparing that with your current method is the honest basis for deciding whether to use it.

Will a forecasting model replace our finance team?

No. It replaces the hours spent assembling the spreadsheet. Your team still decides what to do with the forecast and adds what the model cannot know, such as a contract about to be signed or a new tariff.

Which part of cash flow should we forecast with machine learning first?

Customer receipts are usually the best first stream, because that is where the uncertainty sits. Fixed items such as payroll, rent, tax and loan repayments need no model and can come straight from their schedules.

Keep reading.

More on the same subjects, picked by topic and tag.

Free project estimate

Book a call with a founder.

Discuss your software or AI project with a founder in a free 30-minute call. We will review your goal, identify the main cost drivers and agree what to scope next.

What you get back

  • An indicative budget range
  • A realistic timeline
  • What moves the cost up or down
  • A reply within 4 business hours
  • Answered by a founder
  • NDA on request, before you share details

Tell us what you need

A few lines is plenty. You get a number before any call.

Fields marked * are required.