Skip to content

Decision engines and credit scoring: how to test the rules

B2Bnetwork team · · 7 min

IT in banking

In brief

You test the rules of a decision engine like high-risk business logic: with decision tables, boundary values for every threshold, a set of reference applications with the expected decision, and a comparison of the new rule version with the old one on historical applications. Before deployment, a new strategy can run in shadow mode, meaning it calculates decisions without affecting the customer. Every decision should leave a trail: the rule version, the input data, and the reasons for refusal, because audit, the customer, and the law require it.

What a decision engine does in the credit process

A decision engine takes a loan application, collects data, and returns a decision: approve, decline, or refer to an analyst. Along the way it usually goes through several stages:

  1. Pre-screening rules. Age, residency, data completeness, sanctions lists, suspected fraud.
  2. External data. Credit history from credit bureaus, in Poland from BIK (the Polish Credit Bureau), income data, and sometimes account data shared by the customer through open banking.
  3. Scoring. A statistical or machine-learned model estimates the probability that the customer will not repay the loan.
  4. Creditworthiness. A calculation of what installment the customer can bear after deducting living costs and other obligations.
  5. Strategy. Based on the scoring result and creditworthiness, the system determines the decision, limit, term, and price.

Each stage has its own rules, thresholds, and exceptions, and the result of one is the input of the next. An error at the start of the chain can go unnoticed until the decision. This is what the process looked like in the case study of an online cash loan with a decision in a single session.

Rules as data: decision tables and versions

In modern engines, rules are not embedded in the application code but stored as data: decision tables, trees, or models in DMN (Decision Model and Notation), a standard of the OMG organization. Risk analysts can change them without releasing a new version of the application. This is an advantage and a risk at the same time: changing a single threshold on a Wednesday afternoon changes decisions for every application from that moment on.

That is why rules need the same discipline as code:

  • versioning: every change gets a version number, an author, and an effective date;
  • review: a change is approved by a second person, ideally from the risk department;
  • regression tests: before publication, the new version runs through a set of reference applications;
  • the ability to roll back: returning to the previous version takes minutes, not days.

It is also worth separating the environment in which analysts prepare and test rules from production. A change goes through the same stages as code: preparation, tests on reference applications, comparison on history, approval, and publication with an effective date. Without this, the rules engine becomes a place where production changes bypass the entire quality control process.

Techniques for testing rules

Decision rules are a classic area for the techniques in the ISTQB Foundation Level syllabus, an exam you can take at our accredited exam center.

Decision tables

Every rule with several conditions is a table: combinations of conditions and the expected decision. Tests cover every column of the table, and reviewing the table often catches combinations for which nobody defined a decision.

Boundary values

Every threshold in the rules needs a test just below, exactly at, and just above the threshold. For example, if a rule rejects applications with income below 3,000 PLN, the test cases are 2,999.99 PLN, 3,000.00 PLN, and 3,000.01 PLN. The most common error is confusing "less than" with "less than or equal to", which changes the decision for exactly the customers at the threshold.

Reference applications

A set of a few dozen to a few hundred applications with the expected decision, prepared together with risk analysts. Each application describes a specific situation: a customer with a good history and low income, a customer with no history, a customer with a delay from years ago. The approach described in the article BDD and acceptance testing makes it easier to write such examples in business language.

Comparison on historical applications

The new rule version recalculates applications from recent months, and the result is compared with the decisions of the old version. The report shows how many decisions changed and in which direction. If a change was meant to affect a narrow group of customers and changed decisions for a much broader one, that is a sign of an error. Historical data in the test environment has to be anonymized, as we describe in the article Test data and GDPR.

Shadow mode

The new strategy calculates decisions in parallel with the old one on real applications, but the customer gets the decision of the old one. After a few weeks, the risk team compares the results and only then switches the strategy.

The decision trail and explaining a refusal

Every credit decision should be reproducible months later: what data came in, which version of the rules and model assessed it, which rules fired, and why the application was declined. Tests should check not only the decision but also this record, including the refusal reason codes.

GDPR Article 22 gives a person the right not to be subject to a decision based solely on automated processing that produces legal effects concerning them or similarly significantly affects them, with the exceptions set out in that provision. The process must therefore provide for human intervention and an explanation of the decision. How to divide work between the system and a human is described in the article Human in the loop.

Scoring and the AI Act

Regulation (EU) 2024/1689, the AI Act, lists in Annex III AI systems intended to evaluate the creditworthiness of natural persons or establish their credit score as high-risk systems, except for systems used for detecting financial fraud. For such systems the regulation provides, among other things, risk management, data requirements, technical documentation, event logging, and human oversight.

Not every rules engine is an AI system within the meaning of the regulation. Rules written entirely by analysts are something different from a model learned from data, and the boundary is set by the definition in Article 3 and requires legal assessment. We describe the risk categories and obligations in the article AI Act: risk categories.

Questions and answers

How do you test a threshold change in credit rules?

With three kinds of tests. Boundary value tests check the decision just below, at, and just above the threshold. A set of reference applications shows that the rest of the rules work as before. A comparison on historical applications shows how many decisions will change after deployment and whether this affects only the group of customers the change was meant to affect.

What is shadow mode in a decision engine?

It is running a new decision strategy in parallel with the old one on real applications, without affecting the customer: the customer gets the decision of the old strategy, while the new one only calculates and records the result. After a few weeks, the risk team compares the two and decides on the switch. Shadow mode catches errors that are not visible in test data.

Is credit scoring a high-risk system under the AI Act?

Yes, if it is an AI system within the meaning of the regulation. Annex III to Regulation (EU) 2024/1689 lists AI systems intended to evaluate the creditworthiness of natural persons or establish their credit score as high-risk systems, except for systems for detecting financial fraud. Whether a specific rules engine is an AI system requires legal assessment.

What should the trail of a credit decision contain?

The application's input data and the data fetched from outside, the version of the rules and the model, the scoring result, the list of rules that fired, the decision, and the refusal reason codes. The trail must make it possible to reproduce the decision months later, explain it to the customer, and show it to an auditor. Tests should check the completeness of this record just as they check the decision itself.

What it looks like in a project

Working on banking systems? Talk to an engineer who knows their constraints.

Let's talk

Read more: IT in banking