How muhammaduzair17/co2_emission_project works
Project type and purpose
• This is a lightweight, single-page full-stack web application built with Streamlit.
• It loads a pre-trained Linear Regression model (co2_emission_model.pkl) and processes user inputs (engine capacity, fuel type, vehicle age, etc.) to predict CO₂ emissions.
• The goal is to educate users and inform policymakers by providing an interactive CO₂ emission estimator for Pakistani automobiles.
File structure
• Top-level directories/files:
• .devcontainer/ – Development container config (VS Code Remote-Containers)
• CO2_Emission/ – Core application folder
– co2_app.py – Streamlit application entrypoint
– co2_emission_model.pkl – Serialized regression model
– co2_emission_model.ipynb – Notebook used for model development/training
– pakwheels_pakistan_automobile_dataset.csv – Raw data snapshot
– requirements.txt – Python dependencies
• README.md – Project overview and run instructions
• No separate “frontend” or “backend” folders; the Streamlit script handles both UI rendering and business logic in one process.
• Devcontainer indicates the recommended development environment but is not part of runtime deployment.
Insights from the README
• Confirms use of Streamlit for UI, Linear Regression for predictions, and a static CSV used for initial model training.
• No external databases or microservices; it’s a standalone Python service that serves HTTP via Streamlit’s built-in server.
Main components
a. User Interface
• Web Browser (end-user)
b. Application Server
• Streamlit App (co2_app.py) running in a Python runtime (inside a container or virtual environment)
c. Model & Data
• Serialized Model File (co2_emission_model.pkl)
• CSV Dataset (pakwheels_pakistan_automobile_dataset.csv) – used only offline/training
• .devcontainer configuration
Relationships and interactions
• User opens the Streamlit UI → submits vehicle specs
• Streamlit app loads at startup:
• Loads co2_emission_model.pkl into memory
• (Optionally) reads CSV if needed for dropdown values or stats
• On each form submission, the app invokes the regression model to compute emission → renders result on UI
• All operations happen in-process; no external API calls or databases
Architectural patterns or design principles
• Single-page reactive UI pattern via Streamlit
• In-memory computation: model and data loaded once at startup for low-latency predictions
• Containerized dev environment (via .devcontainer) to ensure reproducible builds