Documentation

Installation Guide

AI Carbon Footprint Calculator - Predict Your CO2 Emissions Using Machine Learning

Step-by-step Setup Verified Instructions Chat Support
Back to Project
Complete Guide

Installation Guide - AI Carbon Footprint Calculator

Prerequisites

Make sure you have the following installed on your system before proceeding:

  • Python 3.10 or higher
  • pip (Python package manager)
  • Jupyter Notebook or JupyterLab
  • A modern web browser (Chrome, Firefox, or Edge)
  • Git (optional, for cloning)

Step 1: Download and Extract the Project

Download the project ZIP file from CodeAj Marketplace and extract it to your preferred location. Open a terminal or command prompt and navigate to the project directory.

cd carbon-footprint-calculator

Step 2: Create a Virtual Environment

Creating a virtual environment keeps the project dependencies isolated from your system Python installation.

python -m venv venv

Activate the virtual environment:

Windows:

venv\Scripts\activate

macOS / Linux:

source venv/bin/activate

Step 3: Install Dependencies

Install all required Python packages using the included requirements file.

pip install -r requirements.txt

This installs Streamlit, Pandas, NumPy, Scikit-learn, XGBoost, Plotly, Matplotlib, Seaborn, FPDF2, Joblib, Jupyter Notebook, ipykernel, and Kaleido.

Step 4: Download the Dataset

Go to the Kaggle dataset page and download the CSV file:

https://www.kaggle.com/datasets/dumanmesut/individual-carbon-footprint-calculation

Place the downloaded CSV file inside the data/ folder and rename it to carbon_emission.csv if it has a different name.

Step 5: Run the Model Training Notebook

Launch Jupyter Notebook and open the training notebook.

jupyter notebook notebooks/model_training.ipynb

Run all cells from top to bottom using Cell > Run All or press Shift + Enter on each cell sequentially. The notebook performs the following operations:

  • Cleans the raw dataset by filling Vehicle Type blanks, parsing Recycling and Cooking_With list-format columns, and one-hot encoding them
  • Saves the cleaned data as data/carbon_emission_cleaned.csv
  • Generates EDA visualizations including histograms, correlation heatmaps, bar charts, and scatter plots
  • Engineers new features: Total_Screen_Time, Waste_Score, Green_Score, Travel_Impact, Shopping_Impact
  • Label encodes categorical columns and saves each encoder as a pickle file
  • Scales numeric features and saves the StandardScaler
  • Trains Random Forest, XGBoost, and Linear Regression models
  • Evaluates all models using R-squared, MAE, RMSE, and MAPE metrics
  • Runs KMeans clustering to create four user segments
  • Exports the best model and all artifacts to the models/ folder

Step 6: Verify Model Files

After running the notebook, check that the models/ folder contains these files:

  • carbon_model.pkl - Trained regression model
  • scaler.pkl - StandardScaler for feature normalization
  • kmeans_model.pkl - KMeans clustering model
  • cluster_labels.pkl - Cluster name mappings
  • feature_names.pkl - Feature list used during training
  • le_Body_Type.pkl, le_Diet.pkl, and other le_*.pkl files - Label encoders for categorical columns

Step 7: Launch the Streamlit Application

streamlit run app/app.py

The application will start and open automatically in your web browser at http://localhost:8501. If it does not open automatically, copy and paste the URL from the terminal output into your browser.

Step 8: Using the Application

Fill in all the input fields in the sidebar across five sections: Personal, Home, Transport, Lifestyle, and Digital and Waste. Click the Submit button. The main area will display your predicted annual carbon footprint in kilograms of CO2, along with a letter grade, user segment, and comparison against the dataset average. Explore the four dashboard tabs for detailed visualizations. Scroll down to view personalized recommendations and download the PDF report.

Troubleshooting

  • If you see a "models not found" error, make sure you have run the Jupyter notebook completely before launching the Streamlit app.
  • If package installation fails, try upgrading pip first: pip install --upgrade pip
  • If Plotly charts do not render, install Kaleido separately: pip install kaleido
  • If the dataset fails to load, verify that the CSV file is in the data/ folder with the exact name carbon_emission.csv
  • For any XGBoost installation issues on Windows, try: pip install xgboost --no-cache-dir

Need Help?

Our team is here to assist you with installation and setup.

Chat with Us
Chat with us