rshewatkar/ship_co2-emission-predictor
๐ข 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
git clone <your-repo-link>
cd Ship_Co2_Emission_Prediction2๏ธโฃ Create virtual environment
conda create -n ml_env python=3.10
conda activate ml_env3๏ธโฃ Install dependencies
pip install -r requirements.txt4๏ธโฃ Train the model
python src/train.py5๏ธโฃ Run the Streamlit app
streamlit run app.py๐ Project Structure
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
  
