Skip to main content

MetaGen: A framework for metaheuristic development and hyperparameter optimization in machine and deep learning.

Project description

MetaGen: A Framework for Metaheuristic Development and Hyperparameter Optimization

Python Latest Release Documentation

🚀 Why MetaGen?

MetaGen simplifies the development of metaheuristics and the optimization of hyperparameters in machine learning and deep learning. Whether you're a researcher, developer, or practitioner, MetaGen provides a structured, flexible, and scalable framework.

🔹 Key Features

Metaheuristic Development Framework – Simplifies the creation of custom metaheuristics.
Hyperparameter Optimization Tools – Supports both layer and architecture-level tuning in deep learning.
Standardized Interface – Ensures compatibility between metaheuristic developers and end users.
Dynamic Architecture Optimization – Adapts model structures dynamically during execution.
Seamless Integration – Compatible with scikit-learn, tensorflow, pytorch, and other ML libraries.
Built-in Metaheuristics – Pre-implemented algorithms ready to use.
Performance Analysis Tools – Integrated visualization tools for analyzing metaheuristic performance.
Scalable and Distributed Execution – Metaheuristics can run efficiently across multiple nodes.

📌 Built-in Metaheuristics

MetaGen includes a collection of powerful metaheuristics:

  • Random Search
  • Tabu Search
  • Simulated Annealing
  • Tree-Parzen Estimator
  • Memetic Algorithm
  • Genetic Algorithm
  • Steady-State Genetic Algorithm
  • Coronavirus Optimization Algorithm (CVOA)

📦 Installation

MetaGen requires Python 3.10+ and can be installed with:

pip install pymetagen-datalabupo

📖 Documentation

The official API reference and usage guides are available at: MetaGen Documentation

🛠 Example: Developing a Metaheuristic

Creating a simple Random Search metaheuristic:

from copy import deepcopy
from typing import Callable, List
from metagen.framework import Domain, Solution

class RandomSearch:

    def __init__(self, domain: Domain, fitness: Callable[[Solution], float], search_space_size: int = 30,
                iterations: int = 20) -> None:

        self.domain = domain
        self.fitness = fitness
        self.search_space_size = search_space_size
        self.iterations = iterations

    def run(self) -> Solution:

        potential_solutions: List[Solution] = list()

        for _ in range(0, self.search_space_size):
            potential_solutions.append(Solution(self.domain, connector=self.domain.get_connector()))

        solution: Solution = deepcopy(min(potential_solutions))

        for _ in range(0, self.iterations):
            for ps in potential_solutions:
                ps.mutate()

                ps.evaluate(self.fitness)
                if ps < solution:
                    solution = deepcopy(ps)

        return solution

🤖 Example: Hyperparameter Optimization

Optimizing hyperparameters for a regression model:

from metagen.framework import Domain, Solution
from metagen.metaheuristics.rs import RandomSearch
from sklearn.datasets import make_regression
from sklearn.linear_model import SGDRegressor
from sklearn.model_selection import cross_val_score

# Generate synthetic dataset
X, y = make_regression(n_samples=1000, n_features=4)

# Define the search space
regression_domain = Domain()
regression_domain.define_real("alpha", 0.0001, 0.001)
regression_domain.define_integer("iterations", 5, 200)
regression_domain.define_categorical("loss", ["squared_error", "huber", "epsilon_insensitive"])

# Fitness function
def regression_fitness(solution: Solution):
    model = SGDRegressor(
        loss=solution["loss"],
        alpha=solution["alpha"],
        max_iter=solution["iterations"]
    )
    mape = cross_val_score(model, X, y, scoring="neg_mean_absolute_percentage_error").mean() * -1
    return mape

# Run optimization
best_solution = RandomSearch(regression_domain, regression_fitness).run()
print(best_solution)

🤝 Contributing

We welcome contributions from developers of all experience levels! To contribute:

  • Open an issue or submit a pull request.

  • Run tests using:

    pytest test
    

📌 Resources


MetaGen is an open-source project developed and maintained by:

  • David Gutiérrez-Avilés
  • Manuel Jesús Jiménez-Navarro
  • Francisco José Torres-Maldonado
  • Francisco Martínez-Álvarez

All authors are members of DataLabUPO, the Data Science & Big Data Research Lab at Pablo de Olavide University.

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

pymetagen_datalabupo-0.2.1.tar.gz (65.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pymetagen_datalabupo-0.2.1-py3-none-any.whl (104.0 kB view details)

Uploaded Python 3

File details

Details for the file pymetagen_datalabupo-0.2.1.tar.gz.

File metadata

  • Download URL: pymetagen_datalabupo-0.2.1.tar.gz
  • Upload date:
  • Size: 65.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for pymetagen_datalabupo-0.2.1.tar.gz
Algorithm Hash digest
SHA256 4a8456db592a96bbf6f066a140b105c9a1bb9cf4764733c207673c9e3cd16cbf
MD5 440f2594c9920723a4fcc34bcfc3e6a2
BLAKE2b-256 1ade3a0d5e37cd67183f1cd075e61acb785ed844a1885c24d740b76f44152cd7

See more details on using hashes here.

File details

Details for the file pymetagen_datalabupo-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pymetagen_datalabupo-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c587a0f3cfc70e6ac17dce78ba3a2fa68147cbd51b895ded55a5bcbcf79cf5ec
MD5 45d26e954fc1d91007b3c061a03c5a67
BLAKE2b-256 3378331ce65a8d88640f07ff90b5ebbcf34a82c1dc612447a46512e8b67cd464

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page