--- id: pygad version: "3.7.0" license: Copyright GeneticAlgorithmPython Contributors Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1.… (full text in the JSON record) license_treatment: unclear maintenance: active --- # pygad — PyGAD: A Python Library for Building the Genetic Algorithm and Training Machine Learning Algoithms (Keras & PyTorch). License: unclear · Maintenance: active · Downloads: 90.1K/mo ## 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 above — verify before relying. PyGAD is a Python library for building and running genetic algorithms to optimize single-objective and multi-objective problems, with built-in support for training Keras and PyTorch models. 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 pip install pygad uv add pygad poetry add pygad ## Installing pygad 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: Copyright GeneticAlgorithmPython Contributors Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1.… (full text in the JSON record) (unclear) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 90.1K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags genetic algorithm python, evolutionary optimization library, neural network training optimization, multi-objective optimization, machine learning hyperparameter tuning, genetic algorithm keras pytorch, population-based optimization, evolutionary-computation, hyperparameter-optimization, neural-network-training [View on SkillFed](https://skillfed.io/packages/pygad) · [View on PyPI](https://pypi.org/project/pygad/)