surahj/electricity-consumption-predictor
0
โก Electricity Consumption Predictor
A machine learning application that predicts daily electricity consumption based on various factors like temperature, day of the week, and special events.
๐ Live Demo

๐ Features
- Temperature-based predictions: Considers how temperature affects electricity usage
- Day of week analysis: Accounts for different consumption patterns on weekdays vs weekends
- Special events: Factors in holidays and major events
- Interactive interface: User-friendly Gradio web interface
- Model insights: Detailed explanation of prediction factors
๐ ๏ธ Technology Stack
- Machine Learning: scikit-learn (Linear Regression)
- Data Processing: pandas, numpy
- Web Interface: Gradio
- Model Persistence: joblib
๐๏ธ Project Structure
โโโ src/
โ โโโ app.py # Main Gradio application
โ โโโ model.py # ML model implementation
โ โโโ data_generator.py # Synthetic data generation
โโโ tests/
โ โโโ test_model.py # Model unit tests
โ โโโ test_app.py # App unit tests
โ โโโ test_integration.py # Integration tests
โโโ app.py # Hugging Face Spaces entry point
โโโ requirements.txt # Python dependencies
โโโ README.md # This file๐งช Usage
Local Development
- Clone the repository:
git clone https://github.com/YOUR_USERNAME/electricity-consumption-predictor.git
cd electricity-consumption-predictor- Install dependencies:
pip install -r requirements.txt- Run the application:
python app.py- Run tests:
pytest tests/Hugging Face Spaces
The app is automatically deployed on Hugging Face Spaces. Simply visit the live demo link above to use the application.
๐ How It Works
- Data Generation: Creates synthetic electricity consumption data with realistic patterns
- Model Training: Trains a linear regression model on historical data
- Feature Engineering: Extracts relevant features (temperature, day of week, events)
- Prediction: Uses the trained model to predict consumption for new scenarios
- Interpretation: Provides detailed breakdown of prediction factors
๐ฏ Model Features
- Temperature Effect: Higher temperatures increase AC usage
- Day of Week: Weekends typically have different consumption patterns
- Base Consumption: Minimum daily electricity usage
- Event Impact: Special events can significantly affect consumption
๐ Example Predictions
๐ง Configuration
The model can be customized by modifying parameters in src/model.py:
- Training data size
- Feature weights
- Model hyperparameters
๐งช Testing
Run the test suite to ensure everything works correctly:
# Run all tests
pytest tests/
# Run with coverage
pytest tests/ --cov=src
# Run specific test file
pytest tests/test_model.py๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ค Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
๐ Support
If you encounter any issues or have questions:
- Open an issue on GitHub
- Check the Hugging Face Spaces discussion
- Review the test files for usage examples
Built with โค๏ธ using Gradio and scikit-learn
