← Latest papers
💻 computer science

Predicting Case Processing Duration in Kenyan Magistrate Courts: A Three-Stage Machine Learning Pipeline for Proactive Backlog Management

This study introduces a three-stage machine learning pipeline, validated on over 670,000 Kenyan magistrate court cases, which utilizes LightGBM and CatBoost models to predict case processing durations and classify same-day disposals, thereby enabling proactive backlog management through an empirically derived risk scheme and a deployed web application.

Original authors: Anuary Mulombi, Fidelis Mukudi, Anthony Mile

Published 2026-08-10
📖 8 min read🧠 Deep dive

Original authors: Anuary Mulombi, Fidelis Mukudi, Anthony Mile

Original paper licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine a giant, bustling library where millions of books are constantly being checked in and out. In this library, the librarians are overwhelmed. Some books are returned the same day they are checked in, but others get lost in the stacks for years, creating a massive pile of "backlog" that no one can seem to clear. This isn't just about books; it's about justice. When cases (the "books") sit too long, people lose faith in the system, and their rights to a fair and speedy trial are delayed. For a long time, librarians could only count the books they had already processed; they had no way to guess which new books would get stuck in the pile before they even left the desk.

Enter the world of Machine Learning, a branch of computer science where we teach computers to find patterns in history, much like a detective studying old crime scenes to solve new mysteries. Instead of guessing, these computers look at thousands of past cases to learn what makes a case move fast or get stuck. The key idea here is predictive analytics: using data from the past to forecast the future. If a computer can tell us, "This new case looks like the ones that took five years," we can stop it from getting lost in the pile before it even starts. This is exactly what the researchers in this study set out to do for the courts in Kenya, turning a reactive system (fixing problems after they happen) into a proactive one (stopping problems before they grow).


The Three-Stage Crystal Ball for Court Cases

In the Kenyan magistrate courts, where more than 80% of all legal business happens, a massive backlog has been building up. As of mid-2025, there were over 127,000 cases waiting to be heard. The existing computer system, called the Integrated Case Management System (ICMS), is great at recording what has happened, but it's blind to what might happen. It doesn't know which new cases are likely to become the "super-slow" ones that clog the system.

To fix this, the researchers built a three-stage machine learning pipeline. Think of this pipeline as a high-tech sorting machine at a post office that doesn't just stamp letters; it predicts how long each letter will take to reach its destination and flags the ones that might get lost.

Stage 0: The "Same-Day" Speed Trap

The first job of this machine is to spot the "express" cases. About 29% of all cases in Kenya are resolved on the very day they are filed. The researchers trained a computer model to look at a new case the moment it arrives and ask: "Is this a quick one, or is it going to be a marathon?"
They tested four different computer "brains" (algorithms) to see which was best at this. The winner was LightGBM, which correctly identified same-day cases with a high level of accuracy (a score of 0.9148). If the computer says "Same Day," the case gets a green light and moves on without further delay. If it says "Multi-Day," the case moves to the next stage.

Stage 1: The "Filing-Time" Crystal Ball

Once a case is flagged as a "multi-day" marathon, the system needs to guess how long the race will take. This is the tricky part because the case hasn't even started its journey yet. The computer looks only at the information available the moment the case is filed: the type of case, how many lawyers are involved, how busy the specific judge is, and whether the court is in a city or a rural area.
Using data from nearly 673,000 past cases, the LightGBM model again proved to be the champion. It could predict the duration of a case with a margin of error of about 444 days. While that sounds like a lot, it explained about 62% of the reasons why cases take as long as they do. This means that just by looking at the paperwork on day one, the system can tell a judge, "This case looks like it will take about 1.5 years," or "This one might drag on for four years."

Stage 2: The "Live-Update" Tracker

