CoolFace
Apppublic

rshewatkar/ship_co2-emission-predictor

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes
App README

๐Ÿšข Ship COโ‚‚ Emission Prediction

๐Ÿ“Œ Project Overview

This project predicts COโ‚‚ emissions of ships based on key operational and fuel-related parameters such as engine efficiency, fuel consumption, distance, ship type, and fuel type.

The objective is to build a production-ready machine learning pipeline and deploy it using an interactive Streamlit web application.


๐Ÿš€ Live Demo

๐Ÿ‘‰ [Click Here to Try the App](https://huggingface.co/spaces/rshewatkar/ship_co2-emission-predictor)

Deployed on Hugging Face Spaces โ€” No installation required!

๐ŸŽฏ Problem Statement

The shipping industry is a major contributor to global carbon emissions. Predicting COโ‚‚ emissions helps in:

  • โ€”๐ŸŒฑ Monitoring environmental impact
  • โ€”โš™๏ธ Optimizing fuel efficiency
  • โ€”๐Ÿšข Supporting sustainable shipping operations

๐Ÿ› ๏ธ Tech Stack

  • โ€”Language: Python
  • โ€”Libraries: pandas, numpy, scikit-learn, joblib
  • โ€”Model: Random Forest Regressor
  • โ€”Visualization/UI: Streamlit
  • โ€”Deployment: Hugging Face Spaces

โš™๏ธ Features Used

  • โ€”Engine Efficiency
  • โ€”Fuel Consumption
  • โ€”Distance
  • โ€”Ship Type
  • โ€”Fuel Type

๐Ÿง  ML Pipeline

This project uses a scikit-learn Pipeline to ensure robust and consistent predictions:

  • โ€”๐Ÿ”น Data preprocessing using ColumnTransformer
  • โ€”StandardScaler for numerical features
  • โ€”OneHotEncoder for categorical features
  • โ€”๐Ÿ”น Model training using Random Forest Regressor
  • โ€”๐Ÿ”น Entire pipeline saved using joblib

โœ… This approach prevents:

  • โ€”Feature mismatch errors
  • โ€”Encoding inconsistencies
  • โ€”Deployment failures

๐Ÿ“Š Model Performance

  • โ€”Rยฒ Score: 0.9951
  • โ€”RMSE: 1012.98

๐Ÿ“ˆ The model explains 99.51% variance, indicating very high prediction accuracy.


๐Ÿš€ Deployment

The model is deployed using Streamlit on Hugging Face Spaces.

App Features:

  • โ€”๐ŸŽš๏ธ Interactive sliders for numeric inputs
  • โ€”๐Ÿ“‹ Dropdown selection for ship and fuel type
  • โ€”โšก Real-time COโ‚‚ emission prediction

๐Ÿ–ฅ๏ธ How to Run Locally

1๏ธโƒฃ Clone the repository

bash
git clone <your-repo-link>
cd Ship_Co2_Emission_Prediction

2๏ธโƒฃ Create virtual environment

bash
conda create -n ml_env python=3.10
conda activate ml_env

3๏ธโƒฃ Install dependencies

bash
pip install -r requirements.txt

4๏ธโƒฃ Train the model

bash
python src/train.py

5๏ธโƒฃ Run the Streamlit app

bash
streamlit run app.py

๐Ÿ“ Project Structure

bash
Ship_Co2_Emission_Prediction/
โ”‚
โ”œโ”€โ”€ app.py                         # Main Streamlit app (UI + model inference)
โ”œโ”€โ”€ model.pkl                      # Trained ML pipeline (preprocessing + model)
โ”œโ”€โ”€ requirements.txt               # Python dependencies for reproducibility
โ”œโ”€โ”€ Dockerfile                     # Container setup for deployment (optional production setup)
โ”œโ”€โ”€ README.md                      
โ”œโ”€โ”€ LICENSE                        
โ”‚
โ”œโ”€โ”€ Ship_Co2_Emission_Prediction_project.ipynb   # Jupyter notebook for EDA & experimentation
โ”‚
โ”œโ”€โ”€ data/
โ”‚   โ””โ”€โ”€ ship_fuel_efficiency.csv   # Dataset used for training the model
โ”‚
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ train.py                   # Script to train ML pipeline and save model.pkl
โ”‚   โ”œโ”€โ”€ preprocess.py              # Preprocessing logic (ColumnTransformer setup)
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ __pycache__/               # Python cache files 
โ”‚
โ”œโ”€โ”€ .github/
โ”‚   โ””โ”€โ”€ workflows/
โ”‚       โ””โ”€โ”€ sync-to-hub.yml        # GitHub Actions workflow for deployment/automation
โ”‚
โ””โ”€โ”€ __pycache__/                   # Cache files generated by Python

๐Ÿ‘ค Author

Rahul Shewatkar

![GitHub](https://github.com/rshewatkar) ![HuggingFace](https://huggingface.co/rshewatkar) ![LinkedIn](https://www.linkedin.com/in/rahul-shewatkar-ml-engineer/)