Sitemap
TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Follow publication

Tune Your Scikit-learn Model Using Evolutionary Algorithms

6 min readMay 26, 2021

--

Photo by Susan Q Yin on Unsplash

Dataset

Digits dataset. Image by Scikit-learn (BSD License)

The Evolutionary Algorithm

Evolutionary Cross-Validation. Image by the author.

Implementation

pip install sklearn-genetic-opt
Data Import. Code by the Author.
GaSearchCV setup. Code by the Author.
evolved_estimator.fit(X_train,y_train)
y_predicy_ga = evolved_estimator.predict(X_test)
accuracy_score(y_test,y_predicy_ga)
Training verbose. Image by the Author.
Optimization result. Image by the Author.
plot_fitness_evolution(evolved_estimator)
plt.show()
Fitness Evolution. Image by the Author.
Log of hyperparameters used. Image by the Author.
plot_search_space(evolved_estimator)
plt.show()
Sampled hyperparameters distribution. Image by the Author.
Hall of Fame. Image by the Author.

Appendix 1: Space definition

Appendix 2: parameters of GASearchCV

--

--

TDS Archive
TDS Archive

Published in TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Rodrigo Arenas
Rodrigo Arenas

Written by Rodrigo Arenas

Data Scientist and open-source contributor working on machine learning, and optimization; for all my projects, check: https://rodrigo-arenas.github.io/portfolio

Responses (7)