Your the first person I found that teaches AI and shows the CODING aspect of what it is. For that, I promise you I am subscribed to you and turned on notifications. Keep up the good work!!
@RafaelBragaCarol7 жыл бұрын
Daniel, I got to say, you're an AWESOME TEACHER! I have watched 3 lists about AI before your list, and never fully got the concept. You make it much easier to understand, plus it helps a lot with the example/exercise. Thanks for doing these videos. I saw in the videos that you wrote a book, I will make sure I will buy it to support these videos.
@TheCodingTrain7 жыл бұрын
thank you!
@markvador66675 жыл бұрын
Daniel, you are merely one of the best teacher i've ever listened in my life ... and i'm 50 years old today (i've started to code at 12 on TI99/4A) ! You make arduous and tough things so easy to understand and amazing : this is pure genious, thank you very much ! Keep on !!!!
@taeshawitsuwanwigo86287 жыл бұрын
Man, you are the best. Really! All the afford you put in. The best tutorial on GA ever. Thank you!!
@TheCodingTrain7 жыл бұрын
Thank you so much!
@harshpatel3096 жыл бұрын
After watching many videos on this topic...finally the place where I have understood is this channel. Great series. Thank you so much
@sohailape6 жыл бұрын
i was taking stanford course but there was no coding and i was forgetting everything. Your tutorials are great . I am able to understand and you are even showing basic implementation.
@alexapostolo33297 жыл бұрын
Hey , I wanted to say that you have done a great job explaining the functionality of a genetic algorithm. I also tried making my own genetic algorithm, the only problem that i have encountered has been on small paragraphs that take many generations for the program to evolve the right phrases.
@heinrichkreuser26596 жыл бұрын
This is a really cool video series! Been watching it up until now and gonna watch until the end. You're very ecstatic and I like that. Keep up the good work🤟
@danieljerabek43337 жыл бұрын
I like the hype, also funny thing is that the ad before video was even more hyped up than the video, thumbs up and keep the hype!
@thisaintmyrealname17 жыл бұрын
Great series man! , I became a big fan of the way you teach stuff ever since I started reading your N.O.C. book. Keep up the good work! Greetings from Ecuador.
@Matt-gr4bu5 жыл бұрын
Bit of a slow way of doing weighted random here's what i normally use 1: Calculate the total fitness 2: Generate a random number between 0 and the total fitness 3: Loop through the population subtracting each DNA's fitness from the random number until it's less than 0, the selected DNA is the DNA that makes the fitness go below 0
@xopabyteh2 жыл бұрын
I looked at the concepts you explained in the video and tried to code it for myself in C#. It was buckets of fun :)
@infinitif98297 жыл бұрын
funny that my algorithm needs 62322 generations in the same setup... But greate video, I came into genetic code just because of you :D
@BrandNewByxor5 жыл бұрын
Don't you just love random numbers?
@willietheron27173 жыл бұрын
A small note: I think it will be better to use the fitness score as a range so you can set 0-3 as A, 4-5 as B, 6 as C and 7 - 9 as D. Then you can use Math.random to find the "key" This works particularly well if you have some irregular values like 2000 for fitness... Then your range gets bigger without you needing to build a mating array which could rip performance. (seeing that your arrays were 16000 elements large) Was just thinking what a more optimum solution would potentially look like. Considering each element can essentially just be a "case" tied to a random value. Have not written this yet, but for my scenario it should work
@Applevi2 жыл бұрын
The random fitness relative selection can be done by: getting a random number from 0 to the sum of all fitness results, then go over the list of the population adding up the fitness values and selecting the one where the random number is smaller than the current sum
The mating pool part is kinda overkill, and you didn't distribute its elements uniformly randomly. You could just had generated a random number (rand) between 0 and 100 and do: if 0 > rand rand rand rand
@TheCodingTrain8 жыл бұрын
Thanks! Yes this is a good point. I address some other solutions to this in a future video coming out soon!
@JaySiggz7 жыл бұрын
Yes. I was just going to say this.
@dazzaondmic7 жыл бұрын
What happens when its not just A B C and D but 1000 possibilities?
@pdcx7 жыл бұрын
^ generalizing this algorithm: accFitness(i) = the accumulated fitness from the first to the i-th DNA randAccuFit = random(0, accFitness(lastDNA)) loop from first to the last DNA, until accFitness(i) >= randAccuFit, the index i corresponds to the random DNA we want to pick from the pool instead of looping linearly, one can loop using constant leaps (i+= constant) or increase the index by a multiple (*2) until accFitness(i) > randAccuFit, then decrement i until accFitness(i)
@matthiasfuchs1396 жыл бұрын
dazzaondmic Have a second array partial with population size N. Then do partial sums of the fitness. At index 0 you have the fitness of population at 0. Then partial[n+1] = fitness(n+1) + partial[n]. Then generate a random number R in the range [0, partial[N-1]]. Do a binary search for the upper boundary (first element greater than your random number) for R. This should give you an index J in the range [1, N]. At J-1 you have the population member of interest.
@Arygua5 жыл бұрын
Really good videos, just walked through the code afterwards and ported it to straight Java and have a decent grasp of method. Little more difficult without alot of the libraries and methods JS has but still works. Also the code posted on GitHub is a little different than it is shown here but still able to put those parts together with the help of the video.
@Arygua5 жыл бұрын
Appreciate the heart, started watching your videos over Machine Learning to see if I want to change my Masters.
@spacemonkeydoom61166 жыл бұрын
I love your incredible coding sessions with fantastic things would you ever do the same like that in other coding languages? like c++, c#, python or java or something like that? I love codes and coding
@suwedo86775 жыл бұрын
It's not really about the language, it's more about the logical aspect of it, you can apply that to any language in fact ^^
@puyanwei7 жыл бұрын
If you don't start from scratch I think it would be good if you could also include the code from the starting point of the video instead of the finished one in your github so we can follow along. Thanks Dan, great stuff! Keep it up! :)
@TheCodingTrain7 жыл бұрын
Great point, thanks for the feedback
@MrThonny158 жыл бұрын
Hey Daniel. Now when you are doing a segment on genetic algorithms I would really appreciate you making a video on the basics of neural networks in p5. It is just something I would love to try to implement in generativ art but it is difficult to find good material on the subject.
@TheCodingTrain8 жыл бұрын
I'm planning on it! github.com/CodingRainbow/Rainbow-Topics/issues/20
@damnit2586 жыл бұрын
realy simplified , thank you Mr. Daniel
@thekkb0074 жыл бұрын
This Guy is so lovable. I wish i had a friend like him :)
@rajinish04 жыл бұрын
This was really helpful, thanks. Coding this was fun
@konstantindimitrov20197 жыл бұрын
Is there any other way of picking a character (object) with a probability? Your approach is really interesting (really applause for that :) ) I've never thought of doing it but can we do it say like a 2D array - 1 row for objects, row 2 for P(x)-s? Or give the random() some sort of bias? I really like your mating pool thing as it's just like real world way of how probabilities work the only drawback I recognize tho is the memory 'overkill' and that if it's 15,2% of chance you can't have it unless u go up to 1000 initialized examples and so on - again the memory draining thing.
@BlueNSour8 жыл бұрын
where you have things like "this.genes.length" as a condition in your for loop, it'll compute the length everytime. If you just chuck it in a variable beforehand and use the variable instead it doesnt have to calc everyloop. Not really that important but its a fun little thing to think about
@Fledron7 жыл бұрын
It would be important, if it was for example a really big array. It's code optimization, to get the code running as fast and smooth as possible
@simontewolde36167 жыл бұрын
Wow, wish I didn't skip this chapter in the book. Imagine using this to find a cure for cancer or something
@neithanm7 жыл бұрын
Can I suggest a chroma key filter to get rid of the green reflections on your figure?
@DasAntiNaziBroetchen4 жыл бұрын
No
@rambodehydrated7 жыл бұрын
thank you! Very good examples and explanation you made it look so easy
@rolexianibuyat28185 жыл бұрын
hi sir, i have a question about your code in the population class... what does this line of code do??is this mapping the value of (this.population[i].fitness) from 0 -> maxFitness to 0 -> 1?? "let fitness = map(this.population[i].fitness, 0, maxFitness, 0, 1); " hoping for your reply
@thalissonalves79504 жыл бұрын
Where can I find the code ? I just don't know how to use github, if anyone could post the link for it here I would appreciate it very much!
@_r3mote6 жыл бұрын
Is there a way to download the pdf-file? Thanks for your brilliant work!
@NeverInterpreter7 жыл бұрын
Yay, finally something I can code myself :D
@FredoCorleone6 жыл бұрын
At the beginning of this series you've showed the algorithm to make custom random distribution. Why you've not used that in this example? Something like the following would be easier on memory consumption: let r a random float between 0 and 1 if r < .4 then A if r < .3 then D if r < .2 then B if r < .1 then C Also I don't get why you calculate the probability that way... Wouldn't be better if you weight the probability against the sum of all fitnesses? myProbability = myFitness / sumOfAllFitnesses
@RedCurlyHead5 жыл бұрын
ArrayList holds data in an array, which resizes each time you add an element, correct? So isn't that slow in that particular case.
@vaibhav11806 жыл бұрын
Will it be a good idea to use HashMap in Java to store the "String" as value and "Fitness score" as key? But if the string is duplicate by chance then the population will be reduced to 199
@saikatchakraborty62914 жыл бұрын
can you please provide the code that you are showing in the video .We are facing a lot of problems . and the nature of code git link does not have this code
@kebman7 жыл бұрын
I'm still Norwegian since last time. No mutations. I'm trying to evove in to Swedish, though, but it's damn hard.
@samhblackmore7 жыл бұрын
Hey Daniel, loving this series so far. Just wondering, you do a lot of looping over arrays, is there a reason you don't use the built in array functions like forEach, map, filter, every, etc. I believe these were introduced in ES5 so perhaps they weren't available at the time in vanilla javascript or perhaps you just wanted to keep your code simple? Thanks!
@TheCodingTrain7 жыл бұрын
More just to keep things simple, but I think I'll consider incorporating them in the future!
@A_Lesser_Man4 жыл бұрын
loving your GA series! I'm doin AI :D albeit rudimentary (starting with your Boids, i'm gonna make'm bigger, better, bolder, badder), but alas, one step at a time. the hard part will be melding all these pieces together to make my boids do what i want. also, wouldn't "if (random(1) < mutationRate)" be more correct as "if (random(1)
@caueZero7 жыл бұрын
Very nice videos. Thanks.
@irsyadkamil66314 жыл бұрын
This is a cool video. Thank youu. But i was wondering, can we apply GA on matrix form data ?
@pankajsharma_ua4 жыл бұрын
I DNT know anything about ai but knows programming and logic. from where should I start ur lectures to start from scratch
@yard20105 жыл бұрын
you work is amazing! keep it up
@narval74952 жыл бұрын
Such a good video
@nilsherrmann20187 жыл бұрын
Hey. I was just wondering if the mating pool generation will eventually become a problem if the fitness of your individual genes is very far apart from each other? Say for example, the fitness of A would be so much higher then the fitness of the rest of your elements that A should be picked with a probability of 90%. Then the resulting reproductions would in almost all cases lead to A crossing A, which of course would not change a thing (except in the event of a mutation). Would it be better in a general case to allow mating only once per element per generation? BTW: Very nice video series! I enjoyed it very much so far!
@nilsherrmann20187 жыл бұрын
PS: Instead of filling the mating pool array with actual DNA objects, why don't you just use an array of unsigned integers resembling the indices of the individual objects in the population array? This would surely reduce your memory requirements by preventing unnecessary double storing of the DNA objects.
@123userthatsme7 жыл бұрын
Could you eliminate that issue with an inbreeding selection function? Elements with the same parents or grand parents would automatically be reassigned in the mating pool.
@edoars7 жыл бұрын
If I put population.calcFitness() before everything else, the algorithm does not end. Am I doing something wrong?
@immanuelkant78955 жыл бұрын
16:44 Isn’t it quite common to have the same parent twice, namely the fittest individual?
@ayaayari56665 жыл бұрын
You saved my semester thank you!!!!
@TheCodingTrain5 жыл бұрын
glad to hear!
@MrDonald9117 жыл бұрын
Why not doing all the process on the set of characters ( DNA ) ? I don't see the point of using 1 element of a population each time creating a set of characters ( its DNA ). I'm transforming your code in C# right now , thank you for answering me :)
@finnoulataylor32347 жыл бұрын
Great video! what texteditor do you use?
@igz8 жыл бұрын
This is really interesting!
@usamatahseenulhaque91254 жыл бұрын
Thank you very much
@alexanderyau63476 жыл бұрын
Do you make the evolution strategies video?
@Marc_B.46 жыл бұрын
Hello everyone ! I didn’t quite understand what the map function returns at 13:51 . Can someone enlighten me with an example ? Thank you :) (Sorry if bad English, it's not my native language)
@oluwatosinohiro22204 жыл бұрын
Thank you so much for this
@SaintPepsiSanCoca8 жыл бұрын
I feel stupid for saying but I can't seem to find your source code on this lesson :) I've made 2 GA's as well (not very good ones) but when your video's on GA's popped up I wanted to give it another shot
@ErebuBat8 жыл бұрын
I had the same problem, some google-foo lead me to: github.com/shiffman/The-Nature-of-Code-Examples-p5.js/tree/master/chp09_ga
@TheCodingTrain8 жыл бұрын
Sorry I need to do a better job of keeping my code and links organized. github.com/shiffman/The-Nature-of-Code-Examples-p5.js/ is the right repo for this video.
@othmandont93555 жыл бұрын
great video man thanks for your effort
@sebastiankoziel80555 жыл бұрын
great stuff! Thank you
@thejswaroop52304 жыл бұрын
do these genetic algorithms have a fixed order of time complexity??..... sry for late comment
@ujjayinibose99937 жыл бұрын
Hey , can you please write a code on web service composition using genetic algorithm! It would help a lot! Thanks!
@SuperBlackBeto5 жыл бұрын
Do u guys have a code for artificial bee colony in java? Or some libraries that implement that code? :) i need it for a research
@lamo4406 жыл бұрын
What are the optimizing techniques for image processing
@NakMs7 жыл бұрын
This is really helpful video thank you :)
@connercampbell4567 жыл бұрын
When i open index in chrome... It shows "Best phrase: Stats & All phrases:" Thats it.. any help??
@KAYKAYMUS4 жыл бұрын
why do we need a bigger mating pool ? cant we map the members in population to a weightage (calculated as its fitness/total fitness of the population). The weightage will always be a number from 0 to 1 and the sum of all weightages will be 1. So a rando m number generated (0..1) can be mapped to each element in population. Say weightages for 3 elements A,B, C are 0.4, 0.5, 0.1. Random number generated from 0..0.4 will select A, 0.41..0.9 will select B , else C will be selected.
@AlissonNunes7 жыл бұрын
How I know when stop if my problem don't have a target?
@urgisjot8 жыл бұрын
woohoo new one!
@TheCodingTrain8 жыл бұрын
Thanks for watching!
@hafeez90847 жыл бұрын
hey sorry if i sound like a fool, but can i get the matlab code of the sample program?
@tristankold90195 жыл бұрын
I though a fitness score of zero meant zero problems, but he increments it when chars match the target. Is there a best practice?
@rinkagamine92015 жыл бұрын
It's a definition thing. Typically when speaking of a fitness function, the higher the score the better it is. What you were referencing is mostly called a cost function (sometimes also calles loss function). When you think about it, it kinda makes sense, because if something costs zero its all good and if something has a very high fitness its also good, right :D? But it really doesn't matter. In this case for example you could define the function like, lets say whe have a phrase with N letters, then our cost function would be "the sum of the letters which don't match with the corresponding letter in the target sentence". This means if none of the letters match then our cost would be N. On the other hand if all the letters match then we get a cost of zero. Hope this helps :)
@84zhebiitha487 жыл бұрын
In what software do you make your presentations?
@seongmopark91646 жыл бұрын
I'm not a professonor in this part though, but.. I have a question.I'm just wondoring why the parents are only two?Is there any jammed problem when I picking more than 2 parents?for example, when I will find this 'paper' word, then I try to combine 5 letter to 5 parent?
@tusuubiraedward96003 жыл бұрын
Hello Good work but can you give me help with GA in R?
@mibdev7 жыл бұрын
*Yes!* The *this dot* song!
@ccuuttww6 жыл бұрын
I think u should generate n(population) child first and check the kid's max score because I find sometimes the kid 's max score is smaller than the last genration if this happens u should stop the caculation it always come form larget phrase like 100 words with low population
@kcseforecast75802 жыл бұрын
do a timetable with genetic algorithm
@piotrptak55076 жыл бұрын
I can't thank you enough.
@h4tt3n Жыл бұрын
Could someone please provide a direct link to the specific github repo Daniel is showing (not just the coding train main github page)? I have spent some time looking and searching, and it doesn't seem to be there.
@TheCodingTrain Жыл бұрын
Is this what you are looking for? editor.p5js.org/codingtrain/sketches/PqRSmKLQU more here: thecodingtrain.com/tracks/the-nature-of-code-2/noc/9-genetic-algorithms/4-looking-at-code and here: nature-of-code-2nd-edition.netlify.app/genetic-algorithms/
@h4tt3n Жыл бұрын
@@TheCodingTrain Thanks a ton!
@abhikmitra26504 жыл бұрын
Can anyone explain what the map() function is doing here?
@prikundnani26227 жыл бұрын
The presentor is growing on me
@nagesh0072 жыл бұрын
Awesome
@TM-ui6wx8 жыл бұрын
how is using a genetic algorithm more efficient in this case than a different type of algorithm?
@TheCodingTrain8 жыл бұрын
It's not necessarily for this particular problem, but it's a good one to demonstrate the idea I think!
@ForCeGR7 жыл бұрын
Saying "4 out of 10 times will be an A" it's not true. The probability is that in 1 pick, I have 40% chance of picking "A". Many people confuse this.
@TheCodingTrain7 жыл бұрын
Oh, this is a very good point, thank you for the correction!
@tellvivk8 жыл бұрын
thanks a lot man, you are the best :D
@harshpatel3096 жыл бұрын
I have 1 Question... What if crossing over of parents generates an output which has 0 fitness score
@harshpatel3096 жыл бұрын
I actually tried to implement this algorithm in python and after a few generations the mating pool was empty: i.e after crossing over ,all parents had fitness score of 0 so all had the probability of becoming parents 0.i.e they occupied no space in the mating pool list: Please provide answer
@theSwomry4 жыл бұрын
So how would I do this in processing?
@ibrahimlaachichi78187 жыл бұрын
salut j 'ai besoin d'un qui modéliser le minimum de la fonction x*x avec les algorithme genetique merci
@stinkytoby7 жыл бұрын
Can someone explain the processing logo to me? Is it a p3? 13? pb?
@amdreallyfast6 жыл бұрын
Where is the code for this? It isn't in your github repo. Your coding challenge for smart rocket is in there, but not this lesson. I followed as best I could, but my version using the same parameters (pop 200, mutation rate 1%) is running for 10,000+ iterations and coming up wrong. Having working code to compare with would be helpful.
@TheCodingTrain6 жыл бұрын
Try these repos: github.com/shiffman/The-Nature-of-Code-Examples/tree/master/chp09_ga github.com/shiffman/The-Nature-of-Code-Examples-p5.js/tree/master/chp09_ga I need to do a better job of organizing all this stuff.
@amdreallyfast6 жыл бұрын
Thanks! I managed to eventually get it working on my own, and I found in doing so that doing a crude "gene split" with the left 50% from parent A and the right 50% from parent B significantly increased the time to completion. Setting the split midpoint to a random value yielded a much faster convergence to the target phrase. I thought about it, but my only conclusion was this extra bit of randomness was somehow a more important piece of randomization than the mutation. Don't know why, but TIL.
@cashel11116 жыл бұрын
having a fixed point to cut in two means that there is a 1/10 chance at finding the optimal slice position. there is also a 1/10 chance of finding it when you choose a random point to slice, however the 'optimal slice point' is never ever going to be in the same spot continuously (as im pretty sure its random too) the simplest way to test this i think would be to have a random number between 1 and 100. After 1000 trials, see how many times it counts an individual number, and then compare that count to the same function, but this time instead of comparing it to one number, compare it to a second random number between 1 and 100 since were on a programming channel i made a small procedural console app (im no pro :P ) in c# i see im going to have to rework the whole thing if i want an accurate answer, however the results are looking like: using a fixed number to compare the random number to yields more consistent numbers and using two random numbers is for more extreme, with the maximum numbers being way higher, and some of the lows being way lower since this algorithm (in the video) is going to preferentially select high fitness scores, this is almost guaranteed why your own version worked so much faster using the double random number thing :) i also think an even better way to split the genes is not in half at all, if you chose a random char from each parent every time i think it would introduce a whole new level of chaos into the generation and allow the ones with ridiculously high fitness score to shine, but it does cost far more processing power.
@chaimeisenbach20978 жыл бұрын
Why are you using ASCII?
@DarionAOD5 жыл бұрын
Is that map function he uses part of standard javascript?
@itsmeshaner5 жыл бұрын
Nope, it's part of p5.js. Here's the reference: p5js.org/reference/#/p5/map
@paladin11475 жыл бұрын
I don't understand why you named DNA[][] population, shouldn't it be like say a member. Please correct me if I am wrong. EDIT: I got it I am dumb.
@maresstefan33916 жыл бұрын
How can I write the code without objects?
@ac11dc1107 жыл бұрын
I can't find the source code
@marcielxd1007 жыл бұрын
Hey man, I downloaded your code and tried to run it on p5, but it returns me an error 60: Uncaught ReferenceError: Population is not defined
@Stanistu7 жыл бұрын
Try to create index.html from the source as well. It schould be working!
@adelsabanovic29863 жыл бұрын
Where can I find the Java code
@dineshbhatotia87837 жыл бұрын
I cant find the js code of this , can someone send a link
@shivamdubey47832 жыл бұрын
great tutorial sir it would be better if you explain and code not prewritten code it becomes difficult to understand
@akshaysunil28524 жыл бұрын
can you do the same video in python
@MaximusFalcon6 жыл бұрын
When you are normalizing each elements fitness, wouldn't you want to map it between the min fitness and the max fitness instead of mapping it between 0 and maxFitness, like you did in the video? If not then why should you use 0 instead of the minFitness?
@TheCodingTrain6 жыл бұрын
Oh this is a good point yes!
@TheCodingTrain6 жыл бұрын
Oh this is a good point! I suppose one reason is to not have any elements with a 0 fitness. But ultimately the normalized values should be a percentage of total fitness to map to probability.
@xxsamperrinxx39936 жыл бұрын
Can someone tell me why we dont just pick the ones with the best fitness instead of use the fitness as a probability ?
@jellohunter79816 жыл бұрын
I don’t know. I just do that
@saurabhahuja67075 жыл бұрын
Because less probability does not mean that it have no probability we have to consider that gene also