Skip to content

This project predicts used car prices using a feedforward neural network regression model implemented in PyTorch. Features include car age, mileage, and other attributes. The pipeline supports feature normalization, train/validation/test splitting, and visualization of training and validation loss curves.

License

Notifications You must be signed in to change notification settings

hurkanugur/Car-Price-Predictor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚗 Car Price Prediction with PyTorch

📖 Overview

This project predicts used car prices using a feedforward neural network regression model built in PyTorch.

  • 📊 Neural Network Regression Model with Batch Normalization and Dropout for better training stability and generalization
  • 🧩 Structured data preprocessing with numeric clipping, categorical encoding, and feature normalization
  • ⚖️ Mean Squared Error (MSE) as the loss function
  • 🧠 Adam optimizer for training
  • 🔀 Train/Validation/Test split for robust evaluation
  • 📈 Feature & target normalization using training statistics
  • 💾 Saving/loading trained model and preprocessing artifacts for inference
  • 🎨 Interactive Gradio Interface for real-time prediction

🖼️ Application Screenshot

Below is a preview of the Gradio Interface used for real-time prediction:

Application Screenshot


🧩 Libraries

  • PyTorch – model, training, and inference
  • pandas – data handling & preprocessing
  • scikit-learn – ColumnTransformer, standardization, one-hot encoding
  • matplotlib – plotting loss curves
  • pickle – saving/loading feature transformer, statistics and trained model
  • Gradio — interactive web interface for real-time model demos

⚙️ Requirements

  • Python 3.13+
  • Recommended editor: VS Code

📦 Installation

  • Clone the repository
git clone https://github.com/hurkanugur/Car-Price-Predictor.git
  • Navigate to the Car-Price-Predictor directory
cd Car_Price_Predictor
  • Install dependencies
pip install -r requirements.txt

🔧 Setup Python Environment in VS Code

  1. View → Command Palette → Python: Create Environment
  2. Choose Venv and your Python version
  3. Select requirements.txt to install dependencies
  4. Click OK

📂 Project Structure

assets/
└── app_screenshot.png           # Screenshot of the application

data/
└── car_price_dataset.csv        # Raw used car data

model/
├── car_price_model.pth          # Trained PyTorch model
├── feature_transformer.pkl      # Fitted preprocessing transformer
└── statistics.pkl               # Preprocessing stats

src/
├── config.py                    # Paths, hyperparameters, split ratios
├── dataset.py                   # Data loading & preprocessing
├── device_manager.py            # Selects and manages compute device
├── train.py                     # Training pipeline
├── inference.py                 # Inference pipeline
├── model.py                     # Neural network definition
└── visualize.py                 # Training/validation plots

main/
├── main_train.py                # Entry point for training
└── main_inference.py            # Entry point for inference

requirements.txt                 # Python dependencies

📂 Model Architecture

Input → Linear(256) → BatchNorm → ReLU → Dropout(0.2)
      → Linear(128) → BatchNorm → ReLU → Dropout(0.2)
      → Linear(64)  → BatchNorm → ReLU → Dropout(0.1)
      → Linear(1)   → Output

📂 Train the Model

Navigate to the project directory:

cd Car_Price_Predictor

Run the training script:

python -m main.main_train

or

python3 -m main.main_train

📂 Run Inference / Make Predictions

Navigate to the project directory:

cd Car_Price_Predictor

Run the app:

python -m main.main_inference

or

python3 -m main.main_inference

About

This project predicts used car prices using a feedforward neural network regression model implemented in PyTorch. Features include car age, mileage, and other attributes. The pipeline supports feature normalization, train/validation/test splitting, and visualization of training and validation loss curves.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages