I wrote a version of this algorithm in python with the help of these videos and it solves it in around 50 generations. Lightening fast!! I am stoked...
I made a similar GA, But you could type the sentence you wanted, and I used the letter's position in the alphabet to calculate the fitness, and mutated by going up or down, worked pretty well... Good video anyway :)
Has anyone rewritten this in Python? I've written a few versions. But, my best version still takes thousands of generations to solve "To be or not to be." I don't know what I'm missing. Would love to see others' code.
Is it safe to say that if your population is (way) bigger than the number of variables in your question you don't need mutation? Your example seemed to indicate that at around 5:00...
I see that the mutation rate and the gene pool is important But what can we use math to find the best value for those values ? Like make the variables updatable as one mutate of value is more faster / accurately and approach to the target Like ml in ml?
Hey The Coding Train, first thank you so much for this very clear explanation. I have a quick question though. If we take the example of this or another classic GA : two parents will combine to create one offspring, right ? Could you tell me why and how is it possible that your population stays the same at every iterations ?
Why does the total population remain constant from one generation to the next? Is it intentional? Because a gradually increasing population would soon become an overhead. Btw, it is always an amazing experience to watch your videos.
I noticed that this algorithm seems to have issues dealing with words that end with lower case 'z' I set the target to "the bee goes buzz" and it never seems to find it.. it doesn't ever seem to mutate a lower case 'z' although I have seen an upper case 'Z' fly by.. I wonder if we are having an off by one error.. if lower case 'z' is the last character in the list and it never selects it cause it's off by one.. that might explain it.
Hello, i have a question. Can i use code from repo on Warsaw school of AI event ? As a part of presenatation about GA ? How need i refer to you ? I made a hyperlink to your stuff and mention your name.
The idea is that you know the goal, but you don't know the solution to that specific goal. The fitness is based only by the goal, you can say "The fitness is how close an object is to a target location" then the computer it self finds HOW to get a maximum fitness - Achieving our goal.
I was inspired by your last video about this and made my own version of this! Then I tried thinking of using this method for solving a nonogram puzzle, but I couldn't figure out what would determine the fitness. Maybe an example with Sudoku would be cool to see.
Well it was the same as your phrase searching algorithm, but you could enter any phrase under 50 characters. I just made a new version that can solve those nonogram puzzles I was talking about. But I don't think I have a good measure on fitness.
As one approach, the base for your fitness could be the number of moves required to solve the thing, a lower value giving a higher fitness score. So say you have a total population of 3 members (A,B,C) that solved the problem in (100, 50, 25) moves respectively. Sum the number of moves for a total of 175, then express the performance of each member as a % of the total. So now we'd have A = 57.14%, B = 28.57%, C = 14.29%. As the final step, since a lower value is better in this case, we'll "invert" the percentages, ie. new % = 100 - current %. So finally, the relative fitness of each member of our population is A = 42.86%, B = 71.43%, C = 85.71%.
The Coding Train I went a little further and made a genetic algorithm that finds an optimal mining pattern in Minecraft. You can check it out at kamoroso94.github.io/minecraft-turtle and the GitHub repo of the same name.
I hope this algorithm has a constraint such that when a child is added to the mating pool it cannot mate with the parents... we don't want 'To be or not to be' coming out with webbed letters
6:50 what if you "lock" the things responsible for increasing the fitness score, only mutating things known to be incorrect? idk.. just thinking outloud >_> don't even know if I'm making sense.
Hi! That's a great idea but in most situations, it wouldn't be clear which parameters were contributing 'positively' and which were contributing 'negatively'. For example, look at the BoxCar example - once you've evolved a super sleek car it's very non-obvious whether making one stick longer or shorter will make it work better or worse here. For that reason you often can't lock off parameters in that way.
I was thinking, and it would be really meta to make a genetic algorithm which produces the highest average fitness based off of total population and mutation rate. And then do the same thing with the best of that set. Idk, it just made me think.
I wonder if someone could make a meta-algorithm for this one, that tests out different ranges of population and mutation rates, and assigns fitness level to each iteration based on it's average time spent finding the correct phrase. Eventually, it would settle on a population and mutation rate that gives the correct answer (for phrases of this length) fastest (on average).
Couldn't you make an Genetic Algorithm that could play with the variables the way you just did to figure out what would be optimal to get the word you look for the fastest. And compare that with the number of letters in the word, and see if the number e pops up anywhere or something xD
I think you wanted to get away from that "boring soon-to-be-corpse professor" - kind, but this amount of energy might be a bit too much. You can boost book sales by trying to appeal to masses (find middle ground). Who doesn't want to be successful in their sales? Edit: One way to keep that energy amount but be more appealing is to ask questions enthusiastically. "And as we can see, 100% mutation rate leads to utter garbage. *Why, why does this happen?*". You obviously know the answer, but it's a way to be energetic and try to immense the viewer. After all, we can passively watch these videos without further thinking, but questions promote thinking.
Couldn't you make an Genetic Algorithm that could play with the variables the way you just did to figure out what would be optimal to get the word you look for the fastest. And compare that with the number of letters in the word, and see if the number e pops up anywhere or something xD