Skip to content

Machine Learning project that predicts household electric power consumption using the UCI Individual Household Electric Power Consumption dataset. The dataset was cleaned, preprocessed, and trained using a Random Forest Regressor model to forecast Global Active Power with ~96.7% accuracy.

Notifications You must be signed in to change notification settings

MehwishSayyed/Week2---Household-Energy-Consumption-Forecasting-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 

Repository files navigation

⚑ Electric Power Consumption Prediction using Random Forest

This project predicts household electric power consumption using the UCI Individual Household Electric Power Consumption Dataset.
The goal is to accurately forecast Global Active Power based on features such as voltage, reactive power, current, and sub-meter readings.


πŸ“˜ Project Overview

This notebook demonstrates the full pipeline of a Machine Learning regression project:

  1. Data Loading – Imported directly from the UCI Machine Learning Repository
  2. Data Cleaning – Handled missing values, replaced '?' with NaN, interpolated time-series data
  3. Feature Engineering – Combined date and time columns, removed outliers, and converted all data to numeric types
  4. Model Training – Used Random Forest Regressor for prediction
  5. Model Evaluation – Evaluated using metrics like RΒ², MAE, MSE, and MAPE
  6. Visualization – Compared actual vs predicted power consumption using scatter plots and line charts

🧠 Key Features

  • Cleaned and preprocessed 1.9 million energy data points
  • Used Random Forest for robust and high-accuracy regression
  • Achieved RΒ² = 0.998 and Average Accuracy β‰ˆ 96.7%
  • Generated performance visualizations:
    • Actual vs Predicted Scatter Plot
    • Residual Distribution
    • Feature Importance Plot

πŸ“Š Dataset Information

Dataset Name: Individual Household Electric Power Consumption
Source: UCI Machine Learning Repository
Rows: ~2 million
Columns:

  • Global_active_power β€” Total active power consumed (Target)
  • Global_reactive_power β€” Reactive power
  • Voltage β€” Average voltage
  • Global_intensity β€” Average current
  • Sub_metering_1, Sub_metering_2, Sub_metering_3 β€” Energy consumption in different household areas

🧰 Tech Stack

  • Python 3
  • Pandas, NumPy β€” Data manipulation
  • Scikit-learn β€” Model training and evaluation
  • Matplotlib, Seaborn β€” Visualization
  • ucimlrepo β€” Fetch dataset from UCI repository

πŸ§ͺ Model Evaluation Results

Metric Value
RΒ² Score 0.998
Mean Absolute Error (MAE) 0.0176
Mean Squared Error (MSE) 0.00098
Average Accuracy 96.67%
Mean Absolute Percentage Error (MAPE) 3.32%

βœ… These results show the model predicts energy usage with extremely high precision.


πŸ“ˆ Visualizations

  • Actual vs Predicted Scatter Plot
  • Residual Distribution
  • Feature Importance Bar Chart

These plots help visualize how close predictions are to actual values and which features influence power usage the most.


πŸš€ How to Run

  1. Clone this repository

    git clone https://github.com/your-username/your-repo-name.git
    
  2. Install required dependencies

    pip install 
    
  3. Open the notebook

    jupyter notebook Electric_Power_Prediction.ipynb
    
  4. Run all cells sequentially to reproduce results.

🏁 Results Summary

The Random Forest model provides near-perfect predictions for household energy consumption. It can be extended for real-time power monitoring, energy efficiency analysis, or smart grid applications.

🌟 Acknowledgments

UCI Machine Learning Repository for the dataset

Scikit-learn Team for ML tools

Google Colab for providing a free compute environment

About

Machine Learning project that predicts household electric power consumption using the UCI Individual Household Electric Power Consumption dataset. The dataset was cleaned, preprocessed, and trained using a Random Forest Regressor model to forecast Global Active Power with ~96.7% accuracy.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published