Skip to main content

Reservoir computing benchmark toolkit

Project description

RCbench - Reservoir Computing Benchmark Toolkit

Python License

RCbench (Reservoir Computing Benchmark Toolkit) is a comprehensive Python package for evaluating and benchmarking reservoir computing systems. It provides standardized tasks, flexible visualization tools, and efficient evaluation methods for both physical and simulated reservoirs.

๐Ÿš€ Features

RCbench provides:

-Multiple Benchmark Tasks: -NLT (Nonlinear Transformation): Evaluate reservoir performance on standard nonlinear transformations -NARMA: Test with Nonlinear Auto-Regressive Moving Average models of different orders -Memory Capacity: Measure the short and long-term memory capabilities -Sin(x): Assess reservoir ability to transform a random signal into a nonlinear function that use the input as argument -KernelRank: Evaluates the nonlinearityof the reservoir -GeneralizationRank: Evaluates the generalization capabilities of the reservoir

-Advanced Visualization: -Task-specific plotters with customizable configurations -General reservoir properties visualization (input signals, output responses, nonlinearity) -Frequency domain analysis of reservoir behavior -Target vs. prediction comparison with proper time alignment

-Efficient Data Handling: -Automatic measurement loading and parsing -Support for various experimental data formats -Feature selection and dimensionality reduction tools

๐Ÿ“‚ Project Structure

RCbench/
โ”œโ”€โ”€ rcbench/
|   |โ”€โ”€ examples/                  # Example scripts
|   |   โ”œโ”€โ”€ example_nlt.py
|   |   โ”œโ”€โ”€ example_NARMA.py
|   |   โ”œโ”€โ”€ example_sinx.py
|   |   โ””โ”€โ”€ example_MC.py
โ”‚   โ”œโ”€โ”€ measurements/          # Data handling
โ”‚   โ”‚   โ”œโ”€โ”€ dataset.py         # ReservoirDataset class
โ”‚   โ”‚   โ”œโ”€โ”€ loader.py          # Data loading utilities
โ”‚   โ”‚   โ””โ”€โ”€ parser.py          # Data parsing utilities
โ”‚   โ”œโ”€โ”€ tasks/                 # Reservoir computing tasks
โ”‚   โ”‚   โ”œโ”€โ”€ baseevaluator.py   # Base evaluation methods
โ”‚   โ”‚   โ”œโ”€โ”€ nlt.py             # Nonlinear Transformation
โ”‚   โ”‚   โ”œโ”€โ”€ narma.py           # NARMA tasks
โ”‚   โ”‚   โ”œโ”€โ”€ memorycapacity.py  # Memory Capacity
โ”‚   โ”‚   โ”œโ”€โ”€ sinx.py            # Sin(x) approximation
โ”‚   โ”‚   โ””โ”€โ”€ featureselector.py # Feature selection tools
โ”‚   โ”œโ”€โ”€ visualization/         # Plotting utilities
โ”‚   โ”‚   โ”œโ”€โ”€ base_plotter.py    # Base plotting functionality
โ”‚   โ”‚   โ”œโ”€โ”€ plot_config.py     # Plot configurations
โ”‚   โ”‚   โ”œโ”€โ”€ nlt_plotter.py     # NLT visualization
โ”‚   โ”‚   โ”œโ”€โ”€ narma_plotter.py   # NARMA visualization
โ”‚   โ”‚   โ””โ”€โ”€ sinx_plotter.py    # Sin(x) visualization
โ”‚   โ””โ”€โ”€ logger.py              # Logging utilities
โ””

๐Ÿ”ง Installation

Install directly from GitHub:

pip install rcbench

Or, install locally (development mode):

git clone https://github.com/nanotechdave/RCbench.git
cd RCbench
pip install -e .

๐Ÿšฆ Usage Example

Here's a quick example demonstrating how to perform an NLT evaluation:

import logging
from pathlib import Path
import numpy as np
import matplotlib.pyplot as plt

from rcbench import ReservoirDataset
from rcbench import NltEvaluator
from rcbench.visualization.plot_config import NLTPlotConfig
from rcbench.logger import get_logger

logger = get_logger(__name__)
logger.setLevel(logging.INFO)

BASE_DIR = "FILE_PATH"

filenameNLT = "YOUR_FILENAME"

measurement_file_NLT = BASE_DIR / filenameNLT

# Load the data directly using the ReservoirDataset class
dataset = ReservoirDataset(measurement_file_NLT)

