Documentation · v2.0.0

Model cards & API

What each model is, what it was measured at, where it is weak, and how to call it. Numbers on this page come from held-out evaluation runs, not from aspiration.

Demo flow

Five minutes, in this order. Each step is designed to show that a real model is on the other end.

  1. Start at the landing page. The pill at the top calls /api/health, which loads all three models and runs a real inference through each. The millisecond timings are measured per request.
  2. Open Sell-out and set Open to 0. The forecast collapses toward zero. No formula was told to do that — a closed store sells nothing, and the model learned it from Rossmann's history.
  3. Open Loan risk and drag on-time payments. Risk moves sharply. Now drag credit score across its whole range: almost nothing happens. That is the honest finding — on this dataset credit score correlates +0.002 with the target.
  4. Open Campaign. Three models score the same input side by side with individual latencies. Uplift is compared against what that store and item really sold.
  5. Check the manifest. Every deployed graph reports its measured drift from the original model it was converted from.

Loan delinquency · model card

FieldValue
ModelRandomForestClassifier — 160 trees, max_depth 12, min_samples_leaf 25, class_weight balanced
Training dataapproach_train.csv — 116,058 rows, 30 features after encoding
Targetmx — inverted: 1 = good loan, 0 = delinquent
Class balance69.0% mx=1 / 31.0% mx=0
Held-out AUC0.7209 (25% split, stratified, seed 42)
Majority baselineAUC 0.500 · accuracy 0.690
Accuracy0.664 — below the 0.690 majority baseline, by design
Why accuracy is below the baseline, and why that is correct.

Predicting "good loan" for everyone scores 69% accuracy and catches zero delinquencies. class_weight='balanced' makes the model pay for missing the minority class, which costs raw accuracy and buys ranking ability — AUC 0.72 versus 0.50. For triage, ranking is the useful property. Anyone quoting accuracy alone on a 69/31 split is quoting the baseline.

Where the signal is

FeatureImportanceReading
total_on_time_payments0.364Payment history
total_late_payments0.262Payment history
current_dpd0.136Payment history
avg_payment_delay0.105Payment history
Annual Income0.016Marginal
borrower_credit_score0.015Effectively unused

Payment history is 87% of total importance. Credit score is 1.5%, and its raw correlation with the target is +0.0018. On a real lending book credit score is the canonical predictor of delinquency, so a near-zero correlation is a strong signal that this dataset is synthetic or scrambled in its demographic columns. Treat the model as a demonstration of a working pipeline, not as a credit policy.

Known defects fixed in this version

Campaign performance · model card

FieldValue
ModelsCatBoostRegressor · LGBMRegressor · Ridge — all three deployed
TaskPredict units sold for a store/item on a date
Featuresstore, item, month, day, dayofweek, dayofyear, weekofyear
Historytrain2.csv — 913,001 rows, 2013-01-01 → 2017-12-31, 10 stores × 50 items
Baseline sourceMeasured per store/item, seasonal by month where available
What was removed, and why.

The previous version reported a "conversion probability" and an uplift built from store_id % 10, item_id % 20 and 0.8 + (store_id % 7) * 0.1, with source comments reading "simulate store quality impact" and "simulate item appeal". These are arbitrary arithmetic on identifiers — store 8 scored above store 7 because 8 % 7 is 1 — and they were presented in the UI as model output.

Uplift is now measured against the real historical mean for that store and item. Conversion probability is gone: no dataset in this project contains impressions, clicks or conversions, so there is nothing to estimate it from, and a number with no source is worse than a blank.

The decision layer

Channel selection is a documented rule, not a prediction, and the UI labels it as one. Uplift bands: high ≥ +15%, moderate 0–15%, low < 0%. Volume bands: high ≥ 60 units, moderate 25–60, low < 25. The pair selects a channel; cost per contact is a configurable planning input in prism/campaign_rules.py. Separating the model output from the business rule is the point — both are legitimate, and conflating them is what made the old version misleading.

Sell-out forecasting · model card

