Skip to main content

MetaPerceptron: A Standardized Framework for Metaheuristic-Trained Multi-Layer Perceptron

Project description

MetaPerceptron


GitHub release Wheel PyPI version PyPI - Python Version PyPI - Downloads Downloads Tests & Publishes to PyPI Documentation Status Chat DOI License: GPL v3

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


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

metaperceptron-2.2.0.tar.gz (50.5 kB view details)

Uploaded Source

Built Distribution

metaperceptron-2.2.0-py3-none-any.whl (46.6 kB view details)

Uploaded Python 3

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

Hashes for metaperceptron-2.2.0.tar.gz
Algorithm Hash digest
SHA256 418d9b7ecb83056e8e760408f75a19b0f3f08d9338eca4e18cc879cb7460e03a
MD5 3d98e39409a1e6c712432d5c94c6c653
BLAKE2b-256 f66e40ecb69c0101d98a850f76871c65cfe7734d123fb3d3a58aafed3ea11f47

See more details on using hashes here.

Provenance

The following attestation bundles were made for metaperceptron-2.2.0.tar.gz:

Publisher: publish-package.yml on thieu1995/MetaPerceptron

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

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

Hashes for metaperceptron-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e5ba548d31e508446eb2a696709d03a4c79048bd76130fe2b19f5775b8857211
MD5 f00799c8780ab07b5344478140937842
BLAKE2b-256 e18ca7730f2049b55b29e518206c689ae49e1ac1fa1ad449b08a127ff71afc41

See more details on using hashes here.

Provenance

The following attestation bundles were made for metaperceptron-2.2.0-py3-none-any.whl:

Publisher: publish-package.yml on thieu1995/MetaPerceptron

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 Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page