Repository navigation
Add genetic search for hyperparameter optimization - #527
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
Resource serialization validation and type-preserving candidate deduplication require correction.
No open issues 🎉
What changed in this PR
Adds GeneticSearch, a genetic algorithm-based hyperparameter optimizer for discrete search spaces, with tests, benchmarks, documentation, and integration updates.
Changes:
- Implements selection, crossover, mutation, elitism, scoring, and serialization.
- Adds focused tests and a benchmark.
- Updates tuning documentation, navigation, and changelog.
| File | Description |
|---|---|
tests/Base/GeneticSearchTest.php |
Functional and validation tests |
src/GeneticSearch.php |
Genetic hyperparameter search implementation |
mkdocs.yml |
Documentation navigation entry |
docs/hyper-parameter-tuning.md |
Tuning strategy guidance |
docs/genetic-search.md |
Reference documentation |
CHANGELOG.md |
Unreleased feature entry |
benchmarks/Base/GeneticSearchBench.php |
Performance benchmark |
Review effort: Lite
andrewdalpino
left a comment
There was a problem hiding this comment.
Very cool @ahbaqdadi! I see you have some experience with genetic algorithms - is this something you came up with yourself?
On the surface the PR looks good, nice and clean, and adheres well to the existing design. I'll take a closer look ASAP.
|
Thanks, @andrewdalpino ! Yes, I have some prior experience with genetic algorithms, and I thought genetic search would be a nice addition to Rubix ML. I adapted the standard approach to fit the project's existing search APIs. I appreciate you taking a closer look, and I'll update the benchmark sizes you pointed out. |
|
By any chance @ahbaqdadi is there any published literature about this specific technique or is it just a general application of tournament selection, uniform crossover, mutation, and elitism applied to hyper-parameter search? |
|
It’s a general application of established genetic algorithm operators to discrete hyperparameter search. I’m not claiming a new GA variant or implementing one particular paper. There is published work on GA-based parameter tuning, such as Huang and Wang (2006), and Ma et al. (2026) describe a similar combination of operators. |
|
Nice, it's great to see classical machine learning is still alive in 2026! https://www.mdpi.com/2076-3417/16/13/6734 Does your algorithm follow the one they describe in section 3.2.2? If not, could you describe it in pseudo code or plain English for me? |
|
Thanks, Andrew. I cited that paper as an example of the same standard operators, rather than as the specification for this implementation. In plain English, |
andrewdalpino
left a comment
There was a problem hiding this comment.
Looks good @ahbaqdadi, just one comment about the compatibility() that I think can be improved.
Summary
Add
GeneticSearch, a meta-estimator for discrete hyperparameter spaces. It follows the existing search estimator API and uses tournament selection, uniform crossover, mutation, and elitism to evolve candidates. It avoids evaluating duplicate combinations, caps evaluations at the size of the search space, and supports setup, scoring results, prediction, and serialization.Add focused tests, a benchmark, a reference guide, a tuning guide comparison, MkDocs navigation, and a changelog entry.
Validation
vendor/bin/phpunit tests/Base/GeneticSearchTest.php --no-progress— 10 tests, 35 assertionscomposer test -- --no-progress— 2,150 tests, 51,343 assertions (38 skipped for optional extensions)vendor/bin/phpstan analyse -c phpstan.neon --memory-limit 1G --debug --no-progress— no errorscomposer check— cleanReplaces #526, which GitHub closed when the source branch was renamed from
codex/genetic-searchtogenetic-search.