Technical explainer

Under the Hood

CorpCred turns a company's financial statements into a credit rating with a machine-learning model trained on thousands of real agency ratings. Here's exactly how it works — the data, the modelling, and the math that runs when you press Get credit rating.

UC Davis · ECS 171 research projectSource & paper
The problem

Credit ratings, learned from data

A corporate credit rating summarises how likely a company is to repay its debt. Traditionally these are produced by analysts through a process that is slow, expensive, and subjective. The goal of this project was to ask a simpler question: can a model reproduce those ratings from financial ratios alone?

The answer is largely yes — and the value isn't just the prediction, but the transparency. A tree-based model can tell you which financial metrics moved the rating, something a black-box system cannot.

The dataset

Real ratings from real agencies

The model learns from a public dataset of corporate credit ratings issued by Moody's, Standard & Poor's, and Fitch — each paired with the issuer's reported financial ratios.

7,805
Rated filings
1,377
Corporations
12
Sectors
25
Attributes
Label engineering

From 23 notches to 5 bands

Agencies use 20+ fine-grained notches (AAA, AA+, AA, …). Predicting all of them is noisy and many have only a handful of examples. Collapsing them into five credit bands made the problem tractable — and was the single biggest driver of accuracy in the study.

AAA / AAAAA, AA+, AA, AA−class 0
AA+, A, A−class 1
BBBBBB+, BBB, BBB−class 2
BBBB+, BB, BB−class 3
B or belowB, CCC, CC, C, D …class 4
The pipeline

From filing to rating

  1. 01Collect & label

    7,805 agency-rated filings (Moody's, S&P, Fitch) joined with the issuer's financial ratios from public statements.

  2. 02Reduce 23 → 5 classes

    The 23 raw notches are collapsed into five credit bands. This single step drove the largest accuracy gain in the study.

  3. 03Clean & scale

    Non-predictive identifiers are dropped, missing values imputed, and every feature standardised to zero mean and unit variance.

  4. 04Train & compare

    Random Forest, KNN, and a neural network are tuned with grid search and cross-validation, then evaluated on a held-out test set.

  5. 05Export & serve

    The winning forest is serialised to JSON and runs inference directly in your browser session — no server round-trip to a model host.

Model selection

Three models, measured head-to-head

Each model was tuned with grid search and cross-validation, then scored on a held-out test set. The Random Forest came out ahead on accuracy and recall.

Random Forest

Best

Selected model

78.92%
Accuracy
77.91%
Precision
76.66%
Recall
78.9%
F1-score

K-Nearest Neighbors

Distance-based baseline

78.23%
Accuracy
78.86%
Precision
78.23%
Recall
78.15%
F1-score

Neural Network

Keras MLP (128→64→32)

74.05%
Accuracy
74.03%
Precision
74.05%
Recall
73.98%
F1-score

Tuning the Random Forest lifted accuracy from 49% to 79% — but most of that gain came from reducing the class count and cleaning the data, not from the hyperparameters themselves.

The production model

What's actually running

Random Forest
Algorithm
50
Decision trees
20
Max depth
19
Input features

A Random Forest is an ensemble of decision trees. Each tree is trained on a random slice of the data and a random subset of features, then asked to vote. Because the trees disagree in different ways, their majority vote is far more stable than any single tree — and resistant to overfitting.

What the model looks at

Feature importance

These are the model's own importance scores — how much each input contributes to its splits. Cash-flow-per-share metrics dominate, a reminder that liquidity, more than headline margins, separates credit tiers.

Operating Cash Flow / Share
20.1%
Free Cash Flow / Share
15.5%
Debt / Equity
5.5%
Long-term Debt / Capital
4.9%
Current Ratio
4.4%
Operating Margin
4.2%
CIK
4.0%
Return on Assets
3.9%
Investment Grade
3.8%
Pre-Tax Profit Margin
3.7%
Return on Investment
3.6%
Gross Margin
3.6%
EBIT Margin
3.6%
Return on Tangible Equity
3.5%
Asset Turnover
3.4%
SIC Code
3.3%
Return on Equity
3.2%
Net Profit Margin
2.9%
EBITDA Margin
2.7%
Inference

The model runs in your browser

The trained forest is exported from Python to a compact JSON file — every tree's split features, thresholds, and leaf votes — alongside the scaler's mean and variance. When you submit the calculator, a Next.js API route reproduces the exact scikit-learn pipeline in JavaScript:

  1. Standardise your 19 inputs using the saved scaler statistics.
  2. Drop each scaled vector down all 50 trees, following the learned thresholds to a leaf.
  3. Tally every tree's vote and return the majority class as the rating band.

Because everything is precomputed and the trees are shallow, the whole prediction completes in milliseconds — no GPU, no external model server.

See it in action

Run a company's financials through the model and get a rating with a risk breakdown in seconds.

Open the calculator

Metrics reported here are from the project's research evaluation on a held-out test set. CorpCred is an academic project for research and education and does not produce official credit ratings or investment advice.