Used Car Price Predictor
A Random Forest model trained on ~17k used-car listings.
About this project
This is my first machine learning project. I built it to learn the end-to-end workflow: cleaning messy real-world data, engineering features, training a model, and honestly evaluating how well (or badly) it actually works.
The model is far from perfect - on cars it hasn't seen before, its typical prediction is off by about 14%, and it does noticeably worse on rare or luxury cars where there just isn't much training data. That's expected: the dataset is a noisy, scraped set of used-car listings, not curated appraisal data. I'd rather show the real numbers than pretend it's more accurate than it is - the goal here was learning the process, not shipping a production-grade pricing tool.
Accuracy vs. a naive baseline
The baseline just guesses the median training price for every car, regardless of its specs. Any real model needs to beat that by a wide margin to be worth anything.
| Metric | Baseline (median guess) | This model (Random Forest) |
|---|---|---|
| Mean Absolute Error | $11,253 | $4,168 |
| Root Mean Squared Error | $17,572 | $9,214 |
| R² (variance explained) | -0.0574 | 0.7092 |
| Median % error | 50.11% | 14.06% |
Evaluated on a held-out test set of 3,436 cars the model never trained on (13,740 used for training).
What the plots say
Each dot is one test car. Points on the dashed line would be perfect predictions. Most cars cluster reasonably close to it, but the spread widens a lot at higher prices - the model gets shakier the more expensive (and rarer) the car is.
Residual = actual price - predicted price. Points above zero mean the model underpriced the car; below zero means it overpriced it. Errors grow with price, which is normal for this kind of skewed data.
Which inputs the Random Forest actually leaned on most. Production year, mileage, and engine specs dominate - roughly what you'd expect for used-car pricing.
Average error broken down by price bracket, with the number of test cars in each (n). Error climbs sharply for the $100k+ segment - there are only a handful of examples that expensive in the whole dataset, so the model has barely seen that territory.