Last Updated: May 24, 2025
EnergyCostPredictorApp is a PyQt5-based desktop application designed to predict and manage energy costs for household appliances. It leverages a machine learning model to forecast monthly bills, provides energy usage profiles, visualizes appliance usage patterns, and manages appliance states based on the owner's presence and environmental conditions. The app also supports automatic model updates from a Google Cloud Storage bucket and integrates weather-based appliance recommendations.
This README provides detailed instructions on setting up and running the application on your local machine.
- Energy Cost Prediction: Predicts monthly energy bills based on a 7-day dataset using a machine learning model.
- Energy Profiles: Adjusts appliance usage with profiles (Eco, Balanced, Comfort, Normal).
- Model Updates: Automatically checks for and downloads new models from a Google Cloud Storage bucket.
- Usage Graph: Visualizes weekly usage patterns for individual appliances.
- Weather Integration: Displays simulated weather data and provides appliance recommendations.
- Owner Presence Management: Manages appliance states based on the owner's expected return time, with a grace period countdown and power reduction.
Before setting up the application, ensure you have the following:
- Operating System: Windows, macOS, or Linux.
- Python Version: Python 3.8 or higher (tested with Python 3.9).
- Disk Space: Approximately 500 MB for dependencies and model files.
- Internet Connection: Required for initial setup (downloading dependencies) and model updates.
- Python: Install Python from python.org.
- pip: Ensure
pipis installed (usually bundled with Python). - Git: Optional, for cloning the repository (download from git-scm.com).
- RAM: Minimum 4 GB (8 GB recommended).
- CPU: Any modern processor (e.g., Intel i3 or equivalent).
Follow these steps to set up the EnergyCostPredictorApp on your machine.
-
Option 1: Clone with Git
- Open a terminal or command prompt.
- Run the following command to clone the repository:
git clone https://github.com/NguyenVHungDZ/Model
-
Option 2: Download Manually
- Download the project as a ZIP file from the repository's GitHub page.
- Extract the ZIP file to a directory
- Navigate to the extracted directory:
cd /path/to/Model
- Create a virtual environment to isolate dependencies:
python -m venv venv - Activate the virtual environment:
- Windows:
venv\Scripts\activate - macOS/Linux:
source venv/bin/activate
(venv)in your terminal prompt. - Windows:
- Install the required Python packages using
pip:pip install -r requirements.txt - If
requirements.txtis not provided, install the following packages manually:pip install PyQt5 numpy pandas matplotlib google-cloud-storage joblib requests urllib3- PyQt5: For the GUI framework.
- numpy, pandas: For data processing.
- matplotlib: For usage graph visualization.
- google-cloud-storage: For model updates from Google Cloud Storage.
- joblib: For loading the machine learning model.
- requests, urllib3: For network operations.
The app requires a dataset file (mock_appliances_week.json) for energy cost predictions. This file should contain 7 days of appliance data (e.g., May 12 to May 18, 2025).
-
Place Dataset:
- Ensure
mock_appliances_week.jsonis in themock_datasetdirectory. - Example structure of the JSON file:
[ { "Date": "2025-05-12", "Device Type": "Air Conditioner", "Power Consumption (W)": 1200.0, "Room Location": "Living Room", "Temperature (°C)": 25.0, "Humidity (%)": 60.0, "Usage Duration (minutes)": 60.0, "On/Off Status": "On", "Turn On Time": "08:00" }, ... ]
- Ensure
-
Create Dataset (if wanted):
- If the dataset is not provided, create a JSON file with at least 7 days of data (56 records for 8 appliances per day).
- Save it as
mock_dataset/mock_appliances_week.json.
- Ensure you're in the project directory with the virtual environment activated:
cd /path/to/Model source venv/bin/activate # or venv\Scripts\activate on Windows - Run the main script:
python main.py - The application window should open, displaying the main interface with buttons like "Load Appliances", "Show Usage Graph", and "Settings ⚙️".
- Load Dataset:
- Click "Load Appliances".
- Select
mock_appliances_week.jsonfrom themock_datasetdirectory. - The table will populate with appliance data for the first day (e.g., May 12, 2025), and the predicted monthly bill will update (e.g., "Predicted Monthly Bill: $179.14").
- Check for Model Update:
- Click "Check for Model Update" to download the latest
gb_model.pklfrom thebig_data32bucket if new folders are available. - Ensure an internet connection is available for this step.
- Click "Check for Model Update" to download the latest
- Set Up Owner Return Time:
- In the "Owner Status" section, set the "Expected Return Time" (e.g., 20:30 PM).
- Click "Save" to confirm the return time.
- The app will compare with the current time (08:20 PM) and start a countdown if the time has passed.
- Navigate Days: Use the "◄" and "►" buttons to view appliance data for different days (May 12 to May 18, 2025).
- Change Profile: Click "Eco", "Balanced", "Comfort", or "Normal" to adjust appliance usage and recalculate the bill.
- View Usage Graph: Click "Show Usage Graph" to see weekly usage patterns for each appliance, toggling between appliances with the "Next Appliance" button.
- Manage Owner Presence:
- Set a return time and save it.
- If the return time passes (e.g., 20:30 PM passes at 08:20 PM), a grace period countdown starts (e.g., "Missed Return - Grace Period: 00:15").
- Click "Simulate" to simulate the owner returning home, stopping the countdown.
- Settings: Click "Settings ⚙️" to adjust temperature thresholds, turn-on times, turn-off period, and grace period.
- "File not found" Error on Startup:
- Cause: Missing model files (
gb_model.pkl, etc.) in themodelsdirectory. - Solution: Ensure all
.pklfiles are in themodelsdirectory. Run "Check for Model Update" to download them, or manually place them.
- Cause: Missing model files (
- "No file selected" Warning:
- Cause: Cancelled the dataset selection dialog.
- Solution: Click "Load Appliances" and select
mock_appliances_week.json.
- Model Update Fails:
- Cause: No internet connection or bucket access issues.
- Solution: Ensure you're online. Verify the
big_data32bucket is public and contains model files.
- GUI Not Displaying:
- Cause: Missing PyQt5 or dependency issues.
- Solution: Reinstall dependencies:
pip install PyQt5 numpy pandas matplotlib google-cloud-storage joblib requests urllib3
- The app logs debug information to the console.
- Check the logs for detailed error messages (e.g., "Failed to load dataset: ...").
- Dataset: The app expects
mock_appliances_week.jsonto contain 7 days of data (e.g., May 12 to May 18, 2025). Ensure the file matches this format. - Model Updates: The app checks the
big_data32bucket for new folders. Ensure the bucket is accessible and contains folders liketest_folder_2025-05-15/withgb_model.pkl. - Time-Based Features: The owner return feature uses the laptop's system time (e.g., 08:20 PM on May 24, 2025). Ensure your system time is correct.
- Dependencies: If dependency installation fails, try updating
pip:pip install --upgrade pip
To contribute to the project:
Happy Energy Monitoring!