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
Release files for metaperceptron 2.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| metaperceptron-2.2.0.tar.gz | 50.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| metaperceptron-2.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 97.1 kB
Release files / metaperceptron-2.2.0.tar.gz
| Download URL | metaperceptron-2.2.0.tar.gz |
|---|---|
| Size | 50.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
418d9b7ecb83056e8e760408f75a19b0f3f08d9338eca4e18cc879cb7460e03a
|
|
BLAKE2b-256 checksum How to use checksums |
f66e40ecb69c0101d98a850f76871c65cfe7734d123fb3d3a58aafed3ea11f47
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 4, 2025.
Transparency logRelease files / metaperceptron-2.2.0-py3-none-any.whl
| Download URL | metaperceptron-2.2.0-py3-none-any.whl |
|---|---|
| Size | 46.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e5ba548d31e508446eb2a696709d03a4c79048bd76130fe2b19f5775b8857211
|
|
BLAKE2b-256 checksum How to use checksums |
e18ca7730f2049b55b29e518206c689ae49e1ac1fa1ad449b08a127ff71afc41
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 4, 2025.
Transparency log