百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
S

Sklearn-genetic-opt

> DevOps
开源

使用进化算法对 scikit-learn 进行超参数优化和特征选择。这是 GridSearchCV 和 RandomizedSearchCV 的现代替代方案。

386 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

使用进化算法对 scikit-learn 进行超参数优化和特征选择。这是 GridSearchCV 和 RandomizedSearchCV 的现代替代方案。

.. -- mode: rst --

.. image:: https://github.com/rodrigo-arenas/Sklearn-genetic-opt/blob/master/docs-vitepress/public/brand/readme-banner-1280x320.png?raw=true :alt: sklearn-genetic-opt — hyperparameter tuning and feature selection with evolutionary algorithms :target: https://sklearngeneticopt.rodrigo-arenas.com/

sklearn-genetic-opt ###################

Hyperparameter tuning and feature selection for scikit-learn models using genetic algorithms.

|Tests|_ |Codecov|_ |PythonVersion|_ |PyPi| |Conda|_ |Docs|_ |Stars|_ |GoodFirstIssues|_

.. |Tests| image:: https://github.com/rodrigo-arenas/Sklearn-genetic-opt/actions/workflows/ci-tests.yml/badge.svg?branch=master .. _Tests: https://github.com/rodrigo-arenas/Sklearn-genetic-opt/actions/workflows/ci-tests.yml

.. |Codecov| image:: https://codecov.io/gh/rodrigo-arenas/Sklearn-genetic-opt/branch/master/graphs/badge.svg?branch=master&service=github .. _Codecov: https://codecov.io/github/rodrigo-arenas/Sklearn-genetic-opt?branch=master

.. |PythonVersion| image:: https://img.shields.io/badge/python-3.12%20%7C%203.13%20%7C%203.14-blue .. _PythonVersion: https://www.python.org/downloads/

.. |PyPi| image:: https://img.shields.io/pypi/v/sklearn-genetic-opt.svg :target: https://pypi.org/project/sklearn-genetic-opt/ :alt: PyPI package version

.. |Conda| image:: https://img.shields.io/conda/vn/conda-forge/sklearn-genetic-opt.svg .. _Conda: https://anaconda.org/conda-forge/sklearn-genetic-opt

.. |Docs| image:: https://img.shields.io/badge/docs-GitHub%20Pages-blue .. _Docs: https://sklearngeneticopt.rodrigo-arenas.com/

.. |Stars| image:: https://img.shields.io/github/stars/rodrigo-arenas/Sklearn-genetic-opt?style=social .. _Stars: https://github.com/rodrigo-arenas/Sklearn-genetic-opt

.. |GoodFirstIssues| image:: https://img.shields.io/github/issues/rodrigo-arenas/Sklearn-genetic-opt/good%20first%20issue?label=good%20first%20issues&color=7057ff .. _GoodFirstIssues: https://github.com/rodrigo-arenas/Sklearn-genetic-opt/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22

.. |Contributors| image:: https://contributors-img.web.app/image?repo=rodrigo-arenas/sklearn-genetic-opt .. _Contributors: https://github.com/rodrigo-arenas/Sklearn-genetic-opt/graphs/contributors

sklearn-genetic-opt is a scikit-learn-compatible optimization toolkit for users who want a smarter alternative to GridSearchCV and RandomizedSearchCV. Its genetic algorithm evaluates complete parameter configurations — finding regions where learning_rate × n_estimators or C × gamma are jointly optimal, something one-parameter-at-a-time approaches miss. It also provides GAFeatureSelectionCV, a wrapper-based selector that searches the full space of feature subsets simultaneously instead of eliminating features one at a time.

If sklearn-genetic-opt saves you time, consider starring the GitHub repository _. It helps more practitioners discover the project.

