Overview
This Python package provides state-of-the-art models for short-term load forecasting (STLF), designed for both academic research and real-world energy applications.
The models and evaluation framework are described in the following publication:
Moosbrugger et al. (2025). Load Forecasting for Households and Energy Communities: Are Deep Learning Models Worth the Effort?
arXiv:2501.05000
For more details and the full project source code, visit the GitHub repository.
Quick Start
Install the package:
pip install loadforecasting_models
You can easily integrate and train our forecasting machine learning models in your Python workflow:
from loadforecasting_models import Knn, Lstm, Transformer, xLstm, Persistence, Normalizer
import torch
# ------------------------------------------------------------------------------
# Prepare training data using dummy (replace with your own) data
# ------------------------------------------------------------------------------
# Generate Random Data
x = torch.randn(365, 24, 10) # Shape: (batches, seq_len, features)
y = torch.randn(365, 24, 1) # Shape: (batches, seq_len, 1)
# Do train/test split
x_train = x[:330 ,: ,:]
y_train = y[:330 ,: ,:]
x_test = x[330: ,: ,:]
y_test = y[330: ,: ,:]
# Normalize data
normalizer = Normalizer()
x_train = normalizer.normalize_x(x_train, training=True)
y_train = normalizer.normalize_y(y_train, training=True)
x_test = normalizer.normalize_x(x_test, training=False)
y_test = normalizer.normalize_y(y_test, training=False)
# ------------------------------------------------------------------------------
# Train the model
# ------------------------------------------------------------------------------
myModel = Transformer(model_size='5k', normalizer=normalizer)
myModel.train_model(x_train, y_train, epochs=100, verbose=1)
# ------------------------------------------------------------------------------
# Make predictions
# ------------------------------------------------------------------------------
y_pred = myModel.predict(x_test)
y_pred = normalizer.de_normalize_y(y_pred)
print('\nOutput shape:', y_pred.shape) # Should output 'torch.Size([35, 24, 1])'
Using a non-machine learning model is very similar, e.g. for a KNN model:
from loadforecasting_models import Knn, Lstm, Transformer, xLstm, Persistence, Normalizer
import torch
# Same setup as above
# ...
myModel = Knn(k=40, weights='distance', normalizer=normalizer)
myModel.train_model(x_train, y_train)
# ...
Using automatic machine-learning hyperparameter tuning. This automatically optimizes hyperparameters like nr-of-epochs, batch-sizes, model-size, and learning-rate:
from loadforecasting_models import Knn, Lstm, Transformer, xLstm, Persistence, Normalizer
import torch
# Same setup as above
# ...
myModel = Transformer()
myModel.train_model_auto(x_train, y_train)
# ...
Currently Available Model Types:
-
'Transformer'
-
'Lstm'
-
'xLstm'
-
'Knn'
-
'Persistence'
Citation
If you use this package in your work, please cite the following paper:
@article{moosbrugger2025load,
title={Load Forecasting for Households and Energy Communities: Are Deep Learning Models Worth the Effort?},
author={Moosbrugger, Lukas and Seiler, Valentin and Wohlgenannt, Philipp and Hegenbart, Sebastian and Ristov, Sashko and Eder, Elias and Kepplinger, Peter},
journal={arXiv preprint},
year={2025},
doi={10.48550/arXiv.2501.05000}
}
License
This project is open-source and available under the terms of the MIT License.
Metadata
Release files for loadforecasting-models 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| loadforecasting_models-0.5.0.tar.gz | 47.5 kB | Without provenance | Details for loadforecasting_models-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| loadforecasting_models-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for loadforecasting_models-0.5.0-py3-none-any.whl |
Total release size: 119.3 kB
Release files / loadforecasting_models-0.5.0.tar.gz
| Download URL | loadforecasting_models-0.5.0.tar.gz |
|---|---|
| Size | 47.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ca94f0afed6a2afbdf4e765f3eb4d52ffa76bf777deec9dde20f7db7355b7712
|
|
BLAKE2b-256 checksum How to use checksums |
a775400efb65ad486c528f7294cda3cf459ff988956c311b5a6df7d0a176718d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.9
|
Release files / loadforecasting_models-0.5.0-py3-none-any.whl
| Download URL | loadforecasting_models-0.5.0-py3-none-any.whl |
|---|---|
| Size | 71.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a4a2edf2d862aadb0c58e692fa373e10f34423aab44140fa5dbc39bad90cd582
|
|
BLAKE2b-256 checksum How to use checksums |
b16fa9092128ddfcced48573dc1113bb9f90d89bdff4de07d0e97613a0f02fcb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.9
|
Security for loadforecasting-models 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.