🌱 Carbon Footprint & Sustainability Advisor
A comprehensive, AI-powered web application that helps users calculate their carbon footprint, assess their sustainability level, and receive personalized recommendations to reduce their environmental impact.
📋 Problem Statement
The Challenge
Climate change is one of the most pressing issues of our time. According to the IPCC, human activities have caused approximately 1.1°C of warming since the pre-industrial era. Individual actions matter, but many people don't understand their personal carbon footprint or how to reduce it.
The Solution
This application addresses the following real-world problems:
- Lack of Awareness: People don't know how their lifestyle choices affect the environment
- Complex Calculations: Carbon footprint calculations are mathematically complex and time-consuming
- Generic Advice: Existing tools provide one-size-fits-all recommendations
- No Progress Tracking: Users can't track their environmental impact over time
- No Personalization: No way to set goals and measure progress
Target Users
- Environmentally conscious individuals
- Sustainability enthusiasts
- Organizations looking to educate employees
- Students learning about climate change
- Anyone wanting to reduce their carbon footprint
🎯 Approach
Methodology
Data Collection & Generation
- Generate synthetic datasets based on EPA, IPCC guidelines
- Use real-world emission factors for accuracy
- Incorporate lifestyle survey data
Machine Learning Models
- Random Forest Regressor: Predict carbon footprint from lifestyle factors
- Gradient Boosting Classifier: Classify sustainability levels
- XGBoost Classifier: Predict goal achievement
Personalization Engine
- Analyze user inputs
- Generate personalized recommendations
- Track progress over time
User Experience
- Intuitive web interface
- Interactive visualizations
- Historical data tracking
- Secure authentication
Key Features
- ✅ User authentication (login/signup)
- ✅ Carbon footprint prediction
- ✅ Sustainability level assessment
- ✅ Personalized recommendations
- ✅ Historical data tracking
- ✅ Interactive visualizations
- ✅ Goal setting and tracking
- ✅ Comprehensive logging system
🛠️ Tech Stack
Core Technologies
| Technology | Version | Purpose |
|---|---|---|
| Python | 3.13+ | Programming Language |
| Streamlit | 1.40.2 | Web Framework |
| Pandas | 2.2.3 | Data Processing |
| NumPy | 1.26.4 | Numerical Computing |
| Scikit-learn | 1.6.1 | Machine Learning |
ML & AI Libraries
| Library | Version | Purpose |
|---|---|---|
| XGBoost | 2.1.3 | Gradient Boosting |
| LightGBM | 4.5.0 | Alternative Boosting |
Visualization
| Library | Version | Purpose |
|---|---|---|
| Plotly | 5.24.1 | Interactive Charts |
| Matplotlib | 3.10.0 | Static Visualization |
| Seaborn | 0.13.2 | Statistical Graphics |
Security & Utilities
| Library | Version | Purpose |
|---|---|---|
| bcrypt | 4.2.1 | Password Hashing |
| python-dotenv | 1.0.1 | Environment Variables |
| pytz | 2024.2 | Timezone Handling |
📁 Project Structure
hackathon1/
├── app.py # Main Streamlit application
├── auth.py # Authentication module
├── ml_models.py # ML models and predictions
├── credentials.json # User data storage
├── requirements.txt # Python dependencies
├── README.md # This file
├── model_details.md # Detailed model documentation
└── app.log # Application logs
🚀 Setup Instructions
Prerequisites
- Python 3.13 or higher
- pip package manager
Installation Steps
1. Clone or Download the Project
# clone repository
git clone https://github.com/aryaanchavan1-commits/carbon_footprint_and_sustainability_advisor.git
cd carbon_footprint_and_sustainability_advisor
2. Create Virtual Environment (Recommended)
# Windows
python -m venv venv
venv\Scripts\activate
# Linux/Mac
python3 -m venv venv
source venv/bin/activate
3. Install Dependencies
pip install -r requirements.txt
If you encounter issues with specific packages:
# Upgrade pip first
pip install --upgrade pip
# Install packages individually if needed
pip install streamlit==1.40.2
pip install scikit-learn==1.6.1
pip install pandas==2.2.3
pip install numpy==1.26.4
pip install plotly==5.24.1
pip install xgboost==2.1.3
pip install bcrypt==4.2.1
4. Run the Application
# Run with Streamlit
streamlit run app.py
# Or run with specific port
streamlit run app.py --server.port 8501
# Or run in browser automatically
streamlit run app.py --server.headless true
5. Access the Application
Open your browser and navigate to:
http://localhost:8501
📖 User Guide
Getting Started
Create an Account
- Click "Sign Up" tab
- Enter username and password
- Click "Sign Up"
Login
- Enter credentials
- Click "Login"
Make Your First Prediction
- Fill in lifestyle details
- Click "Calculate My Carbon Footprint"
- View results and recommendations
Features
🏠 Home Page
- Complete lifestyle assessment form
- View predictions and recommendations
- See real-time results
📜 History
- View all past predictions
- See carbon footprint trends
- Track progress over time
🤖 Model Details
- Learn about ML models
- View performance metrics
- Understand how predictions work
🔧 Configuration
Changing Port
streamlit run app.py --server.port 8080
Enabling Debug Mode
streamlit run app.py --debug
Environment Variables
Create a .env file:
PORT=8501
DEBUG=false
LOG_LEVEL=INFO
📊 Model Performance
Carbon Footprint Prediction
- R² Score: 0.95
- MAE: ~200 kg CO₂/year
- RMSE: ~260 kg CO₂/year
Sustainability Classification
- Accuracy: ~92%
- Precision: High across all classes
- Recall: High across all classes
Cross-Validation
- 5-Fold CV R²: 0.94 ± 0.02
🔐 Security
- Passwords are hashed using bcrypt
- User data is stored in JSON format
- Session management implemented
- Input validation on all forms
📝 Logging
The application includes comprehensive logging:
- Log File:
app.log - Log Levels: INFO, WARNING, ERROR
- Logged Events:
- User registration
- Login attempts
- Predictions made
- Errors and exceptions
View logs:
# Windows
type app.log
# Linux/Mac
cat app.log
🤝 Contributing
Contributions are welcome! Please feel free to:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
📄 License
MIT License - See LICENSE file for details.
🙏 Acknowledgments
- EPA (Environmental Protection Agency)
- IPCC (Intergovernmental Panel on Climate Change)
- Streamlit team
- Scikit-learn community
📞 Support
For issues or questions:
- Check the logs in
app.log - Review the model documentation in
model_details.md - Verify all dependencies are installed correctly
🔮 Future Enhancements
- Real Data Integration: Connect with real carbon footprint data
- Smart Device Integration: IoT sensor data
- Mobile App: React Native or Flutter
- API Development: RESTful API for developers
- Social Features: Community challenges
- Carbon Offsets: Integration with offset programs
- Multi-language Support: i18n implementation
📅 Version History
| Version | Date | Changes |
|---|---|---|
| 1.0.0 | 2026-02-21 | Initial release |
Built with ❤️ for a sustainable future
Built With
- python
- streamlit
Log in or sign up for Devpost to join the conversation.