pystrand
Quickstart
In order to define a genetic algorithm you only need to determine how should genotypes, or candidate solutions, look and which operators should apply to them.
The rest is simply matter of providing training data.
In our case the data was generated by function f(x) = 5 + 5x + 2x^2.
>>>x = [i for i in range(10)]
>>>y = [5 + (5*i) +(2*(i**2)) for i in x]
After importing the model class we define which values can genes take.
>>>from pystrand.models.polymodels import PowerPolyModel
>>>domain = [i/10 for i in range(-100, 100)]
At the model initialization we can provide constraints on operator behavior, population size and maximum allowed runtime. This is particulary useful if we are looking for approximate solution.
>>> model = PowerPolyModel(domain, population_size=500, max_iterations=1000, crossover_prob=0.5)
We can also initialize the model with no constraints on the behavior of the algorithm, which will set parameters to pre-determined defaults. The only required parameter is the domain of gene values.
>>> model = PowerPolyModel(domain)
Model is then fitted on provided data.
>>>model.fit(x, y, verbose=0)
>>>model.solution
... (1., Genotype([5., 5., 2., 0., 0., 0., 0., 0., 0., 0.]))
Metadata
Release files for pystrand 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pystrand-0.1.1.tar.gz | 14.0 kB | Without provenance | Details for pystrand-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pystrand-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for pystrand-0.1.1-py3-none-any.whl |
Total release size: 31.3 kB
Release files / pystrand-0.1.1.tar.gz
| Download URL | pystrand-0.1.1.tar.gz |
|---|---|
| Size | 14.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fb5cde39141446dd8045741357fda872ecf005d3541b111007a52c2f0773704c
|
|
BLAKE2b-256 checksum How to use checksums |
90fc1374875338e828505c34fd41a5501cfd4468cc193e954b25f76afe706731
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.0 CPython/3.10.6 Linux/5.15.0-52-generic
|
Release files / pystrand-0.1.1-py3-none-any.whl
| Download URL | pystrand-0.1.1-py3-none-any.whl |
|---|---|
| Size | 17.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bfd701d27840c3effda2fcce9b7851d1bd08a3f56870fed59db1a39696ac93ef
|
|
BLAKE2b-256 checksum How to use checksums |
38d4cbaae0cc2687a5fe6b80ee82fddd8b8ac6bf1496f51e6c82eb5ebde7d778
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.0 CPython/3.10.6 Linux/5.15.0-52-generic
|
Security for pystrand 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.