← Solutions

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.

risk-service · real-time scoring
customerhistoryamountvelocityDeep Nettsrisk model0.72HIGHcustomeraccount 4821historyamountvelocity0.72HIGH
customerhistoryamountvelocityDeep Nettsrisk model0.72HIGH
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

  1. Describe the application

    Income, loan amount and term, debt-to-income, credit utilization, credit history, years employed and recent late payments.

  2. Scale once

    A Deep Netts Standardizer fitted on training data only is stored in the network, so every input is scaled exactly once.

  3. Estimate the default probability

    A small feedforward network returns the probability that the loan defaults within 12 months.

  4. 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.

Inputs · 8Hidden · 8 · tanhOutput · 2 · softmaxannualIncomeloanAmountloanTermMonthsdebtToIncomecreditUtilizationcreditHistoryYearsemploymentYearslatePaymentsLast2Yearsrepaiddefaulted
The minimal network8 → 8 → 2

Point at an input or an output to see what it is and how it is computed.

Decision
  • defaultProbability = the “defaulted” output
  • LOW below 0.10
  • MEDIUM from 0.10
  • HIGH from 0.25
Standardizer saved in the modelCross-entropyAdamlearning rate 0.00120 epochsseed 42
Extended version17 → 16 (tanh) → 2 (softmax)

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

REST API

POST/api/risk/scoreScore one applicationminimal
POST/api/applications/scoreScore, band, decision and reasonsextended
GET/api/data/summaryDefault rates by field in the training dataextended
GET/api/modelActive model, evaluation, last retrainingextended
POST/api/model/retrainTrain a candidate, activate it only if every check passesextended
GET/api/monitoringDrift, scores per band and decision, outcomesextended
POST/api/monitoring/outcomesReport an outcomeextended
Request · minimal
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}
Response
{  "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
Terminal
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 anything
  • use-your-own-data.mdTrain on your own historical loans
  • change-the-inputs.mdAdd, remove or replace an application field
  • adapt-the-risk-policy.mdChange the bands and the decision policy, without retraining
  • adapt-to-another-risk-domain.mdReuse the workflow for another yes / no risk question, such as merchant risk
  • integrate-into-an-existing-app.mdMove the risk model into your own Spring Boot app
  • review-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.

More solutions

See Deep Netts in researchCase studies from Jefferson Lab and the University of Minnesota.Read the case studies