CoolFace
Apppublic

surahj/electricity-consumption-predictor

sourceHugging Facemitupdated 1y agoView on Hugging Face
0likes
App README

โšก 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

![Hugging Face Spaces](https://huggingface.co/spaces/surahj/electricity-consumption-predictor)

๐Ÿ“Š 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

  1. 1.Clone the repository:
bash
   git clone https://github.com/YOUR_USERNAME/electricity-consumption-predictor.git
   cd electricity-consumption-predictor
  1. 1.Install dependencies:
bash
   pip install -r requirements.txt
  1. 1.Run the application:
bash
   python app.py
  1. 1.Run tests:
bash
   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

  1. 1.Data Generation: Creates synthetic electricity consumption data with realistic patterns
  2. 2.Model Training: Trains a linear regression model on historical data
  3. 3.Feature Engineering: Extracts relevant features (temperature, day of week, events)
  4. 4.Prediction: Uses the trained model to predict consumption for new scenarios
  5. 5.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

TemperatureDayEventPredicted Consumption
25ยฐCMondayNone16.5 kWh
35ยฐCSaturdayHoliday22.3 kWh
15ยฐCWednesdayNone14.1 kWh

๐Ÿ”ง 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:

bash
# 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

  1. 1.Fork the repository
  2. 2.Create a feature branch
  3. 3.Make your changes
  4. 4.Add tests for new functionality
  5. 5.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