Skip to main content

GeneticPy

codecov PyPI version PyPI pyversions PyPI Downloads

GeneticPy is an optimizer that uses a genetic algorithm to quickly search through custom parameter spaces for optimal solutions.

Installation

GeneticPy requires Python 3.10+

pip install geneticpy

Development Workflow

This project uses uv for fast dependency management and hatchling as the build backend.

# Run tests
make test

# Build the package
make build

Optimize Example:

A brief example to get you started is included below:

import geneticpy

def loss_function(params):
  if params['type'] == 'add':
    return params['x'] + params['y']
  elif params['type'] == 'multiply':
    return params['x'] * params['y']

param_space = {'type': geneticpy.ChoiceDistribution(choice_list=['add', 'multiply']),
               'x': geneticpy.UniformDistribution(low=5, high=10, q=1),
               'y': geneticpy.GaussianDistribution(mean=0, standard_deviation=1)}

results = geneticpy.optimize(loss_function, param_space, size=200, generation_count=500, verbose=True)
best_params = results.best_params
loss = results.best_score
total_time = results.total_time

PyPi Project

https://pypi.org/project/geneticpy/

Contact

Please feel free to email me at brandonschabell@gmail.com with any questions or feedback.

Metadata

Release files for geneticpy 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for geneticpy 2.0.0
File Size Uploaded
geneticpy-2.0.0.tar.gz 14.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for geneticpy 2.0.0
File Interpreter ABI Platform
geneticpy-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 28.4 kB

Release files / geneticpy-2.0.0.tar.gz

Download URL geneticpy-2.0.0.tar.gz
Size 14.5 kB
Tags Source
SHA-256 checksum
How to use checksums
4d44e4faf0c5d5856f68879633ba955de7fbce6b049254a0b900de5cb8611e97
BLAKE2b-256 checksum
How to use checksums
78062147b6801ba35db5eb5071430c62425adc8d0ac40b3c51af62dbed901564
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / geneticpy-2.0.0-py3-none-any.whl

Download URL geneticpy-2.0.0-py3-none-any.whl
Size 13.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
75b91ad98afbc4c0b00b0821bd4ee33532ba6c3c98023d301105aab99b2c6bb7
BLAKE2b-256 checksum
How to use checksums
8bad56b460408a46d513ef447c349728a8d327b1ddea9e994528cef8951e55cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

1.3.0

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.1

2 release files

0.1.0

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page