A modular optimization and machine learning workflow framework for hyperparameter tuning and performance benchmarking across diverse datasets.
Project description
OptiFlowX
OptiFlowX is a production-oriented, modular framework for hyperparameter and configuration optimization. It combines metaheuristic and probabilistic search algorithms with flexible search-space abstractions, an easy-to-use wrapper for models, and efficient parallel evaluation—designed for both research and production use.
Key capabilities:
- Optimize models for classification and regression tasks
- Support for scikit-learn models and user-supplied custom models
- Built-in metrics and user-provided custom metric callables
- Built-in search-space definitions and fully custom search spaces
- Parallel candidate evaluation with optional
dillfallback for non-pickleable callables
Table of contents
- Why OptiFlowX
- Key features
- Algorithms included
- Quickstart
- Examples
- Search space
- Parallelism & multiprocessing notes
- API reference (quick)
- Development & testing
- Contributing
- License
- Contact & citation
Why OptiFlowX
- Single, consistent API across many optimizers (metaheuristics and probabilistic methods)
- Production-minded: packaged with docs, examples, tests, and CI
- Extensible — add new optimizers, model wrappers, or search-space primitives
Key features
- Unified optimizer interface (PSO, GA, ACO, GWO, SA, TPE, Bayesian, Random Search)
- Classification and regression support
- Plug-and-play model configs (
optiflowx.models.configs.*) andModelWrapperfor CV and final fitting - Built-in metric helpers and a
get_metric()abstraction that normalizes regression metrics for maximization - Flexible
SearchSpacesupporting continuous, discrete, and categorical parameters with sampling and grid generation - Parallel evaluation via
ParallelExecutorwith pickle/dill serialization fallbacks
Algorithms included
- Metaheuristics / Combinatorial:
- Particle Swarm Optimization (PSO)
- Genetic Algorithm (GA)
- Simulated Annealing (SA)
- Ant Colony Optimization (ACO)
- Grey Wolf Optimizer (GWO)
- Probabilistic / Bayesian & related:
- Tree-Structured Parzen Estimator (TPE)
- Bayesian Optimization
- Random Search
All algorithms are implemented under optiflowx.optimizers.*. Most optimizers expose a run(max_iters=...) method that returns (best_params, best_score).
Quickstart
Install (recommended inside a virtual environment):
python -m venv venv
source venv/bin/activate
pip install -e .
# Optional extras
pip install dill xgboost
Minimal example (random forest + PSO):
from sklearn.datasets import make_classification
from optiflowx.models.configs import RandomForestConfig
from optiflowx.optimizers import PSOOptimizer
X, y = make_classification(n_samples=200, n_features=12, random_state=0)
cfg = RandomForestConfig()
wrapper = cfg.get_wrapper(task_type="classification")
opt = PSOOptimizer(
search_space=cfg.build_search_space(),
metric="accuracy",
model_class=wrapper.model_class,
X=X, y=y,
n_particles=12,
)
best_params, best_score = opt.run(max_iters=10)
print(best_score, best_params)
Examples
The examples/ directory contains runnable scripts covering common combinations:
- classification with sklearn models and sklearn/custom metrics
- regression with sklearn models and sklearn/custom metrics
- examples that use
CustomModelConfigfor user-defined model wrappers
Run one of the example scripts directly:
python examples/classification/classification_sklearn_model_sklearn_metric.py
Search space
Use built-in configs for quick starts (e.g., RandomForestConfig().build_search_space()), or create custom spaces with optiflowx.core.search_space.SearchSpace:
from optiflowx.core import SearchSpace
s = SearchSpace()
s.add("n_estimators", "discrete", [10, 50, 100, 200])
s.add("learning_rate", "continuous", [1e-3, 0.3], log=True)
s.add("criterion", "categorical", ["gini", "entropy"])
Parallelism & multiprocessing notes
ParallelExecutor uses multiprocessing.Pool to evaluate candidates concurrently. If you pass non-pickleable callables (e.g., nested functions or closures) as custom metrics, the executor will:
- Try to serialize with
pickle. - If
picklefails anddillis installed, it will serialize usingdill. - If serialization is not possible and multiple workers are requested, the executor raises an error. If only one worker is used it will fall back to sequential evaluation.
If you plan to pass nested custom metrics and want parallel execution, install dill:
pip install dill
API reference — quick
High-level building blocks (see docstrings for full signatures):
optiflowx.core.SearchSpace— define and sample hyperparameter spacesoptiflowx.core.ModelWrapper— cross-val evaluation and final fittingoptiflowx.core.get_metric— normalized metric callables (negates regression errors so optimizers maximize)optiflowx.core.ParallelExecutor— parallel candidate evaluationoptiflowx.optimizers.*— concrete optimizers (e.g.,PSOOptimizer,GeneticOptimizer)optiflowx.models.configs.*— model configs exposingbuild_search_space()andget_wrapper()
Typical high-level flow:
- Select model config from
optiflowx.models.registry.MODEL_REGISTRY. - Build its
SearchSpaceandModelWrapper. - Initialize an optimizer with the space, metric,
model_class, and data. - Run
optimizer.run(max_iters=...)or useoptiflowx.core.OptimizationEngine/MLPipelineto orchestrate runs.
Development & testing
Run tests locally (recommended in a virtualenv):
pip install -r requirements-test.txt
pytest -q
Developer tools (optional):
pip install black ruff mypy pytest pytest-cov
ruff check .
black .
mypy optiflowx
Contributing
Contributions welcome. Please follow these steps:
- Open an issue describing the feature or bug.
- Create a topic branch in your fork.
- Add tests for any new behavior.
- Submit a PR with a clear description and changelog entry.
If you plan to add new optimizers or model configs, aim for:
- clear docstrings and examples under
examples/; - unit tests in
tests/exercising the integration (optimizer + wrapper + executor); - lightweight, focused commits.
License
This project is licensed under the MIT License — see the LICENSE file for details.
Contact & citation
If you use OptiFlowX in research or production, please cite:
@software{optiflowx,
author = {Faycal, Alikacem},
title = {OptiFlowX: Combinatorial Hyperparameter Optimization Framework},
year = {2025},
url = {https://github.com/Faycal214/optiflowx}
}
Contact:
- Author: Alikacem Faycal
- Email: faycal213.dz@gmail.com
Acknowledgements
This project draws on many open-source tools and libraries including scikit-learn, Optuna, scikit-optimize, and others. See pyproject.toml for declared dependencies.
If you'd like, I can also:
- run the test suite in this environment and report results,
- produce a condensed one-page quick reference for the most common API calls,
- add badges for coverage/Docs/CodeQL if you want to include them in CI.
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file optiflowx-0.0.8.tar.gz.
File metadata
- Download URL: optiflowx-0.0.8.tar.gz
- Upload date:
- Size: 258.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d71b3f3eb1d780c1e1f6bbac9b01b2624e0f9c964d95ee86cb55163ab19399e6
|
|
| MD5 |
1fb50234d9bce914f0a145c91f34d0bd
|
|
| BLAKE2b-256 |
b04011f51fc30146821ebe472d5a48adb4b2af08c2fdd5eeb26028d09b106c13
|
File details
Details for the file optiflowx-0.0.8-py3-none-any.whl.
File metadata
- Download URL: optiflowx-0.0.8-py3-none-any.whl
- Upload date:
- Size: 52.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a077d9a9aa593a6d2e53ce4a6bb82663eb518c0fcd7a03bf02301adc23efef7f
|
|
| MD5 |
44fd65c858bd649d6755cad78ea612c7
|
|
| BLAKE2b-256 |
9606d9f3a80dfa9a39e9c478cb3bf8d41e6eda032a2819a48f4dfd848dd72490
|