Why use sklearn-genetic-opt? #############################

  • Drop-in scikit-learn API — GASearchCV has the same fit / predict / best_params_ interface as GridSearchCV; replace it in one line.
  • Handles interacting parameters — genetic algorithms evaluate complete configurations, naturally finding cross-parameter sweet spots that random or grid search miss.
  • Joint feature selection and tuning — run GAFeatureSelectionCV and GASearchCV in a two-stage workflow; no separate feature-selection library needed.
  • Mixed search spaces — Integer, Continuous (uniform or log-uniform), and Categorical types in the same search.
  • Smart initialization — Latin hypercube seeding, estimator defaults, warm-start configs, and duplicate avoidance give the first generation a head start over random initialization.
  • Early stopping callbacks — ConsecutiveStopping, DeltaThreshold, and TimerStopping end the search automatically when it converges or runs out of time.
  • Adaptive schedules — crossover and mutation rates anneal over generations, shifting from exploration to exploitation.
  • Optimization history and plots — per-generation fitness, diversity, and telemetry stored in history; built-in plots visualize the full search.
  • MLflow integration — every evaluated candidate is automatically logged as a child run for experiment comparison.
  • Parallel execution — n_jobs=-1 parallelizes candidate or fold evaluation.

When should you use it? ########################

  • Your model is expensive to train and you can only afford 50–200 total evaluations.
  • Your search space has 5+ hyperparameters that interact (gradient boosting, SVM, regularized regression).
  • You want feature selection and hyperparameter tuning in a single reproducible workflow.
  • You want optimization history, convergence plots, callbacks, or MLflow tracking built in.
  • You have known-good configurations to warm-start from (prior runs, published defaults).
  • GridSearchCV is too slow and RandomizedSearchCV keeps returning similar bad results.

