WaveletML: A Scalable and Extensible Wavelet Neural Network Framework
Project description
WaveletML: A Scalable and Extensible Wavelet Neural Network Framework
📌 Overview
WaveletML is an open-source Python framework designed for building, training, and evaluating Wavelet Neural Networks (WNNs) tailored for supervised learning tasks such as regression and classification. Leveraging the power of PyTorch and the modularity of scikit-learn, WaveletML provides a unified, extensible, and scalable platform for researchers and practitioners to explore wavelet-based neural architectures.
Features
- ✅ Modular Wavelet Neural Network (WNN) architectures
- ✅ Support for multiple wavelet functions (e.g., Morlet, Mexican Hat)
- ✅ Support for multiple wavelet layers (e.g., Weighed Linear, Product, Summation, etc.)
- ✅ Gradient Descent-based training via Pytorch
- ✅ Metaheuristic Algorithm-based training via Mealpy
- ✅
scikit-learn-compatible API withBaseEstimatorsupport - ✅ Built-in support for both classification and regression tasks
- ✅ Customizable activation functions, training parameters, and loss functions
- ✅ Designed for scalability, enabling deployment on CPU or GPU environments.
Whether you're prototyping WNN-based models or conducting advanced experimental research, WaveletML aims to bridge the gap between theory and practical implementation in wavelet-based learning systems.
Model Types
GdWnnClassifier: Wavelet-based classifier using gradient-based trainingGdWnnRegressor: Wavelet-based regressor using gradient-based trainingMhaWnnClassifier: Uses metaheuristics (e.g., PSO, GA) for trainingMhaWnnRegressor: Wavelet-based regressor with metaheuristic training
📦 Installation
Install the latest version using pip:
pip install waveletml
After that, check the version to ensure successful installation:
$ python
>>> import waveletml
>>> waveletml.__version__
🚀 Quick Start
Classification
In this example, we will use Adam optimizer to train Wavelet Weighted Linear Neural Network (WNN) for a classification task.
from sklearn.datasets import load_iris
from waveletml import Data, GdWnnClassifier
## Load data object
X, y = load_iris(return_X_y=True)
data = Data(X, y)
## Split train and test
data.split_train_test(test_size=0.2, random_state=2, inplace=True, shuffle=True)
print(data.X_train.shape, data.X_test.shape)
## Scaling dataset
data.X_train, scaler_X = data.scale(data.X_train, scaling_methods=("standard", "minmax"))
data.X_test = scaler_X.transform(data.X_test)
data.y_train, scaler_y = data.encode_label(data.y_train)
data.y_test = scaler_y.transform(data.y_test)
print(type(data.X_train), type(data.y_train))
## Create model
model = GdWnnClassifier(size_hidden=10, wavelet_fn="morlet", act_output=None,
epochs=100, batch_size=16, optim="Adam", optim_params=None,
valid_rate=0.1, seed=42, verbose=True, device=None)
## Train the model
model.fit(X=data.X_train, y=data.y_train)
## Test the model
y_pred = model.predict(data.X_test)
print(y_pred)
print(model.predict_proba(data.X_test))
## Calculate some metrics
print(model.evaluate(y_true=data.y_test, y_pred=y_pred, list_metrics=["F2S", "CKS", "FBS", "PS", "RS", "NPV", "F1S"]))
## Print model parameters
for k, v in model.network.named_parameters():
print(f"{k}: {v.shape}, {v.data}")
Regression
In this example, we will use Genetic Algorithm - GA to train Wavelet Summation Neural Network (WNN) for a regression task.
from sklearn.datasets import load_diabetes
from waveletml import Data, MhaWnnRegressor, CustomWaveletSummationNetwork
## Load data object
X, y = load_diabetes(return_X_y=True)
data = Data(X, y)
## Split train and test
data.split_train_test(test_size=0.2, random_state=2, inplace=True)
print(data.X_train.shape, data.X_test.shape)
## Scaling dataset
data.X_train, scaler_X = data.scale(data.X_train, scaling_methods=("standard", "minmax"))
data.X_test = scaler_X.transform(data.X_test)
data.y_train, scaler_y = data.scale(data.y_train, scaling_methods=("standard", "minmax"))
data.y_test = scaler_y.transform(data.y_test.reshape(-1, 1))
print(type(data.X_train), type(data.y_train))
## Create model
model = MhaWnnRegressor(size_hidden=10, wavelet_fn="morlet", act_output=None,
optim="BaseGA", optim_params={"epoch": 40, "pop_size": 20},
obj_name="MSE", seed=42, verbose=True, wnn_type=CustomWaveletSummationNetwork,
lb=None, ub=None, mode='single', n_workers=None, termination=None)
## Train the model
model.fit(data.X_train, data.y_train)
## Test the model
y_pred = model.predict(data.X_test)
print(y_pred)
## Calculate some metrics
print(model.evaluate(y_true=data.y_test, y_pred=y_pred, list_metrics=["R2", "NSE", "MAPE", "NNSE"]))
## Print model parameters
for k, v in model.network.named_parameters():
print(f"{k}: {v.shape}, {v.data}")
Please read the examples folder for more use cases.
📚 Documentation
Documentation is available at: 👉 https://waveletml.readthedocs.io
You can build the documentation locally:
cd docs
make html
🧪 Testing
You can run unit tests using:
pytest tests/
🤝 Contributing
We welcome contributions to WaveletML! If you have suggestions, improvements, or bug fixes, feel free to fork
the repository, create a pull request, or open an issue.
📄 License
This project is licensed under the GPLv3 License. See the LICENSE file for more details.
Citation Request
Please include these citations if you plan to use this library:
@software{thieu20250525WaveletML,
author = {Nguyen Van Thieu},
title = {WaveletML: A Scalable and Extensible Wavelet Neural Network Framework},
month = June,
year = 2025,
doi = {10.6084/m9.figshare.29095376},
url = {https://github.com/thieu1995/WaveletML}
}
@article{van2023mealpy,
title={MEALPY: An open-source library for latest meta-heuristic algorithms in Python},
author={Van Thieu, Nguyen and Mirjalili, Seyedali},
journal={Journal of Systems Architecture},
year={2023},
publisher={Elsevier},
doi={10.1016/j.sysarc.2023.102871}
}
Official Links
- Official source code repo: https://github.com/thieu1995/WaveletML
- Official document: https://waveletml.readthedocs.io/
- Download releases: https://pypi.org/project/waveletml/
- Issue tracker: https://github.com/thieu1995/WaveletML/issues
- Notable changes log: https://github.com/thieu1995/WaveletML/blob/master/ChangeLog.md
- Official chat group: https://t.me/+fRVCJGuGJg1mNDg1
Developed by: Thieu @ 2025
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file waveletml-0.2.0.tar.gz.
File metadata
- Download URL: waveletml-0.2.0.tar.gz
- Upload date:
- Size: 48.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fdd37025590694dd8545e2d5adfae84024ee959e794d9f12fc429fc9596dc15c
|
|
| MD5 |
4d7d793566dc77ee8170fe7ad3826d35
|
|
| BLAKE2b-256 |
f51e02a681beac36bfb7a9082b98fd0771f68a7439a9241b19bf068e4ea0de43
|
Provenance
The following attestation bundles were made for waveletml-0.2.0.tar.gz:
Publisher:
publish-package.yml on thieu1995/WaveletML
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
waveletml-0.2.0.tar.gz -
Subject digest:
fdd37025590694dd8545e2d5adfae84024ee959e794d9f12fc429fc9596dc15c - Sigstore transparency entry: 229752930
- Sigstore integration time:
-
Permalink:
thieu1995/WaveletML@f077193d5865c4735764257e680b4a3b52634fd9 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/thieu1995
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-package.yml@f077193d5865c4735764257e680b4a3b52634fd9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file waveletml-0.2.0-py3-none-any.whl.
File metadata
- Download URL: waveletml-0.2.0-py3-none-any.whl
- Upload date:
- Size: 46.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b074cb88b01bf6598a6b0d8766aadebb939b31259b92007ae6faa1353d5264c4
|
|
| MD5 |
5db3621161bc425a6cef757d95c23d6a
|
|
| BLAKE2b-256 |
268d3e1d1a0f18d2063239ccafa9311747c293a99b079205479da1ccaca21724
|
Provenance
The following attestation bundles were made for waveletml-0.2.0-py3-none-any.whl:
Publisher:
publish-package.yml on thieu1995/WaveletML
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
waveletml-0.2.0-py3-none-any.whl -
Subject digest:
b074cb88b01bf6598a6b0d8766aadebb939b31259b92007ae6faa1353d5264c4 - Sigstore transparency entry: 229752936
- Sigstore integration time:
-
Permalink:
thieu1995/WaveletML@f077193d5865c4735764257e680b4a3b52634fd9 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/thieu1995
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-package.yml@f077193d5865c4735764257e680b4a3b52634fd9 -
Trigger Event:
release
-
Statement type: