Downloads · 30 days
0
SelvaMech/electricity-bill-regression
electricity-bill-regression is a machine learning model from SelvaMech. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for scikit-learn. The card lists the license as mit.
A Linear Regression model that predicts a household's daily electricity consumption (kWh) from appliance usage hours. Used to power a "what-if" electricity bill calculator, deployed as a Streamlit app.
Downloads · 30 days
0
Access
Public
Updated Aug 6, 2026
Repo size
2.4 KB
Likes
0
Public
Click a slice to open those files.
.md5 KB · 56%
From the Hugging Face model README
A Linear Regression model that predicts a household's daily electricity consumption (kWh) from appliance usage hours. Used to power a "what-if" electricity bill calculator, deployed as a Streamlit app.
Daily_kWh from 13 appliance usage-hour featuresStandardScaler before being passed to the modellinear_regression_model.pkl - the trained regression modelscaler.pkl - the fitted StandardScaler (must be used to transform any new input before prediction)feature_columns.pkl - the exact list and order of input feature names the model expectsGiven a household's typical daily appliance usage hours, this model estimates daily electricity consumption. That estimate can then be scaled to a full month and passed through a fixed slab-based electricity tariff formula (LT Commercial tariff) to estimate a monthly bill. The tariff calculation itself is NOT part of this model, it is applied separately after prediction, since it is a fixed government rate structure, not a learned relationship.
The model expects 13 numeric features, in this exact order (see feature_columns.pkl for the authoritative list):
AC_Hours, Fridge_Hours, Heater_Hours, Fan_Hours, Light_Hours, NightLamp_Hours, LEDBulb_Hours, TV_Hours, WashingMachine_Hours, Chimney_Hours, Mixer_Hours, Grinder_Hours, InductionStove_Hours
Each represents hours of use per day (0-24) for that appliance.
Trained on a synthetically generated dataset simulating 9 years (2017-2025) of daily electricity usage for a single household, ~3,269 rows after cleaning (missing values dropped, invalid negative values removed, outliers removed using the IQR method).
Note: Daily_kWh in the training data was generated using a deterministic formula (hours x fixed appliance wattage), with no added noise. This means the model achieves a very high (near 100%) R-Squared score on this dataset, which reflects the noise-free nature of the training data rather than an unusually strong real-world model. On genuine smart-meter data with natural variance, performance would be expected to be lower.
This model predicts only daily electricity consumption (kWh). It does not predict the monthly bill directly, since bill calculation depends on a fixed government tariff formula (slab-based rates), not something a model should learn. The example below shows the complete pipeline: get the daily prediction from the model, scale it to a full month, then apply the tariff formula separately to get the estimated bill.
from huggingface_hub import hf_hub_download
import joblib
import pandas as pd
import calendar
REPO_ID = "SelvaMech/electricity-bill-regression"
model = joblib.load(hf_hub_download(repo_id=REPO_ID, filename="linear_regression_model.pkl"))
scaler = joblib.load(hf_hub_download(repo_id=REPO_ID, filename="scaler.pkl"))
feature_columns = joblib.load(hf_hub_download(repo_id=REPO_ID, filename="feature_columns.pkl"))
# user_values must be in the same order as feature_columns
user_values = pd.DataFrame([[5, 24, 1, 8, 5, 8, 6, 3, 0.5, 0.5, 0.1, 0.1, 1]], columns=feature_columns)
scaled_input = scaler.transform(user_values)
predicted_daily_kwh = model.predict(scaled_input)[0]
# Scale to a full month (example: August 2026)
days = calendar.monthrange(2026, 8)[1]
monthly_units = predicted_daily_kwh * days
# LT Commercial slab tariff - deterministic formula, not part of the model
if monthly_units <= 100:
bill = monthly_units * 5.5 + 120
elif monthly_units <= 250:
bill = (100 * 5.5) + (monthly_units - 100) * 6.5 + 120
else:
bill = (100 * 5.5) + (150 * 6.5) + (monthly_units - 250) * 7.2 + 120
print(f"Predicted Daily kWh : {predicted_daily_kwh:.2f}")
print(f"Predicted Monthly Units : {monthly_units:.2f}")
print(f"Estimated Bill : Rs {bill:.2f}")
Try the deployed calculator here: [(https://ebbillpredictionsampledeployment-bpne9za7xb7p2kkp7eejza.streamlit.app)]
Built by Selvanaayagam Ravy as part of a personal Data Analytics/AI portfolio project. Full training code and dataset details: [https://github.com/selvanaayagam-tech/EB_billprediction_sample_deployment]