Skip to content
All projects

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.

  1. 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.

  2. 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.

  3. 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.

  4. 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.

Predicted against actual price

Predicted against actual price on the test set. Saved notebook figure.

Scatter plot of predicted against actual price for the 2,000 test-set cars. The points cluster along an orange line of perfect prediction. Actual prices run from about $1,000 to $17,000.
Predicted against actual price on the test set. Saved notebook figure.

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

Results for Used Car Price Analysis & Prediction
GradeOfficial coursework result100/100
Linear regressionRMSE $989.82, MAE $790.65R² 0.877
KNN regression, k = 19RMSE $1,063.08, MAE $847.93R² 0.858
Mean-price baselineMAE $2,265.52RMSE $2,821.77
Six-feature KNN classifier, k = 38Test accuracy, with 76.65% mean cross-validation accuracy77.35%
Four-feature KNN classifier, k = 29Test accuracy74.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.