Skip to content

A web app that predicts vehicle CO₂ emissions using machine learning based on fuel and engine specs. It includes SHAP and LIME explainability for transparent, interpretable predictions.

grootisgroot29/C02_EmissionPredictor

Repository files navigation

CO₂ Emission Predictor WebApp

This is a machine learning-powered web application that predicts CO₂ emissions of vehicles based on technical specifications. It also provides explainable AI features using SHAP and LIME to interpret predictions.

Dataset

Dataset: MY1995-2023 Fuel Consumption Ratings
Contains fuel consumption data and CO₂ emissions for vehicles sold in Canada.

Features used:

  • EngineSize_L
  • Cylinders
  • FuelConsCity_L100km
  • FuelConsHwy_L100km
  • Comb_L100km
  • Comb_mpg
  • FuelType

Target: CO2Emission_g_km

Model Pipeline

  • Preprocessing using StandardScaler and OneHotEncoder
  • Model: RandomForestRegressor with 100 estimators
  • Train-test split: 80/20
  • Pipeline created using scikit-learn's Pipeline and ColumnTransformer
  • Serialized using pickle to model_pipeline.pkl

Web Interface (Streamlit)

  • Interactive UI built with Streamlit
  • Users can select vehicle specs (Make, Model, Engine Size, etc.)
  • Predicts CO₂ emissions upon input
  • Provides model explainability via SHAP and LIME
  • Visuals generated using matplotlib

Explainability Features

  • SHAP: Shows global feature importance using Shapley values
  • LIME: Explains individual predictions with a local surrogate model
  • PDP vs ICE: PDP shows average effects, ICE reveals individual variation

Deployment

The application is deployed on Render and is accessible through a live web URL.

Files Included

  • app.py – Streamlit web application
  • model_pipeline.pkl – Serialized ML pipeline
  • MY1995-2023-Fuel-Consumption-Ratings.csv – Dataset
  • X_test.csv – Sample test data

Run Locally

Step 1: Install requirements
pip install streamlit pandas scikit-learn shap lime matplotlib

Step 2: Run the app streamlit run app.py

Summary

This project demonstrates how to combine machine learning with explainable AI to create transparent and user-friendly predictive systems. By using SHAP, LIME, PDP, and ICE, the app offers valuable insight into model behavior and fosters trust in predictions.

About

A web app that predicts vehicle CO₂ emissions using machine learning based on fuel and engine specs. It includes SHAP and LIME explainability for transparent, interpretable predictions.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages