pyReCo
A Reservoir Computing Library for Time Series Forecasting and Research
pyReCo is built by researchers for researchers: we aim to develop new RC methods that allow for fast and efficient learning for sequential data. The main focus is time series prediction, mostly performed in an auto-regressive fashion based on learning discrete flow maps. Another core aspect that motivates the implementation of a new library is structure-function-relationships in functional networks. pyReCo allows to implement novel ways to generate better reservoir networks than the classical random choice. Overview of the core capabilities of pyReCo:
- Classical reservoir computing: using random reservoir layers and training readout-layer weights using Ridge regression
- Cross-validation: built-in functions to k-fold cross-validate any ResPy model for performance evaluation
- auto-regressive time stepping through feeding the predictions into the input layer (closed-loop prediction system)
- automated hyper-parameter tuning for leakage rate, activation function, reservoir network properties, etc.
Compatability: ResPy follows the syntax of scikit-learn (pyReCo Model-API), such that an estimator has the methods .fit() and .predict(). Any more experimental modeling can be realised by pyReCo's CustomModel-API, which follows TensorFlow's Sequential-API: a custom pyReCo model is compiled using model.add() functions for stacking different layers.
Table of Contents
- About the Developers
- Usage
- Installation
- Documentation
- Background and Supplementary Material
- Cite pyReCo
About the Developers
This library is developed by the Cyber-Physical Systems in Mechanical Engineering (CPSME) research group at TU Berlin, led by Prof. Merten Stender. The group specializes in Digital Twins, Dynamics and Artificial Intelligence, and Hybrid Simulation.
Usage
Minimal Working Examples
Model API
The ModelAPI is the simplest way to use one of the predefined RC models for training and prediction. The Model class follows the syntax of scikit-learn, such that an estimator has the methods .fit(), .predict(), and .evaluate().
The following example illustrates how to translate a sine signal to a cosine signal, i.e. a sequence-to-sequence mapping task. The input is $$x=\sin\left(\pi t\right)$$ and the output is $$x=2\cos\left(\pi t\right)$$. Thus, The model must learn a phase shift and the amplitude scaling from input to output. Both signals have 3 periods, sampled with 100 steps per period.
import numpy as np
from matplotlib import pyplot as plt
from pyreco.models import ReservoirComputer as RC
# generate 3 cycles of a sine (input) and of a cosine (output)
omega = np.pi
t = np.linspace(start=0, stop=3 * (2*np.pi/omega), num=300, endpoint=True)
x = np.sin(omega * t)
y = 2 * np.cos(omega * t)
x_train = np.expand_dims(x, axis=(0,2)) # obtain shape of [n_batch, n_time, n_states]
y_train = np.expand_dims(y, axis=(0,2))
# fit a reservoir computer with 200 nodes and make predictions on the training set
model = RC(num_nodes=200, activation='tanh')
model.fit(x_train, y_train)
y_pred = model.predict(x_train)
# evaluate some metrics (for simplicity on the train set)
metric_value = model.evaluate(X=x_train, y=y_train, metrics=['mse','mae'])
print(f'scores:{metric_value}')
# print truth and predicted sequence
plt.figure()
plt.plot(y_train[0,:,0], label='ground truth', marker='.', color='#1D3557')
plt.plot(y_pred[0,:,0], label='prediction', marker='.', color='#E63946')
plt.legend()
plt.xlabel('time')
plt.show()
Plotting y_pred and y_train against the time vector t shows how the minimal RC can learn a phase shift, i.e. translate a sine signal to a cosine signal, and also scale the output to the correct amplitude. You may want to increase the reservoir size (num_nodes) or change the leakage rate (leakage_rate) to improve the prediction quality.
Input data shapes: the shape of the input data is of utmost importance. ResPy is built for sequential modeling tasks. Make sure to provide the input data in the shape of [n_batch, n_time, n_states], where
n_batchis the number of samples, i.e. the number of individual time series samples (example above:n_batch = 1)n_timeis the number of time steps per sample (example above:n_time = 300)n_statesis the channel dimension, i.e. the number of contemporaneous states in the time series (example above:n_states = 1)
CustomModel API
The CustomModel API gives the user more flexibility in defining specific properties. For example, one can specify the fraction of reservoir nodes which receive the inputs. Additionally, the user can provide custom reservoir layers and add them to the model. The same example as for the Model API can be obtained with the custom model, as shown below.
import numpy as np
from matplotlib import pyplot as plt
from pyreco.custom_models import RC
from pyreco.layers import InputLayer, ReadoutLayer
from pyreco.layers import RandomReservoirLayer
# generate 3 cycles of a sine (input) and of a cosine (output)
omega = np.pi
t = np.linspace(start=0, stop=3 * (2*np.pi/omega), num=300, endpoint=True)
x = np.sin(omega * t)
y = 2 * np.cos(omega * t)
x_train = np.expand_dims(x, axis=(0,2)) # obtain shape of [n_batch, n_time, n_states]
y_train = np.expand_dims(y, axis=(0,2))
# set the dimensions
input_shape = (x_train.shape[1], x_train.shape[2])
output_shape = (y_train.shape[1], y_train.shape[2])
# build a custom RC model by adding layers with properties
model = RC()
model.add(InputLayer(input_shape=input_shape))
model.add(RandomReservoirLayer(nodes=200, activation='tanh', fraction_input=0.5))
model.add(ReadoutLayer(output_shape))
# compile the model
model.compile(optimizer='ridge', metrics=['mean_squared_error'])
# train the model
model.fit(x_train, y_train)
# make predictions
y_pred = model.predict(x_train)
print(f'shape of predicted array: {y_pred.shape}')
# evaluate some metrics (for simplicity on the train set)
metric_value = model.evaluate(X=x_train, y=y_train, metrics=['mse','mae'])
print(f'scores:{metric_value}')
Installation
Simply use pip, or get the source files from this repo.
pip install pyreco
Documentation
The official pyReCo documentation can be found here: Official Documentation.
Background and Supplementary Material
Introductory material to reservoir computing and echo state networks
Other RC libraries that you may want to have a look at
Cite pyReCo
If you use pyReCo in your research, please cite it. GitHub's "Cite this repository" button (in the sidebar) uses the metadata in CITATION.cff.
BibTeX
@software{pyreco,
title = {pyReCo: A Python Reservoir Computing Library for Time Series Forecasting and Research},
author = {Yadav, Manish and Disson, Klara and Stender, Merten},
version = {2.1.0},
year = {2026},
license = {Apache-2.0},
url = {https://github.com/Cyber-Physical-Systems-in-Mech-Eng/pyReCo}
}
APA
Yadav, M., Disson, K., & Stender, M. (2026). pyReCo: A Python reservoir computing library for time series forecasting and research (Version 2.1.0) [Computer software]. Technische Universität Berlin. https://github.com/Cyber-Physical-Systems-in-Mech-Eng/pyReCo
Metadata
Release files for pyreco 2.0.1
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 | |
|---|---|---|---|---|
| pyreco-2.0.1.tar.gz | 451.9 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyreco-2.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 530.0 kB
Release files / pyreco-2.0.1.tar.gz
| Download URL | pyreco-2.0.1.tar.gz |
|---|---|
| Size | 451.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2f785f11555d40a062a90eb434fca4764600840512bbea03fcc8f7f5e98ed94e
|
|
BLAKE2b-256 checksum How to use checksums |
99afed007449943f15d314b392b2c7e15178bc4061b35094fde84ab9d4c656f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency logRelease files / pyreco-2.0.1-py3-none-any.whl
| Download URL | pyreco-2.0.1-py3-none-any.whl |
|---|---|
| Size | 78.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
25716ca0b8b89edcd28d1a058ec5d1af4727fee14b6286be3c16093c4c1ec416
|
|
BLAKE2b-256 checksum How to use checksums |
07ae8c4695a11be464dec12aabfbae601e1f9f1114e8fd7ded00bb5265ab1060
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency logSecurity for pyreco 2.0.1
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for pyreco-2.0.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency logA 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.