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.
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.
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.
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.
From filing to rating
01Collect & label
7,805 agency-rated filings (Moody's, S&P, Fitch) joined with the issuer's financial ratios from public statements.
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.
03Clean & scale
Non-predictive identifiers are dropped, missing values imputed, and every feature standardised to zero mean and unit variance.
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.
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.
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
BestSelected model
K-Nearest Neighbors
Distance-based baseline
Neural Network
Keras MLP (128→64→32)
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.
What's actually running
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.
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.
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:
- Standardise your 19 inputs using the saved scaler statistics.
- Drop each scaled vector down all 50 trees, following the learned thresholds to a leaf.
- 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 calculatorMetrics 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.