Car Price Guesser
Purpose
This project is a learning exercise for building machine learning models. The goal is to predict the price of a car based on its attributes (e.g., Year, Mileage, Brand, Model, etc.) using a dataset of New York cars.
Getting Started
This project uses uv for dependency management.
Prerequisites
- Python 3.14+
uvinstalled
Installation
- Clone the repository (if applicable).
- Install dependencies:
uv sync
Usage
1. Train the Model
To train the machine learning model (Linear Regression baseline):
uv run train_model.py
This script will:
- Load the
New_York_cars.csvdataset. - Preprocess the data (handle missing values, encode categorical features).
- Train the model.
- Save the trained model to
car_price_model.joblib. - Output performance metrics (MSE, R2 Score).
2. Make Predictions
You can use the trained model to guess the price of a car.
Interactive Mode:
uv run predict.py
Follow the prompts to enter car details.
Command Line Arguments:
uv run predict.py <Year> <Mileage> <Brand>
Example:
uv run predict.py 2020 50000 Toyota
Random Row Verification: To pick a random car from the dataset and compare the model's prediction against the actual price:
uv run predict.py --random