Skip to main content

A modular optimization and machine learning workflow framework for automatic model selection, hyperparameter tuning, and performance benchmarking across diverse datasets.

Project description

OptiFlowX

PyPI version Python versions License: MIT Build Status

OptiFlowX is an open-source framework for hyperparameter optimization using combinatorial and metaheuristic algorithms.
It enables systematic exploration of search spaces for machine learning models using advanced stochastic and hybrid optimization techniques.


🔍 Overview

Machine learning models rely on carefully tuned hyperparameters.
Conventional methods such as grid or random search are inefficient when dealing with discrete, mixed, or high-dimensional spaces.

OptiFlowX provides a modular ecosystem that leverages combinatorial optimization and metaheuristics (evolutionary, swarm-based, and probabilistic methods) to efficiently discover optimal configurations.


⚙️ Key Features

  • Unified interface for multiple optimization algorithms.
  • Works with discrete, categorical, and continuous parameter spaces.
  • Includes multiple strategies:
    • Genetic Algorithm (GA)
    • Particle Swarm Optimization (PSO)
    • Bayesian Optimization
    • Tree-structured Parzen Estimator (TPE)
    • Random Search
    • Simulated Annealing
  • Scalable, parallel execution support.
  • Compatible with any ML framework (scikit-learn, PyTorch, TensorFlow, etc.).

⚗️ Installation

pip install optiflowx

or from source:

git clone https://github.com/Faycal214/optiflowx.git
cd optiflowx
pip install -e .

🧠 Example Usage

from sklearn.datasets import make_classification
from optiflowx.optimizers.genetic import GeneticOptimizer
from optiflowx.optimizers.pso import PSOOptimizer
from optiflowx.optimizers.bayesian import BayesianOptimizer
from optiflowx.optimizers.tpe import TPEOptimizer
from optiflowx.optimizers.random_search import RandomSearchOptimizer
from optiflowx.optimizers.simulated_annealing import SimulatedAnnealingOptimizer
from optiflowx.models.configs.random_forest_config import RandomForestConfig


# 1. Generate sample dataset
X, y = make_classification(
    n_samples=100,
    n_features=10,
    n_informative=8,
    n_redundant=2,
    random_state=42,
)

# 2. Load model configuration and search space
cfg = RandomForestConfig()
search_space = cfg.build_search_space()
model_class = cfg.get_wrapper().model_class

# 3. Define optimizers to test
optimizers = [
    ("pso", PSOOptimizer, {"n_particles": 10, "w": 0.7, "c1": 1.4, "c2": 1.4}),
    ("genetic", GeneticOptimizer, {"population": 10, "mutation_prob": 0.3}),
    ("bayesian", BayesianOptimizer, {"n_initial_points": 5}),
    ("tpe", TPEOptimizer, {"population_size": 10}),
    ("random_search", RandomSearchOptimizer, {"n_samples": 20}),
    (
        "simulated_annealing",
        SimulatedAnnealingOptimizer,
        {
            "population_size": 10,
            "initial_temp": 1.0,
            "cooling_rate": 0.9,
            "mutation_rate": 0.3,
        },
    ),
]

# 4. Run each optimizer and print results
for opt_name, opt_class, opt_params in optimizers:
    print(f"\n{'='*30}\nTesting optimizer: {opt_name}\n{'='*30}")
    optimizer = opt_class(
        search_space=search_space,
        metric="accuracy",
        model_class=model_class,
        X=X,
        y=y,
        **opt_params,
    )

    best_params, best_score = optimizer.run(max_iters=5)
    print(f"Result for {opt_name} → score={best_score:.4f}, params={best_params}")

🧪 Testing

pytest -v --maxfail=1 --disable-warnings

📚 Citation

@software{optiflowx,
  author = {Faycal, Billel},
  title = {OptiFlowX: Combinatorial Hyperparameter Optimization Framework},
  year = {2025},
  url = {https://github.com/Faycal214/optiflowx}
}

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

optiflowx-0.0.4.tar.gz (27.3 kB view details)

Uploaded Source

Built Distribution

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

optiflowx-0.0.4-py3-none-any.whl (39.4 kB view details)

Uploaded Python 3

File details

Details for the file optiflowx-0.0.4.tar.gz.

File metadata

  • Download URL: optiflowx-0.0.4.tar.gz
  • Upload date:
  • Size: 27.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for optiflowx-0.0.4.tar.gz
Algorithm Hash digest
SHA256 2fff67aebf83f3e4bdd1052b9235178ac708fb4acfe3ec489d7ffc59418a4f3b
MD5 882a508f7844e2a3b75d8097c1eb01de
BLAKE2b-256 8598574885dd6182b4c429a2d67207bd937e593f97423c56149316c6c3fa2d55

See more details on using hashes here.

File details

Details for the file optiflowx-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: optiflowx-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 39.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for optiflowx-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 05038cba7c9841c97ebf63bcf45f031b781e6139aa4c84ae8764946c7c274f58
MD5 81598f6915051e566aa5fdd897dd54ee
BLAKE2b-256 51f9bfbefc8589d03cb68066b4769a87f994631038d059472205b6c1911f438f

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