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.0.tar.gz (42.2 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.0-py3-none-any.whl (49.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rcbench-0.1.0.tar.gz
  • Upload date:
  • Size: 42.2 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.0.tar.gz
Algorithm Hash digest
SHA256 9e9d0897f44f4d16b980d8470e8ff333e5fbba1916e01ca98c354596495340f4
MD5 0e8ea1f0e248803bf9e3c50634e612d6
BLAKE2b-256 daeb98a58747f9f3dcf03f0ca223addbdacd55b617c05df60ff7f7a99b3b3a46

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rcbench-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 49.5 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 01473e531e17dd74c49198853311d267cdab4a966cf33f1b705eccb30b410731
MD5 51315d4574a9e21ee84ffd94f91a75f4
BLAKE2b-256 a0dcd09d7a70cdb363245c15ee01e01f361749eacfe2faa4185d0e56f6de37b3

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