# Get information about the electrodes
electrodes_info = dataset.summary()
logger.info(f"Parsed Electrodes: {electrodes_info}")

# Get input and node voltages directly from the dataset
input_elec = electrodes_info['input_electrodes'][0]
input_signal = dataset.get_input_voltages()[input_elec]
time = dataset.time

# Get node voltages (only node electrodes, not input)
nodes_output = dataset.get_node_voltages()
electrode_names = electrodes_info['node_electrodes']

# Create NLT plot configuration
plot_config = NLTPlotConfig(
    save_dir=None,  # Save plots to this directory
    
    # General reservoir property plots
    plot_input_signal=True,         # Plot the input signal
    plot_output_responses=True,     # Plot node responses
    plot_nonlinearity=True,         # Plot nonlinearity of nodes
    plot_frequency_analysis=True,   # Plot frequency analysis
    
    # Target-specific plots
    plot_target_prediction=True,    # Plot target vs prediction results
    
    # Plot styling options
    nonlinearity_plot_style='scatter',
    frequency_range=(0, 20)         # Limit frequency range to 0-20 Hz for clearer visualization
)

# Run NLT evaluation with plot config
evaluatorNLT = NltEvaluator(
    input_signal=input_signal,
    nodes_output=nodes_output,
    time_array=time,
    waveform_type='sine',  
    electrode_names=electrode_names,
    plot_config=plot_config
)


resultsNLT = {}
for target_name in evaluatorNLT.targets:
    try:
        result = evaluatorNLT.run_evaluation(
            target_name=target_name,
            metric='NMSE',
            feature_selection_method='pca',
            num_features='all',
            model="Ridge",
            regression_alpha=0.01,
            train_ratio=0.8,
            plot=False,  # Don't plot during evaluation
        )
        resultsNLT[target_name] = result
        # Print results clearly
        logger.output(f"NLT Analysis for Target: '{target_name}'")
        logger.output(f"  - Metric: {result['metric']}")
        logger.output(f"  - Accuracy: {result['accuracy']:.5f}")
        logger.output(f"  - Selected Features Indices: {[electrode_names[i] for i in result['selected_features']]}")
        logger.output(f"  - Model Weights: {result['model'].coef_}\n")
    except Exception as e:
        logger.error(f"Error evaluating {target_name}: {str(e)}")

evaluatorNLT.plot_results(existing_results=resultsNLT)

๐Ÿ“ˆ Visualization Tools

RCbench features a unified visualization system with: -Task-Specific Plotters: Dedicated plotters for each task (NLTPlotter, NarmaPlotter, SinxPlotter) -Customizable Configurations: Control which plots to generate through configuration objects -Comprehensive Visualization: For each task, view: -General reservoir properties (input signals, node responses, nonlinearity) -Frequency domain analysis -Target vs. prediction comparisons

๐Ÿ“ Contributions & Issues

Contributions are welcome! Please open a pull request or an issue on GitHub.

๐Ÿ“œ License

RCbench is licensed under the MIT License. See the LICENSE file for details.

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

rcbench-0.1.10.tar.gz (43.0 kB view details)

Uploaded Source

Built Distribution

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

rcbench-0.1.10-py3-none-any.whl (50.4 kB view details)

Uploaded Python 3

File details

Details for the file rcbench-0.1.10.tar.gz.

File metadata

  • Download URL: rcbench-0.1.10.tar.gz
  • Upload date:
  • Size: 43.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for rcbench-0.1.10.tar.gz
Algorithm Hash digest
SHA256 e5e3de39fe57e9453bf29849698923a82855917eff6ba97dcb75de90e74d4399
MD5 d361664fa7c6ea5ce96686957304d5e4
BLAKE2b-256 8e80b5500507de0b11aa7f181fcf021cecbd65d501b9f60495966f3e0fbc594f

See more details on using hashes here.

File details

Details for the file rcbench-0.1.10-py3-none-any.whl.

File metadata

  • Download URL: rcbench-0.1.10-py3-none-any.whl
  • Upload date:
  • Size: 50.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for rcbench-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 55d14eb816b2bc7568ccabc57e521f66cf526d1106e415a2b303b2495e1a1ff4
MD5 ce1b5b09a25760f82f8049974f15e218
BLAKE2b-256 e9e15da3963887c2bad6322a99f28994c792040c7cbf620d235505657165862e

See more details on using hashes here.

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