MetaPerceptron: A Standardized Framework for Metaheuristic-Trained Multi-Layer Perceptron
Project description
MetaPerceptron
(Metaheuristic-optimized Multi-Layer Perceptron) is a powerful and extensible Python library that
brings the best of both worlds: metaheuristic optimization and deep learning via Multi-Layer Perceptron (MLP).
Whether you're working with classic Gradient Descent techniques or state-of-the-art metaheuristic algorithms
like GA, PSO, WOA, DE, etc., MetaPerceptron
has you covered. With MetaPerceptron
, you can perform searches,
feature selection, and hyperparameter tuning using the features provided by the Scikit-Learn library.
🚀 Features at a Glance
- 🔧 Estimators:
MlpRegressor
,MlpClassifier
,MhaMlpRegressor
,MhaMlpClassifier
- 📊 Utilities:
MhaMlpTuner
,MhaMlpComparator
- 🧠 Model Zoo:
- 200+ Metaheuristic-trained MLP Regressors
- 200+ Metaheuristic-trained MLP Classifiers
- 12 Gradient Descent-trained MLP Regressors
- 12 Gradient Descent-trained MLP Classifiers
- 📏 67+ Performance Metrics (47 for regression, 20 for classification)
- ⚙️ Support: GPU support (for GD-based models), Scikit-learn compatible API
- 📚 Documentation: https://metaperceptron.readthedocs.io
- 🐍 Python: 3.8+
- 📦 Dependencies: numpy, scipy, scikit-learn, pytorch, mealpy, pandas, permetrics
📖 Citation
If MetaPerceptron supports your work, please consider citing the following:
@article{van2025metaperceptron,
title={MetaPerceptron: A Standardized Framework for Metaheuristic-Driven Multi-Layer Perceptron Optimization},
author={Van Thieu, Nguyen and Mirjalili, Seyedali and Garg, Harish and Hoang, Nguyen Thanh},
journal={Computer Standards \& Interfaces},
pages={103977},
year={2025},
publisher={Elsevier},
doi={10.1016/j.csi.2025.103977},
url={https://doi.org/10.1016/j.csi.2025.103977}
}
@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}
}
@article{van2023groundwater,
title={Groundwater level modeling using Augmented Artificial Ecosystem Optimization},
author={Van Thieu, Nguyen and Barma, Surajit Deb and Van Lam, To and Kisi, Ozgur and Mahesha, Amai},
journal={Journal of Hydrology},
volume={617},
pages={129034},
year={2023},
publisher={Elsevier},
doi={10.1016/j.jhydrol.2022.129034}
}
🧪 Quick Start
Install the latest version using pip:
pip install metaperceptron
After that, check the version to ensure successful installation:
import metaperceptron
print(metaperceptron.__version__)
✅ Import core components
Here is how you can import all provided classes from MetaPerceptron
from metaperceptron import DataTransformer, Data
from metaperceptron import MhaMlpRegressor, MhaMlpClassifier, MlpRegressor, MlpClassifier
from metaperceptron import MhaMlpTuner, MhaMlpComparator
🔍 Example: Training an MLP Classifier with Genetic Algorithm
In this tutorial, we will use Genetic Algorithm to train Multi-Layer Perceptron network for classification task. For more complex examples and use cases, please check the folder examples.
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from metaperceptron import DataTransformer, MhaMlpClassifier
## Load the dataset
X, y = load_iris(return_X_y=True)
## Split train and test
X_train, y_train, X_test, y_test = train_test_split(X, y, test_size=0.2)
## Scale dataset with two methods: standard and minmax
dt = DataTransformer(scaling_methods=("standard", "minmax"))
X_train_scaled = dt.fit_transform(X_train)
X_test_scaled = dt.transform(X_test)
## Define Genetic Algorithm-trained Multi-Layer Perceptron
model = MhaMlpClassifier(hidden_layers=(50, 15), act_names="Tanh",
dropout_rates=None, act_output=None,
optim="BaseGA", optim_params={"epoch": 100, "pop_size": 20, "name": "GA"},
obj_name="F1S", seed=42, verbose=True)
## Train the model
model.fit(X=X_train_scaled, y=y_train)
## Test the model
y_pred = model.predict(X_test)
print(y_pred)
## Print the score
print(model.score(X_test_scaled, y_test))
## Calculate some metrics
print(model.evaluate(y_true=y_test, y_pred=y_pred, list_metrics=["AS", "PS", "RS", "F2S", "CKS", "FBS"]))
💬 Support
- 📦 Source Code
- 📖 Documentation
- ⬇️ PyPI Releases
- ❗ Report Issues
- 📝 Changelog
- 💬 Chat Group
Developed by: Thieu @ 2025
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
Built Distribution
File details
Details for the file metaperceptron-2.2.0.tar.gz
.
File metadata
- Download URL: metaperceptron-2.2.0.tar.gz
- Upload date:
- Size: 50.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
418d9b7ecb83056e8e760408f75a19b0f3f08d9338eca4e18cc879cb7460e03a
|
|
MD5 |
3d98e39409a1e6c712432d5c94c6c653
|
|
BLAKE2b-256 |
f66e40ecb69c0101d98a850f76871c65cfe7734d123fb3d3a58aafed3ea11f47
|
Provenance
The following attestation bundles were made for metaperceptron-2.2.0.tar.gz
:
Publisher:
publish-package.yml
on thieu1995/MetaPerceptron
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
metaperceptron-2.2.0.tar.gz
-
Subject digest:
418d9b7ecb83056e8e760408f75a19b0f3f08d9338eca4e18cc879cb7460e03a
- Sigstore transparency entry: 229567193
- Sigstore integration time:
-
Permalink:
thieu1995/MetaPerceptron@b8dbd4444a225842cd79c399e6063cc241cc5169
-
Branch / Tag:
refs/tags/v2.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@b8dbd4444a225842cd79c399e6063cc241cc5169
-
Trigger Event:
release
-
Statement type:
File details
Details for the file metaperceptron-2.2.0-py3-none-any.whl
.
File metadata
- Download URL: metaperceptron-2.2.0-py3-none-any.whl
- Upload date:
- Size: 46.6 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 |
e5ba548d31e508446eb2a696709d03a4c79048bd76130fe2b19f5775b8857211
|
|
MD5 |
f00799c8780ab07b5344478140937842
|
|
BLAKE2b-256 |
e18ca7730f2049b55b29e518206c689ae49e1ac1fa1ad449b08a127ff71afc41
|
Provenance
The following attestation bundles were made for metaperceptron-2.2.0-py3-none-any.whl
:
Publisher:
publish-package.yml
on thieu1995/MetaPerceptron
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
metaperceptron-2.2.0-py3-none-any.whl
-
Subject digest:
e5ba548d31e508446eb2a696709d03a4c79048bd76130fe2b19f5775b8857211
- Sigstore transparency entry: 229567203
- Sigstore integration time:
-
Permalink:
thieu1995/MetaPerceptron@b8dbd4444a225842cd79c399e6063cc241cc5169
-
Branch / Tag:
refs/tags/v2.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@b8dbd4444a225842cd79c399e6063cc241cc5169
-
Trigger Event:
release
-
Statement type: