Machine Learning could improve invoice routing

[Paper] jamming [in a printer] is what engineers call a “scheduling” problem. Picture a warehouse in which thousands of packages are traveling on intersecting converyor belts. If the distance between the packages isn’t carefully maintained, they will collide and pile up, creating jams. Printer designers solve this problem by making the paper path smart.

See: Joshua Rothman, Why Paper Jams Persist

At Synaptiq we were recently asked to help with a scheduling problem of sorts. Here’s how we can put machine learning to use.

The Situation

A company’s Accounts Payable (AP) division receives invoices from thousands of vendors daily. Invoices go to a team of AP specialists who share the load of sorting invoices into routing queues. A specialist takes some time to route each invoice and can occasionally make a mistake in routing an invoice. On the whole, AP specialists are very good at their jobs — they get it right 95% of the time.

On the occasional instance when they make a mistake and the invoice gets wrongly routed, the invoice needs to be scrutinized more carefully and re-routed correctly. This “high-touch” scenario takes substantially more time to sort out.

But the AP team doesn’t always have the luxury of time. The monthly closing of the books is an inescapable event. When there are a large number of invoices that enter the AP process, eventually, time runs out to handle and fix a portion of the wrongly routed invoices. These invoices end up in approval limbo; come the end of the month they make it hard to efficiently and accurately close the books.

Can Machine Learning Help?

AP specialists are great at their jobs — their routing accuracy rate is 95%. It’s very hard for a machine learning model to come close to this level of accuracy.

But when it comes to a machine learning solution, there’s more to consider than just accuracy. There’s also automation. What if we build a machine learning model to route the majority of the invoices, and send only the the wrongly sorted ones to the AP specialist? That would cut down their workload by quite a bit and enable them to spend their time on the relatively smaller “high-touch” items.

In this case, instead of relying on a machine learning model to route with high accuracy, we rely on the model to automate the routing of the relatively easy invoices and leave the difficult ones for the human specialists. This lets the humans concentrate on the things they do best and gives them more time to do what they do best.

Quantifying the Benefit of Automation Through Machine Learning

Let’s find out how and by how much a machine learning model can help. Let’s make some assumptions about the AP process. (To view the details and plug in your own values, go here.)

  • The number of invoices a vendor sends in a day can be modeled as a Poisson process. The μμ parameter in the Poisson process has to be set appropriately to equal the number of invoices that get into the AP process pipleline every month.
  • Once μμ is set, the number of invoices generated per day also depends on the number of vendors who are generating those invoices. We assume the company has 2,500 vendors.
  • The company has 4 AP specialists and they each deal with routing invoices 6.5 hours a day.
  • There are 20 business days a month.
  • Specialists are 95% accurate at routing invoices correctly. At best, a machine learning model is only 80% accurate in routing invoices correctly.
  • It takes on average 90 seconds for an AP specialist to route an invoice; the automated machine learning system can route an invoice in under a second.
  • Finally, we assume that it takes much longer to correctly re-route inovices that have been incorrectly routed. The time it takes to remedy this problem can take between 1 and 4 hours on average.

For more details, check out the code here.


Let’s say the current situation results in 100 unapproved invoices at the end of the month. Even a relatively low-accuracy machine learning system can reduce the number of stuck invoices by more than half to 41 — see the red line representing a machine learning (ML) model which is only 50% accurate in a scenario where it takes 4 hours on average to fix a routing problem. When the ML model’s efficiency is increased to a moderate 70%, only 18 invoices are stuck in the system rather than 100. That’s a reduction of 82% in stuck invoices.

And depending on the average time it takes to fix an incorrectly routed invoice, introducing the machine learning model at the start of the AP process can eliminate the problem altogether. The yellow and grey lines show that when the accuracy of the ML model is at 70%, and it takes on average an hour to fix the problem, the problem of stuck invoices is eliminated – there are no unapproved invoices in the system at the end of the month!


  • It is very hard if not impossible for a machine learning system to replicate the accuracy of an AP specialist.
  • However, routing invoices through a machine learning system before they get to the AP specialists drastically cuts down the number of invoices that the AP specialists need to handle.
  • This frees them up to focus on a smaller number of wrongly routed invoices.
  • Because there are a smaller number of invoices to start with, there is less risk of running out of time by the month’s close.
  • Acting as an automated routing “filter” at the top of the invoice pipeline, even a machine learning system of moderate accuracy can significantly improve the end-of-month accruals and closing-of-books processes.

For more details, check out the code here.