Real-Time Risk Scoring
Estimate the probability that a loan defaults within 12 months with a Deep Netts neural network inside your Spring Boot service, and turn it into a risk band and a decision your team can review.

- 0.769
- ROC AUC on synthetic evaluation loans
- 1.3–2.2 µs
- per prediction after training (minimal, without HTTP)
- ≈ 9 KB
- saved model file, input scaling included
- JDK 25
- Spring Boot 4.1 · Deep Netts core 4.0.5
Rules treat every case near the line the same way
A lender loses money when a borrower stops paying, and loses business when it turns away people who would have repaid.
Fixed rules such as “decline if debt is above 40 % of income” are easy to explain, but they treat every case near the line the same way and miss combinations of smaller warning signs. The model supports these decisions; it does not make them.
How it works
Describe the application
Income, loan amount and term, debt-to-income, credit utilization, credit history, years employed and recent late payments.
Scale once
A Deep Netts Standardizer fitted on training data only is stored in the network, so every input is scaled exactly once.
Estimate the default probability
A small feedforward network returns the probability that the loan defaults within 12 months.
Band and decide
LOW, MEDIUM or HIGH risk. The extended version maps the band to APPROVE, REVIEW or DECLINE with reasons – a person makes the final decision on REVIEW.
Inside the model
The network from the minimal version, neuron by neuron, in its real size.
Point at an input or an output to see what it is and how it is computed.
- defaultProbability = the “defaulted” output
- LOW below 0.10
- MEDIUM from 0.10
- HIGH from 0.25
Source: minimal/…/RiskModel.java, LoanApplicationEncoder.java
Walk through the code
Real files from the minimal version. Pick a step to see the lines that do it.
@RestController@RequestMapping("/api/risk")public class RiskController { private final RiskModel model; public RiskController(RiskModel model) { this.model = model; } /** Scores one loan application. An invalid request gets a {@code 400} response and no score. */ @PostMapping("/score") public RiskScore score(@Valid @RequestBody LoanApplication application) { return model.score(application); }}Two versions in one repository
Start with the minimal version to see the whole integration in a few files; move to the extended one for the full lifecycle.
The smallest complete integration of a Deep Netts risk model in Spring Boot.
- 8 inputs, one endpoint
- Returns a probability and a risk band
- Calibration per band on test data
- 29 tests
The complete workflow: data analysis, evaluation, credit policy, monitoring and retraining.
- 17 inputs from 11 fields, synthetic generator or your own CSV
- Brier score, calibration and a behaviour check
- A decision with reasons, model versions and rollback
- Drift monitoring (PSI) and outcomes per band
- Retraining with seven checks before a new model goes live
- 58 tests
REST API
| POST | /api/risk/score | Score one application | minimal |
| POST | /api/applications/score | Score, band, decision and reasons | extended |
| GET | /api/data/summary | Default rates by field in the training data | extended |
| GET | /api/model | Active model, evaluation, last retraining | extended |
| POST | /api/model/retrain | Train a candidate, activate it only if every check passes | extended |
| GET | /api/monitoring | Drift, scores per band and decision, outcomes | extended |
| POST | /api/monitoring/outcomes | Report an outcome | extended |
POST /api/risk/scoreContent-Type: application/json { "annualIncome": 38000, "loanAmount": 15000, "loanTermMonths": 48, "debtToIncome": 0.33, "creditUtilization": 0.60, "creditHistoryYears": 5, "employmentYears": 3, "latePaymentsLast2Years": 1}{ "defaultProbability": 0.1799, "riskBand": "MEDIUM", "mediumRiskFrom": 0.1, "highRiskFrom": 0.25}Run it locally
- JDK 25 (required by Deep Netts 4.x)
- Maven 3.9 or later
- No external services – trains on synthetic loans
- Both versions use port 8080, run one at a time
git clone https://github.com/deepnetts/spring-boot-risk-scoring.gitcd spring-boot-risk-scoring/minimalmvn spring-boot:run # in a second terminalcurl -X POST localhost:8080/api/risk/score -H "Content-Type: application/json" -d '{"annualIncome": 38000, "loanAmount": 15000, "loanTermMonths": 48, "debtToIncome": 0.33, "creditUtilization": 0.60, "creditHistoryYears": 5, "employmentYears": 3, "latePaymentsLast2Years": 1}'Ready for AI coding assistants
The repository ships a SKILL.md with eleven rules for developers and AI coding assistants – keep prediction, band and decision apart, scale once, evaluate independently, never use protected characteristics – and prompts that make the assistant explain its plan first.
explain-the-example.mdGuided walkthrough before changing anythinguse-your-own-data.mdTrain on your own historical loanschange-the-inputs.mdAdd, remove or replace an application fieldadapt-the-risk-policy.mdChange the bands and the decision policy, without retrainingadapt-to-another-risk-domain.mdReuse the workflow for another yes / no risk question, such as merchant riskintegrate-into-an-existing-app.mdMove the risk model into your own Spring Boot appreview-a-model-change.mdReview changes to fields, data, training, bands, policy or API
Good to know
- Proofs of concept for learning, not production credit scoring systems. All results come from synthetic data.
- No authentication, durable storage of decisions, audit trail or explanation of individual scores.
- In the EU, the AI Act lists credit scoring as high-risk; the examples do not establish compliance with any regulation.