Familiar sklearn API
GASearchCV supports fit, predict, and best_params_ in the scikit-learn search workflow. Define parameter ranges and a validation budget to get started.
Quick Start
Tune hyperparameters or select features by recombining candidates and scoring them with cross-validation.
How crossover makes a candidate
1 keeps that column; a 0 drops it.Candidate configurations are scored with cross-validation, then selected and recombined across generations.
Choose a diverse initial population, optionally including known-good parameter configurations.
Cross-validation scores each candidate. Optional caching avoids repeated evaluation of identical configurations.
Tournament selection picks the strongest individuals. Uniform crossover and mutation create offspring with new combinations.
Diversity controls and early-stopping callbacks are available when the search needs them.
Install the package, define a search space, call fit. Set a cross-validation budget, then compare the result with a simple baseline.
# pip install sklearn-genetic-opt
from sklearn.datasets import load_breast_cancer
from sklearn.ensemble import RandomForestClassifier
from sklearn_genetic import EvolutionConfig, GASearchCV, RuntimeConfig
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(random_state=42),
cv=5,
param_grid=param_grid,
evolution_config=EvolutionConfig(population_size=20, generations=15),
random_state=42,
runtime_config=RuntimeConfig(n_jobs=-1),
)
evolved_estimator.fit(X, y)
print(evolved_estimator.best_params_)
print(evolved_estimator.best_score_)Focused recipes for common estimators, feature selection, scoring, and pipelines.
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.
Use GAFeatureSelectionCV with a feature-count limit and cross-validation.
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.
Search regularization strength and the L1/L2 ratio in a scaled regression pipeline.
Choose based on your experience. Each path is a curated sequence of docs.
New to genetic search? Learn to fit GASearchCV and inspect cross-validation results.
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.
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