Project 01Individual academic project
Used Car Price Analysis & Prediction
Exploratory analysis and price prediction on 10,000 used-car records, from bootstrap group comparisons to KNN classification and linear regression.
My role
Completed individually and graded 100/100.
Project overview
Problem
How much of a used car's price do its attributes explain, and can they predict both a price bracket and an exact price?
Objective
Explore how vehicle attributes relate to price, test group differences with resampling, and build classification and regression models that are judged against a simple baseline.
10,000 records
Used-car dataset with 12 columns, including price, Kaggle dataset (opens in a new tab)
Tech stack
Languages and tools
- Python
- Pandas
- NumPy
- scikit-learn
- Matplotlib
- Seaborn
Methods
- Exploratory data analysis
- Bootstrap resampling
- KNN classification
- Linear and KNN regression
- 10-fold cross-validation
Architecture and implementation
One Python notebook takes the data from exploration to two kinds of prediction. It splits the data 80/20 into 8,000 training and 2,000 test records.
Explore the data
Distributions and relationships for price, make year, engine capacity, fuel efficiency, and categorical attributes such as fuel type and transmission. Fuel efficiency is measured in kilometres per litre.
Compare groups
Mean-price differences between fuel types and between transmissions. The data is resampled with replacement 5,000 times to build 95% confidence intervals and recentred p-values.
Classify price brackets
Prices are split into three quantile brackets, and the price column is excluded from the inputs. KNN labels each car with the most common bracket among its k most similar training cars. KNN classifiers with six and with four features choose k from 1 to 50 by 10-fold cross-validation. The six features are engine capacity, make year, owner count, fuel efficiency, and two fuel-type indicators.
Predict exact prices
Linear regression on 19 encoded predictors and six-feature KNN regression, both measured against a training-mean baseline with R², RMSE, and MAE.
Outcomes and links
R² 0.877
Linear regression on the test set, with RMSE $989.82 against $2,821.77 for a mean-price baseline.
Notebook result
Results
| GradeOfficial coursework result | 100/100 |
|---|---|
| Linear regressionRMSE $989.82, MAE $790.65 | R² 0.877 |
| KNN regression, k = 19RMSE $1,063.08, MAE $847.93 | R² 0.858 |
| Mean-price baselineMAE $2,265.52 | RMSE $2,821.77 |
| Six-feature KNN classifier, k = 38Test accuracy, with 76.65% mean cross-validation accuracy | 77.35% |
| Four-feature KNN classifier, k = 29Test accuracy | 74.9% |
| Electric vs petrol, mean price95% bootstrap CI $2,775 to $3,145. Diesel vs petrol and automatic vs manual showed no significant difference. | +$2,959 |
The grade refers to the original coursework.
Takeaways and limits
- Linear regression cuts test RMSE by about 65% compared with predicting the mean price.
- Dropping fuel efficiency and the petrol indicator costs the classifier 2.45 points of test accuracy.
- Price-bracket thresholds were computed on the full dataset, and scaling was fitted before the cross-validation folds. Both remain open for a methodological revision.
- The results describe associations in this dataset, not causal effects or performance on current car listings.
