Genetic Machine Learning for Python
GMLP or Genetic Machine Learning for Python, is a user friendly python machine learning package. GMLP is intuitive and can be used for lots of Machine Learning Projects.
What is GMLP?
GMLP helps you with your genetic programming! You can turn 90 lines of code into 18 lines of code!
Examples
GMLP can be used for evolutionary neural networks, and genetic programming! Here are some Examples:
# GMLP Example 1. - Phrase Guesser.
# This Evolutionary Neural Network will have you put in a phrase and the E.N.N will guess it.
import random
import gmlp as gp
# Importing our modules.
# Our characters that we will be using.
characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,.?!: '
# We make our characters into a list.
characters = list(characters)
# The phrase.
phrase = "Hello World!"
# Making the phrase into numbers by using ord() so working with the phrase will be easier.
ord_phrase = [ord(target) for target in phrase]
# Having the population generate random letters and turn them into numbers using the ord() function.
starting_population = [[ord(random.choice(characters))for gene in range(len(ord_phrase))]for pop_size in range(10000)]
print("Our goal phrase is:", phrase)
# Setting up the enviroment.
env = gp.Enviroment(ord_phrase, .9)
# Our population.
population = env.generate_population(settings=starting_population)
# Our fitnesses.
scores = gp.calculate_fitness(population, env.goal)
# Our maximum number of generations.
max_generations = 500
for generation in range(max_generations):
# Calculating the scores for the population.
scores = gp.calculate_fitness(population, env.goal)
# The best score is the minimum of the scores because the scores are how far you are away from your goal.
best = min(scores)
# getting the score index of the best score.
best_score = scores[scores.index(best)]
# the population organism of the best score index.
Output = population[scores.index(best)]
print("Generation:%1s, Best Score:%2s, Output->%3s"%(generation, str(best_score), ''.join([chr(c) for c in Output])))
# Our new population is the mutated population of the crossover of the fittest population .
population = gp.ValueEncodingMut(env.crossover(env.tournament_selection(population, scores, 3), ord_phrase), .15)
# If we are 0% away from our goal we print the output and phrase and break the loop.
if min(scores) == 0:
print(f'Our Output -> {"".join([chr(c) for c in Output])}')
print(f'Our Phrase -> {phrase}')
break
Game
This Feature is new to GMLP and is still in progress
Metadata
Release files for gmlp 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gmlp-0.2.tar.gz | 6.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gmlp-0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.2 kB
Release files / gmlp-0.2.tar.gz
| Download URL | gmlp-0.2.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
50b0db66f9c7a1c9c83f7525c92e33a4ce70e1411ca6be60ee76171962b9905d
|
|
BLAKE2b-256 checksum How to use checksums |
4f69d18a28861dc4aa1d80ef080c7183f6fe9cdce769db800caf646c3fa21dd4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3
|
Release files / gmlp-0.2-py3-none-any.whl
| Download URL | gmlp-0.2-py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b291ec50d9a91ceb08ebf868926d56724bde8dc212239c36928619fd88bd50e8
|
|
BLAKE2b-256 checksum How to use checksums |
8b187618b4a4a22ea192d8f8f87c9a2b9b60a8ab1cd7cac0e24a415d34a1cd52
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3
|