Metadata-Version: 2.4
Name: redrvfl
Version: 0.1.2
Summary: RVFL, Ensemble Deep RVFL, and Recurrent Ensemble Deep RVFL models for regression and forecasting.
Author: Aryan Bhambu
License-Expression: MIT
Project-URL: Homepage, https://github.com/statsdl/RedRVFL
Project-URL: Issues, https://github.com/statsdl/RedRVFL/issues
Keywords: rvfl,edrvfl,redrvfl,time-series,forecasting,ridge-regression,machine-learning
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.21
Requires-Dist: pandas>=1.3
Requires-Dist: scipy>=1.7
Requires-Dist: scikit-learn>=1.0
Provides-Extra: tuning
Requires-Dist: hyperopt>=0.2.7; extra == "tuning"
Requires-Dist: setuptools<81; extra == "tuning"
Provides-Extra: finance
Requires-Dist: yfinance>=0.2; extra == "finance"
Provides-Extra: plots
Requires-Dist: matplotlib>=3.5; extra == "plots"
Provides-Extra: all
Requires-Dist: hyperopt>=0.2.7; extra == "all"
Requires-Dist: matplotlib>=3.5; extra == "all"
Requires-Dist: setuptools<81; extra == "all"
Requires-Dist: yfinance>=0.2; extra == "all"
Provides-Extra: dev
Requires-Dist: build; extra == "dev"
Requires-Dist: hyperopt>=0.2.7; extra == "dev"
Requires-Dist: matplotlib>=3.5; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Requires-Dist: setuptools<81; extra == "dev"
Requires-Dist: twine; extra == "dev"
Requires-Dist: yfinance>=0.2; extra == "dev"
Dynamic: license-file

# RedRVFL

RedRVFL is a lightweight Python package for financial time-series forecasting with
Random Vector Functional Link models:

- `RVFLRegressor`: single hidden-layer RVFL with ridge readout.
- `EDRVFLRegressor`: ensemble deep RVFL with independent layer readouts.
- `REDRVFLRegressor`: recurrent ensemble deep RVFL for ordered time-series frames.
- Hyperopt/TPE tuning for RVFL.
- Layerwise Hyperopt/TPE tuning for EDRVFL and REDRVFL.

## Installation

Core install:

```bash
git clone https://github.com/statsdl/RedRVFL.git
cd RedRVFL
pip install .
```

Finance experiment dependencies:

```bash
pip install ".[finance]"
```

For development:

```bash
pip install -e ".[dev]"
pytest
```

## Financial Time Series Forecasting Example

```python
from redrvfl.finance import download_dji, run_dji_paper_experiment

download_dji("datasets/DJI.csv")
results = run_dji_paper_experiment(
    dataset_path="datasets/DJI.csv",
    seeds=(0,),
    horizon=20,
    look_ahead=1,
    n_layers=10,
    max_evals=100,
)
```

The split follows the paper: 70% training, 10% validation, and 20% test in
chronological order. Hyperparameters are selected on validation data, then the
model is fitted on train+validation and evaluated on the final test segment.

Command-line usage:

```bash
python examples/run_finance_forecasting.py --download --seeds 0 --horizon 20 --look-ahead 1
python examples/run_finance_forecasting.py --seeds 0,1,2
```

## Hyperopt Tuning

```python
from hyperopt import hp
from redrvfl.tuning import layerwise_tune_redrvfl

result = layerwise_tune_redrvfl(
    X,
    y,
    n_layers=10,
    layer_space={
        "n_hidden": hp.quniform("n_hidden", 20, 200, 1),
        "regularization": hp.uniform("regularization", 0, 1),
        "input_scale": hp.uniform("input_scale", 0, 1),
    },
    fixed_params={
        "recurrent_scale": 0.1,
        "random_state": 0,
    },
    validation_fraction=0.1 / 0.8,
    max_evals=100,
)
```

## API

Supported package code lives in `src/redrvfl`.

All estimators expose:

- `fit(X, y)`: train readout weights.
- `predict(X)`: return predictions.
- `predict(X, return_layers=True)`: for EDRVFL/REDRVFL, return each layer's prediction.

`make_forecasting_frame(series, order, horizon)` converts a time series into supervised lagged samples.

Finance and tuning utilities are intentionally imported from submodules:

- `redrvfl.tuning`
- `redrvfl.finance`

This keeps `import redrvfl` lightweight and avoids importing optional Hyperopt
and Yahoo Finance dependencies unless they are needed.

## Repository Notes

The `legacy/`, `utils/`, `RecRVFL_/`, and `ForecastLib.py` files are retained
for traceability to earlier research scripts. They are not included in the
published wheel and are not the supported package API.

## PyPI Release

The publish workflow uses PyPI Trusted Publishing. Configure the PyPI trusted
publisher with:

- owner: `statsdl`
- repository: `RedRVFL`
- workflow: `publish.yml`
- environment: `pypi`

## License

MIT

## Reference

If you use RedRVFL in your work, please cite:

```bibtex
@article{bhambu2024recurrent,
  title={Recurrent ensemble random vector functional link neural network for financial time series forecasting},
  author={Bhambu, Aryan and Gao, Ruobin and Suganthan, Ponnuthurai Nagaratnam},
  journal={Applied Soft Computing},
  volume={161},
  pages={111759},
  year={2024},
  publisher={Elsevier}
}
```
