This package implements various classes and functions for genetic algorithms
Project description
Genetic Algorithm
This is a pure Python implementation for a genetic algorithm. It has precreated classes and functions for using this algorithm.
The genetic module is compossed of a Individual and GeneticAlgorithm class.
from genetic_algorithm.genetic import GeneticAlgorithm, Individual
from genetic_algorithm.chooser import DefaultChooser
from genetic_algorithm.rules import single_crossover, SimpleMutator
def get_pop() -> list[Individual]:
...
def fitness(indivdual: Individual) -> float: # or int
...
ga = GeneticAlgorithm(get_pop(), DefaultChooser(), single_crossover, SimpleMutator(), tracker=..., n_keep=..., n_mutated_keeped=...)
ga.train(iterations=10, fitness)
# or use ga.evololution(fitness, do_sort) where fitness is a list of tuples of a number representing a score and an Individual
# if the list isn't sorted already, pass True for do_sort
When creating your population, you should give the Individuals a list of values, a keras.Model, a keras.Sequential or a NN object, as well as a id.
The NN object can be created with the simple_nn modul. You will need tenserflow for for keras.Model and keras.Sequential.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file genalgopy-1.0.0.tar.gz.
File metadata
- Download URL: genalgopy-1.0.0.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.7.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c1bbdeb9f5f8efd4149311092cdc392be3de89c1d1e5228f99a275b52d28b8b
|
|
| MD5 |
07003c47364f97ff4a6f8e71e660b903
|
|
| BLAKE2b-256 |
b1c61492ebfc8ca6dfa19092f9d06c2018422ccd34f79a5167e650aaf65edf05
|
File details
Details for the file genalgopy-1.0.0-py3-none-any.whl.
File metadata
- Download URL: genalgopy-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.7.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b05c4a9ed15c4a908a6fd9c20a465c26e8f6c08de24c3d6fad54fad0a047794c
|
|
| MD5 |
76de02e070f9c6cfab81ce5fec2445a6
|
|
| BLAKE2b-256 |
0e79e8bd96b1842e06e00d72090968895290f1076dc8d82511f1944f394413a3
|