FieldValue
ModelXGBRegressor, selected by RandomizedSearchCV (10 candidates, 3-fold)
Tuned paramsmax_depth 10 · learning_rate 0.2 · min_child_weight 5 · gamma 0.1 · colsample_bytree 0.7
TaskDaily store sales (Rossmann)
Features17 — promo, competition, calendar, store type, assortment
Validation splitTime-based: train < 2015-06-19, test ≥ 2015-06-19

A time-based split is the right call for a forecasting task — a random split lets the model see the future of the series it is predicting. Held-out error was not recorded in the shipped artifact, so no accuracy figure is quoted here rather than one being invented. Recovering it needs a rerun of the training script.

A closed store forecasts about −0.3, and the UI shows it.

Sales cannot be negative. This is an unclamped regressor: nothing constrains its output to be positive, so with Open = 0 it lands slightly past zero instead of exactly on it (measured: −0.3 closed against 89.0 open with a promotion). The raw value is displayed rather than clipped, because a zero forced by the interface would look identical whether the model had learned anything or not. The gap between −0.3 and 89.0 is the model demonstrating it learned what closing a store does.

On TabFM

This repository is titled "Harnessing TabFM and AI", and no tabular foundation model is used.

The loan artifact ships as models/tabpfn.pkl and loads as sklearn.ensemble.RandomForestClassifier. The code that produced it trains a RandomForest as a fallback and saves it under that filename; the tabpfn package is imported nowhere that runs. Earlier documentation stated "TabPFN foundation model integration" as fact. That claim was not true, and it has been corrected rather than carried forward.

TabPFN was evaluated for this deployment and ruled out on a hard constraint: it requires PyTorch (~2 GB installed) against a 250 MB serverless budget. It cannot serve real-time predictions on this URL under any arrangement — roughly 8× over budget before the model weights are counted.

If the worklet brief requires a tabular foundation model, the honest options are to run TabPFN offline and publish the comparison as a result, or to move inference to a host with room for PyTorch. What is not an option is leaving a RandomForest named tabpfn.pkl and describing it as a foundation model. The RandomForest is a reasonable choice here and needs no cover story: AUC 0.72 on 116k rows, 4.4 MB, single-digit millisecond inference.

API reference

All prediction endpoints accept form-encoded or JSON bodies and return JSON.

# Loan — any omitted field falls back to its training median
curl -X POST https://samsung-dashboard-worklet-8.vercel.app/api/loan/predict \
  -H 'Content-Type: application/json' \
  -d '{"borrower_credit_score": 610, "current_dpd": 45,
       "total_late_payments": 14, "total_on_time_payments": 3}'

# Campaign — compare=1 scores all three models on the same input
curl -X POST https://samsung-dashboard-worklet-8.vercel.app/api/campaign/predict \
  -d 'store=3&item=12&month=12&day=20&model=catboost&compare=1'

# Sell-out
curl -X POST https://samsung-dashboard-worklet-8.vercel.app/api/sellout/predict \
  -d 'Open=1&Promo=1&DayOfWeek=6&StoreType=d&Assortment=c&WeekOfYear=50'

# Batch — CSV in, CSV out, up to 2000 rows
curl -X POST https://samsung-dashboard-worklet-8.vercel.app/api/loan/batch \
  -F 'file=@applications.csv' -o scored.csv

# Health — loads every model and runs a real inference through each
curl https://samsung-dashboard-worklet-8.vercel.app/api/health

# Manifest — measured drift of each deployed graph vs its original
curl https://samsung-dashboard-worklet-8.vercel.app/api/models

Response shape

{
  "probability_of_default": 0.5281,
  "risk_band": "Critical",
  "prediction": "Delinquent",
  "drivers": [
    {"feature": "total_on_time_payments", "value": 3.0, "median": 9.0,
     "importance": 0.364, "direction": "raises risk"}
  ],
  "inference_ms": 1.84,
  "model": {"type": "RandomForestClassifier", "n_estimators": 160, "max_depth": 12}
}

Limitations