A review queue for billing: the system learns what normal invoices look like, flags the odd ones, and explains why, so people only check what needs checking.

- Machine Learning with Python · IBM · Coursera
- Unsupervised Learning, Recommenders, Reinforcement Learning · DeepLearning.AI & Stanford Online · Coursera
Overview
What this is and why it matters, in plain English.
A review queue for billing: the system learns what normal invoices look like, flags the odd ones, and explains why, so people only check what needs checking.
Machine learning that spots unusual invoices for review before they go out, without needing past examples of errors.
The situation
What was going on before, and why it needed fixing.
Billing errors were caught either by checking everything by hand or by fixed rules that missed new kinds of mistakes. There were no labeled examples of bad invoices to train on.
There were no labeled examples of bad invoices. Reviewers either checked everything by hand or relied on fixed rules that missed new kinds of mistakes.
What it needed to do
The outcomes the project had to deliver.
- Flag unusual invoices without needing labeled data.
- Compare each invoice with others like it, not with the whole business.
- Explain every flag so reviewers can act quickly.
What I did
My part of the work and who I worked with.
I designed and built the unsupervised pipeline in Python with Pandas and scikit-learn, the scoring Lambda on AWS, and the review queue integration in Laravel backed by MySQL.
How it works
The main building blocks, from the screen people use to the data underneath.
Built an unsupervised pipeline in Python: features per invoice, k-means to segment normal billing behavior, and a per-cluster Gaussian anomaly score with a threshold tuned on a small reviewed sample. A Lambda scores new invoices and Laravel shows flagged ones in a review queue.
- 01
Feature extraction
Per-invoice features such as line counts, amounts, codes used and timing, scaled consistently.
- 02
k-means segmentation
Groups invoices into segments of normal behavior so different practices are compared fairly.
- 03
Gaussian density score
A per-segment Gaussian model scores how unusual each invoice is; scores below a threshold are flagged.
- 04
Scoring Lambda and review queue
New invoices are scored on AWS Lambda; flagged ones appear in a Laravel review queue with the features that stood out.
Key choices and trade-offs
Every build involves trade-offs. These are the important ones and what each one cost.
| Decision | Trade-off |
|---|---|
| Unsupervised instead of waiting for labels. | Thresholds need human calibration, but the system can start without a labeled history. |
| Cluster first, then score. | An extra model to maintain, but whole segments are no longer flagged just for being different. |
| Human review, not auto-blocking. | Flags still need a person, but no invoice is held back by the model alone. |
Under the hood
Implementation details for technical readers, with a code sample.
- Applies k-means clustering and Gaussian anomaly detection from Unsupervised Learning, Recommenders, Reinforcement Learning.
- Built with the Python, Pandas and scikit-learn workflow from Machine Learning with Python.
- Explanations that point reviewers to the unusual features.
segments = KMeans(n_clusters=k, n_init=10, random_state=7).fit(X_scaled)
scores = np.empty(len(X_scaled))
for c in range(k):
members = X_scaled[segments.labels_ == c]
mu, var = members.mean(axis=0), members.var(axis=0) + 1e-6
idx = segments.labels_ == c
scores[idx] = multivariate_normal(mu, np.diag(var)).logpdf(X_scaled[idx])
flagged = scores < epsilonProblems solved
What got in the way, and how each problem was fixed.
- 01
With no labels, the threshold was set against a small set of invoices reviewers had already checked, then revisited as feedback came in.
The threshold was set against a small reviewed sample and is revisited as reviewer feedback accumulates.
- 02
Different practices bill very differently, so one global model flagged whole segments; clustering first kept comparisons fair.
Segmenting with k-means before density scoring keeps comparisons within similar billing patterns.
- 03
Every flag needed an explanation, so the queue shows which features were furthest from the cluster norm.
Each flag lists the features furthest from its segment’s norm.
Security, speed and growth
How data is protected, and how the system stays fast as usage grows.
Security
Scoring uses invoice features, not patient notes, and the review queue follows the same billing permissions as the rest of the system.
Speed & growth
Scoring runs per invoice in a Lambda, so the review queue fills as invoices are created without batch delays.
Quality and releases
How changes were tested and shipped safely.
Synthetic anomalies injected into historical data to check they are flagged, plus stability checks on clusters between training runs.
Tech stack
The tools and technologies used, for recruiters and technical reviewers.
Results
What the system is designed to achieve, and how.
| Metric | Result |
|---|---|
| Labels needed | None to train |
| Method | k-means + Gaussian |
| Review | Human in the loop |
These are design targets and approach choices for the system, not reported production figures.
Questions
Plain answers first, then the detail a technical reviewer would ask about.
Common questions
- Will it stop invoices going out?
- No. It flags unusual invoices for a person to check; it never blocks anything on its own.
- Do we need examples of past billing errors?
- No. It learns what normal invoices look like and highlights the ones that do not fit.
For your tech lead
- Which certification does this apply?
- Unsupervised Learning, Recommenders, Reinforcement Learning, and Machine Learning with Python.
- Does it block invoices?
- No. It flags them for a person to review.
Key takeaways
- •Machine learning that spots unusual invoices for review before they go out, without needing past examples of errors.
- •Built with Python, scikit-learn, Pandas, AWS Lambda, MySQL, Laravel.