Skip to content
Tutorials Center
My learning

Topics

Lesson 35 of 36 ยท Projects and Practice

Project: A Fuzzy Loan Risk Scorer

Build a fuzzy loan risk scorer with Sugeno rules: income, debt ratio and credit history inputs, a transparent rule table, sensitivity checks and an explanation per applicant.

Lending decisions are full of soft boundaries: is an income of 38,000 "low" or "medium"? Is a debt ratio of 0.38 "high"? A bank's own policy documents use these words and then hide them behind hard cutoffs, so an applicant at 0.39 is approved and one at 0.41 is refused. A fuzzy scorer produces a graded risk instead, and the rules that explain it stay readable.

In this project you build a Sugeno scorer. The output is a risk number from 0 (safe) to 100 (very risky). You will also see how to check it for sensible behavior and how to explain each score.

This is a teaching model with invented rules. Real credit scoring is regulated: it must be validated, monitored for bias and explainable to applicants. Never use made-up thresholds for real decisions.

Step 1: inputs and terms

Input Meaning Terms
income Yearly income in thousands low, medium, high
debt Monthly debt payments divided by income (0 to 1) light, moderate, heavy
history Years of credit history short, long

Step 2: the rules

Each rule has one number: the risk score it recommends. A Sugeno system averages those numbers weighted by how strongly each rule fires. We use the product for AND, which gives smoother results than min.

Rule IF THEN risk
1 income high AND debt light 10
2 income high AND debt moderate 25
3 income medium AND debt light 20
4 income medium AND debt moderate 45
5 income low AND debt moderate 70
6 debt heavy 85
7 income low AND debt light 50
8 history short AND income low 80
9 history long AND debt light 15

Sugeno risk scoring

Inputs Income, debt, history
Rules Each gives a risk number
Weighted average Strength times risk
Score 0 safe to 100 risky

No curve to integrate: fast and simple

1 / 2

Step 3: the scorer

Python Sugeno loan risk scorer

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Ada (high income, light debt, long history) gets a low score. Eve has a high income but heavy debt, and rule 6 pulls her score up. Cara sits between low and medium income and between light and moderate debt, so her score is a blend of several rules.

Step 4: sanity checks with sensitivity analysis

A scorer must behave sensibly when one input changes and the others stay put. For risk: more income should never raise the risk, and more debt should never lower it. Sweep one input at a time and test the direction.

Python Monotonicity checks

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

If a check fails, read the sweep to find where the risk reverses, then look at the rules that fire in that region. Reversals usually come from a rule whose number does not fit its neighbors, for example a "moderate debt" rule that recommends a lower risk than a "light debt" rule at the same income.

Step 5: explain each decision

An applicant (or a regulator) can ask why the score is what it is. The most useful answer lists the rules with the largest contribution, which is each rule's weight times how far its risk number is from the overall score.

Python Top reasons for an applicant's score

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The weights sum to 100 percent. If a rule with a 60 percent weight recommends 45 while another with 40 percent recommends 70, the final score is a sensible blend. This kind of printout is what makes fuzzy scoring easy to defend in a review.

Step 6: from score to decision

The scorer outputs a risk, not a yes or no. The business decides thresholds, for example: below 30 approve, 30 to 60 send to manual review, above 60 decline. A graded band with a human review zone is safer than a single hard cutoff, and it is easy to audit.

Things to keep in mind

  • Fairness. Do not use inputs that act as proxies for protected attributes. Test the scorer on groups of applicants and compare outcomes.
  • Calibration. A risk number of 45 should mean something. Compare scores with real repayment data and adjust rules.
  • Governance. Keep the rule table under version control and record every change.

Extensions

  1. Add an employment input (months in current job) and two new rules.
  2. Replace the product with min for AND and compare the surfaces.
  3. Tune the rule outputs with a small optimization against labelled data, as in neuro-fuzzy learning.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. How does a Sugeno system combine rule outputs?

    Sugeno divides the sum of strength times output by the sum of strengths.
  2. 2. Why might a bank prefer graded risk scoring over a hard cutoff?

    Graded scoring prevents applicants just on either side of a threshold from receiving very different treatment.
  3. 3. What does a monotonicity check verify?

    It checks, for example, that risk never rises when income rises with everything else fixed.
  4. 4. Which statement about this project's rules is true?

    The thresholds are invented; real scoring needs validation, bias monitoring and governance.

Summary

  • A Sugeno scorer averages rule risk numbers weighted by firing strength, using product for AND.
  • Graded scores avoid cliff edges between near-identical applicants.
  • Sweep each input to verify monotonic behavior before trusting a rule base.
  • Rule-weight printouts give transparent per-applicant explanations.
  • Real systems add validation, fairness testing, calibration and governance.

Next: Practice Problems