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.
Metadata
Release files for genalgopy 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| genalgopy-1.0.0.tar.gz | 7.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| genalgopy-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.2 kB
Release files / genalgopy-1.0.0.tar.gz
| Download URL | genalgopy-1.0.0.tar.gz |
|---|---|
| Size | 7.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7c1bbdeb9f5f8efd4149311092cdc392be3de89c1d1e5228f99a275b52d28b8b
|
|
BLAKE2b-256 checksum How to use checksums |
b1c61492ebfc8ca6dfa19092f9d06c2018422ccd34f79a5167e650aaf65edf05
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.7.9
|
Release files / genalgopy-1.0.0-py3-none-any.whl
| Download URL | genalgopy-1.0.0-py3-none-any.whl |
|---|---|
| Size | 9.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b05c4a9ed15c4a908a6fd9c20a465c26e8f6c08de24c3d6fad54fad0a047794c
|
|
BLAKE2b-256 checksum How to use checksums |
0e79e8bd96b1842e06e00d72090968895290f1076dc8d82511f1944f394413a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.7.9
|