How omiiii1221/used-car-price-prediction works
Project Type and Purpose
• This is a full-stack, web-based Machine Learning application built with Flask.
• Purpose: Expose a Random Forest regression model over HTTP so end-users can enter car specs (year, KM driven, fuel type, etc.) in a browser form and receive a resale-price prediction.
File Structure
• Top-Level Files
– app.py: The Flask application (controller + entry point)
– rf_model.joblib: Serialized Random Forest model (inference artifact)
– cars24data_cleaned.xlsx: Raw dataset used during training
– used_car_Price_Prediction.ipynb: Jupyter notebook for exploratory analysis and model training
– requirements.txt: Dependency list
• Directories
– static/: CSS (style.css), JS or images served as static assets (client-side)
– templates/: Jinja2 HTML templates (view layer)
• Dev & Config
– .vscode/: Editor settings (not part of runtime)
README for Tech Stack & Workflow
• Backend: Python + Flask
• Modeling: scikit-learn (RandomForestRegressor), Pandas, NumPy
• Frontend: HTML/CSS via Jinja2 templates
• Runtime:
1. User opens form (GET /)
2. Submits specs (POST /predict)
3. app.py loads rf_model.joblib, preprocesses inputs (via Pandas), runs inference, returns rendered HTML
Main Components & Their Relationships
┌──────────────┐ ┌─────────────────┐ ┌───────────────────┐
│ Web Client │ HTTP │ Flask Server │ In-Process │ ML Inference │
│ (Browser UI) │ ─────► │ (app.py) │ ─────────► │ (joblib+Pandas) │
└──────────────┘ ◀───── └─────────────────┘ ◀─────────┘ │
▲ │ │ │
│ Static Assets │ └──────────┬────────────────────┘
│ (CSS, JS, Images) │ │
│ │ ┌────────▼─────────┐
│ └──────────────►│ Data Store │
│ │ (rf_model.joblib,│
│ │ cars24data*.xlsx)│
│ └──────────────────┘
• Flow:
a. Browser requests HTML form → Flask serves Jinja2 template + static CSS
b. User submits form → Flask route receives POST → Pandas transforms data → RandomForest.predict() → Flask returns result page
c. Model and data live on disk; loaded at startup or per-request
Architectural Patterns & Design Principles
• Monolithic, MVC-style:
• Model: rf_model.joblib + preprocessing code
• View: Jinja2 templates + static assets
• Controller: Flask routes in app.py
• Layered Design: Presentation → Application Logic → ML Inference → Data
• Separation of Concerns: Static vs. dynamic content, training vs. runtime inference