JS Sucks, Genetic Algorithms, and Rate my Yoga Instructor

Spent the last week making a webapp with js.node. I don’t like js.

I’ve become really interested in Genetic Algorithms. Machine learning is very powerful and I know I can use it to make something great. I just haven’t thought of anything concrete yet. I’ve started playing around with Xcode 5 and iOS7, and I used them to run this algo I found. The process is real simple. It take user inputed string and run checks on every character. Lets call the user inputed string theString. The algo counts all characters in theString. Then, for every character it generates a random character. It checks each character for how close it is to the same character at index in theString. So if theString at index 0 == “t”, it will check how close the generated character is to that. It then assigns a negative value for every character and adds them. Now the fun part.

<Screen Shot 2013-07-25 at 9.16.43 PM

This part is better than sex. The algo does this 750 times. The algo makes all neighboring strings breed. The breeding is simple. Out of the two strings, the string who is the most “fit” is passed on. Then a new string is made with a random mutation chance. That means that every character in the string has a small chance of changing to a random character. Every child string is put in an array and the most “fit” in that array is the Champion. Now we generate another 750 and do it all over again. The Champion of that group is compared to the new contender. The victor becomes the Champ.

Then some exciting shit happens. It does this loop until one the the Champions has a fitness value of 0. That Champion is equal to theString. This small algorithm doesn’t do anything very useful but it’s a interesting first step toward smart algorithms and machine learning.

I’m also making an iOS app with my friend called, “Rate my Yoga Instructor”.

Advertisements