Skip to main content

A package implementing physics-informed kernels in dimensions 1 and 2

Project description

WeaKL

WeaKL is a Python package for constructing kernel methods with weak physical information as introduced in the paper
Forecasting time series with constraints (2025) by Nathan Doumèche, Francis Bach, Eloi Bedek, Claire Boyer, Gérard Biau, and Yannig Goude.

Features

  • Build kernels tailored to weak information
  • Compatible with NumPy and PyTorch backends
  • GPU support via PyTorch for accelerated computation

Installation

You can install the package via pip:

pip install weakl

Resources

Citation

To cite this package:

@article{doumèche2025forecastingtimeseriesconstraints,
  title={Forecasting time series with constraints}, 
  author={Nathan Doumèche and Francis Bach and Éloi Bedek and Gérard Biau and Claire Boyer and Yannig Goude},
  year={2025},
  journal={arXiv:2502.10485},
  url={https://arxiv.org/abs/2502.10485}
}

Minimum examples

Training an additive model

import pandas as pd
from weakl.utils import device, dataset_load
from weakl.additive_model import 

# Download the dataset on the French electricity load
data = dataset_load()

# Defining the additive model
features_weakl = {
"features": ["Load_d1", "temperature_smooth_950", "temperature",
            "temperature_max_smooth_990", 'temperature_min_smooth_950',
            'toy',  'day_type_week', 'day_type_jf', 'Load_d7','time'],
"features_type":['linear','regression','regression','regression','regression', 
            'regression','categorical7','linear','linear','linear']
}

features_weakl["masked"] = features_weakl["features_type"].copy()

# Setting the hyperparameters of the model
m_list = ['Linear', 10, 10, 10, 10, 10, 4, 'Linear', 'Linear', 'Linear']
alpha_list = torch.tensor([1.0000e-30, 1.0000e-30, 1.0000e-05, 1.0000e-03, 1.0000e-03, 1.0000e-04, 1.0000e-08, 1.0000e-30, 1.0000e-30, 1.0000e-30, 1.0000e-30],
       device=device)
s_list = ['*', 2, 2, 2, 2, 2, 0, '*', '*', '*']

hyperparameters = {"m_list": m_list,
                   "s_list": s_list,
                   "alpha_list": alpha_list}

# Training the model
dates_test = {
"begin_train": "2013-01-08 00:00:00+00:00",
"end_train": "2022-09-01 00:00:00+00:00",
"end_test": "2023-02-28 00:00:00+00:00"
}

data_hourly = half_hour_formatting(data, dates_test, features_weakl)
cov_hourly = cov_hourly_m(m_list, data_hourly)
sobolev_matrix = Sob_matrix(alpha_list, s_list, m_list)*len(data_hourly[0][0])
M_stacked = torch.stack([sobolev_matrix for i in range(48)])

# Evaluating the RMSE
perf_test, fourier_vectors_test, perf_h_test = WeakL(data, hyperparameters, cov_hourly, M_stacked, criterion=criterion)
print("The RMSE of the model is "+ str(perf_test.cpu().numpy()))

Learning the hyperparameters of the additive model by grid search

Training a model with time adaption

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

weakl-0.0.1.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

weakl-0.0.1-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file weakl-0.0.1.tar.gz.

File metadata

  • Download URL: weakl-0.0.1.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for weakl-0.0.1.tar.gz
Algorithm Hash digest
SHA256 7a4fdf117742f91bc56ccb2feb0afdd64f4ca11af32c18d07d9ec59eaac841f4
MD5 b7a857cb6a579d5929fb3b23cea0bcf4
BLAKE2b-256 514ad8714eec896db7b9e8d44eefa9dc990b8834eb862564556ea1900a008bdc

See more details on using hashes here.

Provenance

The following attestation bundles were made for weakl-0.0.1.tar.gz:

Publisher: publish.yml on NathanDoumeche/weakl-package

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file weakl-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: weakl-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for weakl-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cc169b25c13d0aae0b50cf6c58fd83bddc6c48bc0743dafa37745820390dd59d
MD5 fe794004bae9bcf6cf73ce7cff229af3
BLAKE2b-256 6f2a0508e766ac05d3590a26b86ca75e1d91c953582e35b9aa98dfa7365ec46f

See more details on using hashes here.

Provenance

The following attestation bundles were made for weakl-0.0.1-py3-none-any.whl:

Publisher: publish.yml on NathanDoumeche/weakl-package

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page