When should you NOT use it? ############################

  • You need a fast baseline — start with a fixed configuration or RandomizedSearchCV(n_iter=20); it's faster and good enough to validate your pipeline.
  • Your grid is tiny (fewer than 50 combinations) — GridSearchCV covers it exhaustively and is simpler to reason about.
  • Your model and dataset are fast (`_

What you can do ################

Track optimization progress generation by generation. The fitness curve shows when the search converges so you know whether to add more generations or stop early.

.. image:: https://github.com/rodrigo-arenas/Sklearn-genetic-opt/blob/master/docs-vitepress/public/images/plotting_gallery_fitness_evolution.png?raw=true :alt: Fitness evolution — best and mean CV score plotted over generations :width: 680

See where the search explored and which parameter combinations scored highest. The scatter plot reveals the productive region of the learning_rate × n_estimators interaction — a band a one-at-a-time sweep cannot find.

.. image:: https://github.com/rodrigo-arenas/Sklearn-genetic-opt/blob/master/docs-vitepress/public/images/tune_xgboost_interaction.png?raw=true :alt: Every evaluated candidate colored by CV score, learning_rate vs n_estimators :width: 680

Inspect the full search in one view. The search overview panel combines scores, parameter distributions, diversity, and candidate decisions.

.. image:: https://github.com/rodrigo-arenas/Sklearn-genetic-opt/blob/master/docs-vitepress/public/images/basic_usage_search_overview.png?raw=true :alt: Search overview dashboard showing all evaluated candidates :width: 680

See the full Plotting Gallery → _

Common use cases #################

Hyperparameter tuning

  • Tune RandomForestClassifier _ — 7-parameter joint search, classification and regression
  • Tune XGBoost _ — 9 interacting params, n_jobs=1 oversubscription fix, interaction visualization
  • Tune LightGBM _ — num_leaves / max_depth interaction, parameter scatter plots
  • Tune CatBoost _ — bagging_temperature, border_count, GPU tip
  • Tune Gradient Boosting (sklearn) _ — HistGBM vs classic GBM, speed comparison
  • Tune Logistic Regression _ — solver / penalty compatibility, multi-penalty with SAGA
  • Tune SVM (C, kernel, gamma) _ — C–gamma interaction, mandatory Pipeline + StandardScaler
  • Tune a scikit-learn Pipeline _ — step prefix patterns, ColumnTransformer
  • Tune for imbalanced datasets _ — class_weight as a search param, balanced accuracy

Feature selection

  • Feature selection with genetic algorithms _ — 3-stage: select, retune, validate
  • Combine feature selection + hyperparameter tuning _ — two-stage pipeline recipe

Experiment tracking and tooling

  • MLflow experiment tracking _ — log every candidate as a child run
  • Callbacks and early stopping _ — ConsecutiveStopping, TimerStopping, DeltaThreshold
  • Checkpointing and resume _ — save and continue long searches
  • Visualize optimization progress _ — full gallery of available plots

Browse all Recipes → _ Browse all Tutorials → _

Citation ########

If sklearn-genetic-opt supports your research or a published project, please cite the software version you used. GitHub can generate a citation from CITATION.cff through the "Cite this repository" button, and citation managers can read the same metadata directly from the repository.

Recommended citation:

.. code-block:: text

Arenas, R. (2026). sklearn-genetic-opt: Hyperparameter tuning and feature selection using genetic algorithms, built on top of scikit-learn (Version 0.13.3) [Computer software]. https://github.com/rodrigo-arenas/Sklearn-genetic-opt

BibTeX:

.. code-block:: bibtex

@software{arenas_2026_sklearn_genetic_opt, author = {Arenas, Rodrigo}, title = {{sklearn-genetic-opt}: Hyperparameter tuning and feature selection using genetic algorithms, built on top of scikit-learn}, year = {2026}, version = {0.13.3}, url = {https://github.com/rodrigo-arenas/Sklearn-genetic-opt} }

Learning paths ###############

New user Install _ → Getting Started with GASearchCV _ → How Hyperparameter Optimization Works _ → Pick a Recipe _

ML practitioner When to Use Genetic Algorithm Search _ → Choosing the Right Search Space _ → Model-specific Tutorials _ → Optuna vs sklearn-genetic-opt _

Contributor Contributing guide _ → Open issues _ → Benchmarks documentation _

Benchmarks ##########

The repository includes benchmark scripts that compare GASearchCV against RandomizedSearchCV, GridSearchCV, and Optuna (TPE) using the Bayesmark _ experimental design — same datasets, same search spaces, equal evaluation budget:

.. code-block:: bash

pip install sklearn-genetic-opt[benchmark] python benchmarks/benchmark_bayesmark.py --quick

See the Benchmarks documentation _ for methodology and full results.

Installation ############

.. code-block:: bash

Core package

pip install sklearn-genetic-opt

With plotting, MLflow, and TensorBoard:

pip install sklearn-genetic-opt[all]

conda

conda install -c conda-forge sklearn-genetic-opt

Requires Python ≥ 3.12 and scikit-learn ≥ 1.5.0. See Installation _ for the full requirements table and optional extras.

Contributing ############

Contributions of all sizes are welcome — from fixing a typo to adding a new tutorial or benchmark.

Good ways to start:

  • Add a Recipe for an estimator or workflow not yet covered — see existing Recipes _.
  • Write or improve a tutorial (new models, edge cases, regression examples).
  • Test with a new estimator from another framework and report the results.
  • Add a benchmark comparing search methods on a real dataset.
  • Fix typing, CI, or formatting — black . keeps the style consistent.
  • Answer questions in open issues.
  • Share your work — add a blog post, article, or video to the Community Articles page _.

.. code-block:: bash

git clone https://github.com/rodrigo-arenas/Sklearn-genetic-opt.git cd Sklearn-genetic-opt pip install -r dev-requirements.txt pytest sklearn_genetic

Read the contribution guide _ before opening a pull request. If you are not sure where to start, open an issue _ and ask — small contributions are very welcome.

|Contributors|_

Links

  • Documentation _
  • API reference _
  • Tutorials _
  • Recipes _
  • Grid vs Random vs Bayesian vs Genetic comparison _
  • Common hyperparameter tuning mistakes _
  • Troubleshooting _
  • Release notes _
  • PyPI _
  • Issues _

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Pythonartificial-intelligenceautomlcross-validationevolutionary-algorithms

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类DevOps
定价开源

> 相关工具

D
Docker
容器化平台,标准化应用交付
G
GitHub Actions
GitHub 原生 CI/CD 工作流
N
Nginx
高性能 Web 服务器与反向代理