pygad
PyGAD: A Python Library for Building the Genetic Algorithm and Training Machine Learning Algoithms (Keras & PyTorch).
Decision gist · record as of 2026-08-14
Yes. PyGAD is actively maintained, has low install friction, no known vulnerabilities, and a clear use case for evolutionary optimization and neural network training. The BSD 3-Clause license is permissive. Install it if you need genetic algorithm optimization; skip it if you only do gradient-based machine learning. Verify the license treatment classification if your use case has strict licensing requirements.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low install friction with only two runtime dependencies (numpy and cloudpickle).
- Active maintenance with recent releases; last commit 2026-07-09.
- Optional extras available for visualization and deep learning features.
License · maintenance · safety
(unclear) — Licensed under BSD 3-Clause, which permits commercial and private use with attribution and liability disclaimers. License treatment is marked unclear in the fact sheet, so verify the exact terms apply to your use case.
last release 2026-06-05 (70 days) · last repo commit 2026-07-09 · 2,220 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 90,134 downloads/mo, #13,617 on PyPI
Alternatives
Verify before relying
pip install pygad
import pygad
import numpy
def fitness_func(ga_instance, solution, solution_idx):
output = numpy.sum(solution * [4, -2, 3.5, 5, -11, -4.7])
return 1.0 / (numpy.abs(output - 44) + 0.000001)
ga = pygad.GA(num_generations=100, num_parents_mating=7,
fitness_func=fitness_func, sol_per_pop=10, num_genes=6)
ga.run()- Whether license_treatment 'unclear' indicates any actual licensing ambiguity or is a data classification artifact
- Performance characteristics and scalability limits for large population sizes or high-dimensional problems
- Availability and stability of optional extras (visualize, deep_learning) across Python versions
What it is and what it does
PyGAD is a genetic algorithm library that lets you define a fitness function and run an evolutionary optimization loop to find good solutions to single- or multi-objective problems. It handles population initialization, parent selection, crossover, and mutation automatically, with callback hooks at each stage so you can monitor or intervene in the algorithm's execution. The core library depends only on numpy and cloudpickle, keeping the base install lightweight; optional extras add visualization (matplotlib) and deep learning integration (Keras/PyTorch).
You write a fitness function that scores candidate solutions, then instantiate a GA object with your parameters (population size, number of generations, crossover/mutation strategy) and call run(). The library is actively maintained, supports current Python versions, and is documented with examples covering both simple optimization problems and neural network training scenarios.
Use it for
- Optimize weights or hyperparameters for a machine learning model when gradient-based methods are impractical or you want to explore a non-convex search space.
- Train neural network weights using Keras or PyTorch by wrapping the model in a fitness function that evaluates test accuracy.
- Solve combinatorial or discrete optimization problems (e.g., scheduling, routing) where you define fitness as a penalty-based score.
- Multi-objective optimization where you balance competing goals (e.g., model accuracy vs. inference speed) in a single fitness metric.
- Educational exploration of genetic algorithms and evolutionary computation with built-in lifecycle callbacks to trace algorithm behavior.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
PyGAD is actively maintained, has low install friction, no known vulnerabilities, and a clear use case for evolutionary optimization and neural network training. The BSD 3-Clause license is permissive. Install it if you need genetic algorithm optimization; skip it if you only do gradient-based machine learning. Verify the license treatment classification if your use case has strict licensing requirements.
Install
pygad on PyPI
Before you install
Low install friction with only two runtime dependencies (numpy and cloudpickle). Active maintenance with recent releases; last commit 2026-07-09. Optional extras available for visualization and deep learning features.
License in practice
Licensed under BSD 3-Clause, which permits commercial and private use with attribution and liability disclaimers. License treatment is marked unclear in the fact sheet, so verify the exact terms apply to your use case.
Quickstart
pip install pygad
import pygad
import numpy
def fitness_func(ga_instance, solution, solution_idx):
output = numpy.sum(solution * [4, -2, 3.5, 5, -11, -4.7])
return 1.0 / (numpy.abs(output - 44) + 0.000001)
ga = pygad.GA(num_generations=100, num_parents_mating=7,
fitness_func=fitness_func, sol_per_pop=10, num_genes=6)
ga.run()
Verify before relying
- Whether license_treatment 'unclear' indicates any actual licensing ambiguity or is a data classification artifact
- Performance characteristics and scalability limits for large population sizes or high-dimensional problems
- Availability and stability of optional extras (visualize, deep_learning) across Python versions
Package facts
| License | Not declared unclear |
| Python support | Supports the current Python release >=3 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 2 packagesnumpycloudpickle |
| Maintenance | Actively maintained 70 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 90,134 / month, #13,617 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Intended Audience :: DevelopersIntended Audience :: EducationIntended Audience :: Information TechnologyIntended Audience :: Other AudienceIntended Audience :: Science/ResearchNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Topic :: Scientific/EngineeringTopic :: Scientific/Engineering :: Artificial IntelligenceTopic :: Scientific/Engineering :: Bio-InformaticsTopic :: Software DevelopmentTopic :: Utilities |
Evidence: pygad-3.7.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “genetic algorithm python”
- pygadPyGAD is a Python library for building and running genetic algorithms…
- deapDEAP is an evolutionary computation framework for implementing…
- pysrPySR searches for symbolic expressions that fit data by combining…
Give your agent the search over MCP, or paste the wish link into any chat.
More Software Development packages
Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.
See also deap · pymoo · keras-tuner · moocore · tensorflow-model-optimization · optlang · pyomo · optuna-integration · keras