Overview
sc.
The model, in one number

Used BMW & Audi prices, predicted within 6.5%.

A LightGBM model trained on 29,988 real Turkish listings, served behind a FastAPI backend on Railway. Every number below comes from leak-free 5-fold out-of-fold evaluation — not a lucky holdout — and the same dataset that drives the reports.

6.49%
MAPE · OOF
mean abs. % error
0.9745
R² · OOF
variance explained
₺110K
MAE
₺75K median abs. error
29,988
listings
deduped · TR-plated
typical error vs. the comparable median — MAE (₺)
Comparable median · baseline
₺191K
LightGBM · TF-IDF+SVD · the model
₺110K

The model's mean error is 43% lower than the comparable median (₺81K per car). Beyond model and year, the gap is closed mostly by mileage, age, and damage.

[01]

How it's served

Two tracks. Offline, listings become a DuckDB file and a serving bundle in object storage. Online, FastAPI loads that bundle into memory at boot — the raw 30K rows never leave the backend.

build · offline
Scraped listings
4 snapshots · Jan–Jun 2026
45,159
→
cars.duckdb
deduped · TR-plated · read-only
Railway Volume
→
LightGBM train
TF-IDF+SVD · log1p target
5-fold out-of-fold
→
S3 bundle
…svd.txt + encoders.pkl
Railway S3
serve · online · request flow
Next.js client
sadikcoban.com
Proxy API
→
FastAPI v2.1.0
uvicorn · Railway
APIRouter
→
lgb_service
bundle in memory · thread-safe
boot-loaded
→
predict
expm1 · 90% scale interval + N/10
scale + hit
POST /api/predictGET /api/bi/meta · /agg

Bundle: {model, scale_model, comparables, tfidf, cat_maps, feat_cols} — 9 categoricals + 14 numerics + free-text model & series → TF-IDF → TruncatedSVD (170 dims), paired with the adaptive scale model and comparable counts. Training and serving share the exact same preprocessing.

[02]

Scores

Three model variants share one leak-free 5-fold split, benchmarked against a comparable-median baseline on the same folds.

model comparison · 5-fold out-of-fold
VariantMAPER²MAE ₺MedAE ₺RMSE ₺
LightGBM · TF-IDF+SVD · served6.49%0.9745109,77675,320176,225
CatBoost · TF-IDF+SVD ★6.44%0.9745110,08574,927176,130
CatBoost · native6.58%0.9739112,92577,660178,312
Comparable median · laddered11.20%0.9235191,224130,000305,050

★ wins on MAPE alone; both SVD variants tie in practice, and deterministic CPU training selects LightGBM (258 trees). Vehicle-adaptive scale intervals reach 90.1% OOF coverage (90.3% with zero comparables; median width 24.7%) and hold at 86.8% on 8,889 unseen forward listings.

[03]

What the data actually says

Core findings that change how you read an asking price.

01
Brand adds no standalone signal
Adding brand on top of series+model shifts MAE by just ₺1 — brand identity is already carried in the model name.
brand only8.80%
series+model6.49%
+ brand6.49%
Theil's U = 0.999 · model determines series & brand
02
Mileage & age within the same model
At the typical car (11 yrs, 181,000 km): +1 year aligns with −5.80% and +100k km with −14.83%.
km · +100k−14.83%
age · +1 yr−5.80%
hedonic OOF R² 0.961 · within one car model
03
Baseline collapses on rare cars
The comparable median matches 97.5% of listings in its exact cell; stepping down to all-years or global median multiplies the error.
model+year₺179K
all years₺559K
global₺1.10M
97.49% matched · 2.51% fallback
04
Scale model fixes rare-car coverage
A fixed margin drops to 70.7% coverage on cars with no comparables, whereas the vehicle-adaptive scale model holds 90.3%.
single · no comp.70.7%
scale · no comp.90.3%
input groups off ≥5 pts: fixed 18 · scale 0
[04]

Data & method

Real TR-registered used-car detail pages across 4 snapshots (2026-01-18 – 2026-06-27), deduplicated to one row per listing.

scrape → dedup
45,159 raw rows
29,988 listings
latest record per listing ID

The 15,171 excluded rows are repeat scrapes of the same ads. Deduplication runs before the 5-fold split so no listing straddles train and validation folds.

29,988
unique listings
45,159
raw rows
25 / 117
features / raw
₺1.55M
median price
17,896
BMW
12,092
Audi
target log1p(price)5-fold OOF · leak-freededup before splitP10–P90 ₺0.85M – ₺3.43Mhedonic + LOFO + SHAPscale interval + forward test
[05]

Stack & deep dives

FastAPIuvicornLightGBMCatBoostTreeSHAPTF-IDF+SVDDuckDBboto3 · S3RailwayNext.js