Drop-in sklearn Replacement
GASearchCV follows the same fit / predict / best_params_ API as GridSearchCV. Replace it in one line and keep your entire pipeline unchanged.
Quick Start
Find better parameters faster. Evolutionary search handles cross-parameter interactions that GridSearchCV and RandomizedSearchCV miss — with feature selection, callbacks, and MLflow built in.
Genetic algorithms mimic natural selection to explore hyperparameter space more efficiently than grid or random search.
Latin hypercube sampling generates a diverse initial population covering the search space more evenly than random starts.
Each candidate configuration is cross-validated in parallel. Duplicates are cached — identical configs are never re-evaluated.
Tournament selection picks the strongest individuals. Uniform crossover and mutation create offspring with new combinations.
Diversity control and fitness sharing prevent premature convergence. Callbacks stop the search when it plateaus or hits a budget.
Each method has strengths. Genetic algorithms win on large search spaces with parameter interactions.
| Method | Handles Interactions | Scales to 10+ Params | sklearn Compatible | Feature Selection | Best For |
|---|---|---|---|---|---|
| GridSearchCV | ~ | ✗ | ✓ | ✗ | < 4 parameters, exhaustive coverage needed |
| RandomizedSearchCV | ~ | ✓ | ✓ | ✗ | Quick baseline, budget constrained |
| Optuna | ✓ | ✓ | ~ | ✗ | Bayesian search, non-sklearn objectives |
| RFE / SelectFromModel | ✗ | ~ | ✓ | ✓ | Feature selection only, no hyperparameter tuning |
| sklearn-genetic-opt ✦ | ✓ | ✓ | ✓ | ✓ | Joint hyperparameter + feature search in one step |
✦ = sklearn-genetic-opt | ✓ = yes | ~ = partial | ✗ = no
Install the package, define a search space, call fit. The GA finds better hyperparameters than a grid search in the same budget.
# pip install sklearn-genetic-opt
from sklearn.datasets import load_breast_cancer
from sklearn.ensemble import RandomForestClassifier
from sklearn_genetic import GASearchCV
from sklearn_genetic.space import Integer, Continuous
X, y = load_breast_cancer(return_X_y=True)
param_grid = {
"n_estimators": Integer(50, 500),
"max_depth": Integer(3, 15),
"min_samples_split": Integer(2, 20),
"max_features": Continuous(0.2, 1.0),
}
evolved_estimator = GASearchCV(
estimator=RandomForestClassifier(),
cv=5,
param_grid=param_grid,
population_size=20,
generations=15,
random_state=42,
n_jobs=-1,
)
evolved_estimator.fit(X, y)
print(evolved_estimator.best_params_)
print(evolved_estimator.best_score_)Copy-paste recipes for common tasks. Each one runs as-is and takes 5–10 minutes to read.
7-parameter joint search. Which parameters matter, classification and regression variants.
learning_rate × n_estimators interaction, subsample, colsample_bytree — 8-parameter search.
num_leaves vs max_depth, min_child_samples, feature_fraction — LightGBM-specific parameters.
GAFeatureSelectionCV on datasets with 100+ features. Faster than RFE, respects interactions.
Tune preprocessing parameters and model hyperparameters jointly in a single Pipeline.
Set scoring="roc_auc", handle predict_proba requirements, multi-class extension.
Seed the initial population with hyperparameters from a previous run or domain knowledge.
Same parameters as XGBClassifier but optimized for RMSE, MAE, and R² objectives.
Perform genetic feature selection and hyperparameter tuning for SGDRegressor using GASearchCV and GAFeatureSelectionCV.
Choose based on your experience. Each path is a curated sequence of docs.
Never used a genetic algorithm? Start here. You'll run your first GASearchCV in under 10 minutes.
Start the beginner path →You've run a basic search. Now learn callbacks, parallel evaluation, MLflow logging, and pipelines.
Deep-dive into GA mechanics, feature selection, custom operators, and multi-metric optimization.
Any scikit-learn compatible estimator works — including the most popular gradient boosting libraries.
Rich built-in visualizations — from fitness evolution to parameter interaction heatmaps.

Track score improvement across generations

Full-run dashboard: diversity, stagnation, scores

Discover learning_rate × n_estimators interactions

Watch each hyperparameter converge over time

Monitor genetic diversity and diversity control events

Visualize score surface across parameter pairs
sklearn-genetic-opt is MIT licensed and actively maintained. Contributions, bug reports, and feature requests are welcome. If it saves you time, a GitHub star helps other practitioners discover it.
pip install sklearn-genetic-opt