Skip to main content

RFT and edRFT models for significant wave-height time-series forecasting.

Project description

edRFT: Deep Random Vector Functional Link Transformer Network

🌊 Fast randomized transformer models for significant wave-height forecasting 🌊

Tests PyPI Python License

edRFT provides research-grade implementations of Random Vector Functional Link Transformer models for regression and significant wave-height forecasting. The package includes a shallow RFT model, an ensemble deep edRFT model with multiple output layers, forecasting utilities, error metrics, and Hyperopt-based tuning helpers.

The method combines randomized transformer feature mappings with closed-form ridge readouts, giving a practical balance between deep representation learning and efficient training.

Contents

Use Cases

🌊 Ocean and Coastal Forecasting

  • Significant wave-height forecasting
  • Buoy-based marine condition prediction
  • Short-horizon ocean-state modelling

📈 Time-Series Forecasting

  • Regression with lagged input windows
  • Multi-step forecasting experiments
  • Nonlinear temporal pattern learning

🔬 Research Prototyping

  • Randomized neural network baselines
  • Transformer-enhanced RVFL experiments
  • Fast benchmarking with ridge-regression readouts

Key Features

🎯 Methodology

  • Random Vector Functional Link Transformer (RFT) model
  • Ensemble deep RFT (edRFT) with one output readout per hidden layer
  • Randomized transformer blocks with fixed hidden weights
  • Closed-form ridge-regression readouts
  • Forecasting-frame creation utilities
  • RMSE, MAPE, and MASE metrics

⚡ Practical Workflow

  • Lightweight core API
  • Optional wave-forecasting utilities
  • Hyperopt/TPE tuning helpers
  • Reproducible random_state support
  • GitHub Actions test and PyPI release workflows

Why edRFT?

Feature Classical RVFL Transformer Models edRFT
Randomized hidden mapping
Transformer-based feature interaction
Closed-form output-layer training
Multiple output layers ⚠️ Architecture-dependent
Fast regression-style fitting
Time-series forecasting utilities ⚠️ Manual ⚠️ Manual

Installation

Install the core package from PyPI:

pip install edrft

Install optional wave-forecasting dependencies:

pip install "edrft[wave]"

Install from source:

git clone https://github.com/statsdl/edRFT.git
cd edRFT
pip install -e ".[dev]"
pytest

Requirements

Core requirements:

  • Python >= 3.10
  • NumPy
  • PyTorch

Optional dependencies:

  • hyperopt for tuning
  • pandas for wave data loading
  • build, twine, and pytest for development and release workflows

Quick Start

import numpy as np
from edrft import EDRFTRegressor, make_forecasting_frame

# Create a simple univariate forecasting dataset
series = np.sin(np.linspace(0, 16, 240))
X, y = make_forecasting_frame(series, order=4, horizon=1)

# Train/test split
X_train, y_train = X[:180], y[:180]
X_test = X[180:]

# Fit edRFT
model = EDRFTRegressor(
    n_layers=3,
    n_hidden=32,
    regularization=1e-3,
    random_state=0,
)
model.fit(X_train, y_train)

# Forecast
pred = model.predict(X_test)
print(pred[:5])

RFT Example

import numpy as np
from edrft import RFTRegressor

rng = np.random.default_rng(0)
X = rng.normal(size=(200, 6))
y = X[:, 0] - 0.3 * X[:, 1] + np.sin(X[:, 2])

model = RFTRegressor(n_hidden=64, random_state=0)
model.fit(X[:150], y[:150])
pred = model.predict(X[150:])

Wave Forecasting Demo

The repository includes a command-line demo for buoy-based significant wave-height forecasting:

python examples/run_wave_forecasting.py   --data-dir wave   --stations 46001h   --years 2017   --seeds 0   --look-back 48   --horizon 4   --layers 10   --max-evals 100

The demo prints RMSE, MAPE, MASE, tuning time, training time, testing time, and selected hyperparameters.

Hyperparameter Tuning

from edrft.tuning import layerwise_tune_edrft

result = layerwise_tune_edrft(
    X,
    y,
    n_layers=10,
    validation_fraction=0.125,
    max_evals=100,
    random_state=0,
)

print(result.best_params)
print(result.history[-1])

Mathematical Overview

For an input vector x, an RFT hidden layer creates a randomized transformer feature map:

h = phi(T(x; W_T), W_p)

where T is a transformer encoder with fixed randomized parameters, W_p is a randomized projection, and phi is a nonlinear activation. The output is learned with ridge regression:

beta = argmin ||H beta - y||² + lambda ||beta||²

The edRFT model stacks multiple randomized transformer layers and learns a separate output readout at each layer. Final prediction is obtained by aggregating the layer-wise predictions, for example by median or mean aggregation.

Repository Layout

src/edrft/        Supported package API
examples/         Usage examples
tests/            Unit tests
.github/          CI and PyPI publishing workflows
wave/             Sample wave-height data files
legacy/           Archived research scripts for traceability

The supported public API lives in src/edrft. Use the examples and package modules for new work.

Getting Help

Contributing

Contributions are welcome. Please open an issue or pull request for bug fixes, documentation improvements, tests, or examples.

Before submitting changes, run:

pip install -e ".[dev]"
pytest

License

This project is distributed under the MIT License. See LICENSE for details.

Citation

If you use edRFT in your work, please cite:

@article{bhambu2025deep,
  title={Deep random vector functional link transformer network with multiple output layers for significant wave height forecasting},
  author={Bhambu, Aryan and Gao, Ruobin and Suganthan, Ponnuthurai Nagaratnam and Selvaraju, Natarajan},
  journal={Applied Soft Computing},
  pages={114136},
  year={2025},
  publisher={Elsevier}
}

Acknowledgments

edRFT builds on concepts from randomized neural networks, RVFL models, transformer-based representation learning, and significant wave-height forecasting research.

If this package supports your work, please consider starring the repository.

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

edrft-0.1.1.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

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

edrft-0.1.1-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file edrft-0.1.1.tar.gz.

File metadata

  • Download URL: edrft-0.1.1.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for edrft-0.1.1.tar.gz
Algorithm Hash digest
SHA256 aaf2ebe06ac8107bac5406902e96f081d38d38cacbe97701f329ccc39aee2249
MD5 df1e4368c874323026202e05940c4667
BLAKE2b-256 5ba0c63799a1c3ea2d7486ce087458157a80c60a98a94ddd655bedf1a6d79edb

See more details on using hashes here.

Provenance

The following attestation bundles were made for edrft-0.1.1.tar.gz:

Publisher: publish.yml on statsdl/edRFT

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

File details

Details for the file edrft-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: edrft-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for edrft-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 65fc9668e7a2cd7fff2c257d44c7379a96f62552da2f3b9c759373ae4c6337f5
MD5 6db780fe283a24b577010a5bbbedd0f5
BLAKE2b-256 fbfc45539c89f9404a953b9680835f0ed51b278bbef6f992d7f7ec3c11c3935c

See more details on using hashes here.

Provenance

The following attestation bundles were made for edrft-0.1.1-py3-none-any.whl:

Publisher: publish.yml on statsdl/edRFT

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