AI Carbon Footprint Calculator - Predict Your CO2 Emissions Using Machine Learning
Back to ProjectMake sure you have the following installed on your system before proceeding:
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
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
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.
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.
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:
data/carbon_emission_cleaned.csvmodels/ folderAfter running the notebook, check that the models/ folder contains these files:
carbon_model.pkl - Trained regression modelscaler.pkl - StandardScaler for feature normalizationkmeans_model.pkl - KMeans clustering modelcluster_labels.pkl - Cluster name mappingsfeature_names.pkl - Feature list used during trainingle_Body_Type.pkl, le_Diet.pkl, and other le_*.pkl files - Label encoders for categorical columnsstreamlit 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.
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.
pip install --upgrade pippip install kaleidodata/ folder with the exact name carbon_emission.csvpip install xgboost --no-cache-dirOur team is here to assist you with installation and setup.