The journey doesn't end at the filing desk. As the case moves through the court, it accumulates history: hearings are held, adjournments are granted, and delays happen. The third stage of the pipeline is a dynamic model that updates the prediction as the case progresses.
Imagine a GPS that doesn't just give you an arrival time when you leave home, but recalculates it every time you hit a traffic jam. This Stage 2 model (powered by a different computer brain called CatBoost) takes the new information—like how many hearings have happened or how long the first meeting was delayed—and revises the estimate.
The results here were impressive. While the initial guess (Stage 1) had an error of 444 days, the updated guess (Stage 2) narrowed that error down to just 80.83 days. This shows that as the case moves forward, the computer gets much better at knowing exactly when it will finish.

The "JaliHaki" Dashboard: Putting It All to Work

The researchers didn't just stop at the math; they built a real-world tool called JaliHaki (which means "to guard or protect justice" in Swahili). This is a web application that connects directly to the court's computer system.

  • For Court Administrators: It shows a dashboard with a list of cases, color-coded by risk. A "Low Risk" case is green and needs routine monitoring. A "Critical Risk" case is red and needs immediate attention from a senior judge.
  • For Magistrates: It gives them a personal view of their workload, warning them if a case assigned to them is starting to drift into the "Critical" zone.
  • For Litigants (The Public): It offers a plain-language estimate. Instead of confusing legal jargon, a person filing a case might see: "Your case is estimated to take 5 years, and it is currently in the High Risk category."

What Drives the Delays?

By using a technique called SHAP analysis (which acts like a magnifying glass to see which factors matter most), the researchers discovered the main culprits behind delays:

  1. Caseload per Magistrate: When a judge has too many cases, everything slows down.
  2. Legal Representation: Whether a party has a lawyer or not changes the timeline.
  3. Case Nature: Criminal cases tend to move faster (median 90 days for multi-day cases) than civil cases (median 547 days).
  4. First-Mention Delay: How long it takes to hold the very first hearing is a huge predictor of the final delay.
  5. Accumulated Hearings: The more hearings a case has, the longer it tends to take.

Interestingly, the study found that Urban courts (in big cities) actually took longer to process multi-day cases (median 275 days) than Rural courts (median 99 days). This seems counter-intuitive, but the researchers explain it using a concept called Queueing Theory: even if a city court is well-resourced, the sheer volume of cases creates a longer "waiting line," slowing everyone down.

The Four-Tier Risk System

To make the predictions useful for real people, the team created a simple four-tier risk system based on the computer's predictions:

  • Low Risk (≤ 218 days): Routine monitoring.
  • Medium Risk (218–564 days): Scheduled review.
  • High Risk (564–1,283 days): Immediate intervention needed.
  • Critical Risk (> 1,283 days): Escalate to a senior magistrate immediately.

This system allows the court to spot the "Critical Risk" cases (which make up about 10.5% of new filings) right at the start and take action before they become part of the massive backlog.

What the Study Does and Doesn't Say

The researchers are careful to note that their model is a tool for prediction, not a magic wand. They explicitly state that the model learns from historical data, which means it reflects the current realities of the court system, including any existing inequalities between different counties or court types. They warn that the model's accuracy for rural courts might need more testing because there were fewer rural cases in their data.

They also clarify that the "filing year" was a top predictor, but not because the courts are getting faster or slower over time. Instead, it's a mathematical quirk: cases filed recently haven't had enough time to finish yet, so the computer sees them as "shorter" simply because they are new. The researchers adjusted for this to ensure the predictions were fair.

The Bottom Line

This study proves that with the data courts already have, we can build a system that predicts case delays with surprising accuracy. By using a three-stage pipeline, the Kenyan courts can now move from reacting to backlogs to preventing them. The JaliHaki application turns complex math into a simple, color-coded dashboard that helps judges, clerks, and the public understand the timeline of justice. While the model isn't perfect (it still has an error margin of about 80 days for updated predictions), it represents a massive leap forward in using technology to protect the right to a speedy trial. The study suggests that if these tools are adopted, courts can identify the cases that need help the most, right from the moment they are filed, ensuring that justice doesn't get lost in the stacks.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →