Nice Genes, Wanna Breed?: Genetic Algorithms For The Non-Tech-Savvy

Gregory Belhumeur
SSENSE-TECH
Published in
7 min readDec 12, 2019

Culturally speaking, SSENSE is very quick to adopt novel and unexpected solutions to old problems. Navigating between content, commerce, culture, and technology, we face a wide spectrum of challenges. Be it allocating buying budget or planning staff capacity, our complex and unique issues are tackled by a team composed of the best experts in the industry.

With a virtually infinite number of solutions, our experts have to rely heavily on experience and instinct to hash out those puzzles.

Say you were to design the perfect suit. If we keep the problem at a high-level, we could frame it as searching for the best possible combination of color and cut for the shirt, vest, pants, and shoes, to assemble our perfect suit. The combinations of these factors would leave us with roughly a couple million possibilities. Modern computers should be able to list all the possible solutions and find the most adequate one in a reasonable amount of time.

Of course, our perfect suit problem is solvable to the extent of providing directional information. However, in luxury fashion, with each customer’s unique taste in fit and of brands, the devil is in the details.

If we wanted to get more granular, for instance, materials, cuts, colors, lining, etc, for every piece, the number of possibilities involved would grow exponentially. It becomes too computationally complex to solve in a manageable timeframe. We would need a designer, our expert, and their instinct to solve this problem.

In this article, I’ll explain, in a practical manner, how we can find a reasonable solution to such complex problems by mimicking natural selection using something called Genetic Algorithms (GA).

Genetic algorithms, cool name

Genetic algorithms are a mysterious-sounding technique in a mysterious-sounding field: artificial intelligence. The name genetic algorithms does sound complex and has a faintly magical ring to it, but it turns out that they are one of the simplest and most intuitive concepts you’ll encounter in AI.

Actually, genetic algorithms have had a place in the machine learning repertoire for decades, but the increasing number of incomputable problems paired with evolution in computing resources brought it back on the tables in recent years.

What do they do?

To keep it simple, genetic algorithms are commonly used to approximate the best solution to a problem. If you are mathematically versed, read optimize functions. They can find better answers to a question, but cannot solve new problems. Given the definition of a suit, they might create a better suit, but they’ll never give you a dress.

The magic lies in how it does it.

99 problems but my suit ain’t one

Let’s go back to our initial problem: designing the perfect suit. To keep it simple, we are trying to find the most suitable suit (Individual) in all the possible suits (Population). By most suitable we mean the one with the best set (Chromosome) of characteristics (Genes) to satisfy our client (Fitness).

In genetic algorithms, an Individual is characterized by a set of parameters known as Genes. Genes are joined to form a Chromosome. Chromosomes are a representation of the Individuals of which make up a Population. Fitness determines the ability of an Individual to compete with other Individuals.

Feels like high school biology, right? Here’s a simple diagram to summarize the whole thing:

The only limit as to how fine the granularity can be is dependant on the time you have on-hand to model the problem and wait for it to solve.

If you’re following, you should now understand it would be possible to create all the possible combinations of Genes (Chromosomes) and compute the Fitness to find the best suit. Unfortunately, doing this would take a lot of time and immense computing power. Here is where GA can help us.

Follow the process

The process includes 3 big steps Selection, Breeding (or mating), and Mutation.

Starting with the first generation of randomly generated suits, we will select the top 50% based on Fitness. The selected suits will then breed to produce another generation of Individuals. Amongst this new generation, we’ll apply some mutations.

Survival of the fittest

In the previous graph, if the only important thing for Fitness was that the suit is skinny, ‘SUIT 2’ would be considered better. In this line of thought, Fitness represents a score attributed to a Chromosome based on its Genes. Some Genes may be more important than others.

Only the strong survive the selection. By breeding only the top suits to create our generation, chances are the new resulting suits will have a better Fitness on average than the previous generation.

But how do you breed suits?

Breeding suits

Breeding refers to what is generally the most common method of creating new Chromosomes from an existing generation. It uses a pair of said Chromosomes as parents and creates a new child Chromosome. GAs typically use the crossover method. It consists of using a subset of the genes of both parents. Here’s an example of what would happen if we were using half of the Chromosomes of the parents. It’s pretty intuitive as you probably have half of your father’s traits and half of your mother’s traits.

In our case it would be the equivalent of two suits mixing pieces. If we were to dive deeper, we could also mix only traits like colors or motif.

X-suits

Just like in biological terms, the mutation is used in GAs to push the hypotheses toward optimal. Generally used sparingly, the mutation would simply flip the bit of a random gene and push the chromosome forward to the next generation. It is nature’s strategy for escaping potential local minima. You can picture it as having a kid 1 ft taller than their siblings or a baby blue suit in a black-tie event.

Here for a blazer, if the flipped gene was the color, we would simply get the exact same blazer in another color. This mutation would keep us from getting only black blazers after multiple generations.

Rinse and repeat

Now that we have the whole process mapped, we can use our last generation and repeat it again and again. This will result in generations getting fitter over time converging to an optimum. We can select the fittest Individual in our Population and name it as our suit to rule them all.

START
Create the initial population (generation 1)
REPEAT
Compute fitness
Select the fittest
Breeding to create a new generation
Mutation on the new generation
UNTIL population has converged
STOP

Apart from setting an iteration count, we can also change the size of the Population, the breeding method, and the mutation logic to get better results faster.

Limitations

Even though introducing mutation minimizes the chances of getting stuck in a local minimum, it is really important to understand that there is no way to know if this suit is the global optimum. A GA’s objective is to let us determine a fairly good estimate in a fraction of the time.

So no more designer needed?

Some problems are still too complex to be solved by algorithms. We’ll always need designers to go beyond boundaries and innovate but I wouldn’t be surprised if I were to buy a pair of sneakers designed by an algorithm in the upcoming years.

We barely scratched the surface of Genetic Algorithms and didn’t talk about how the Fitness should be computed. This part of the Genetic Algorithms in itself is very complex and would need specialists with a deep understanding of their field. Only a team of stellar buyers, merchandise planners, and business analysts would be able to seize and model the intricacies of allocating a buying budget. The same goes for conceiving the perfect suit…

SSENSE is a prime example of how companies can find unique ways to leverage algorithms. By pairing business units with data scientists, repetitive problems, even the more complex ones can be optimized, automated, and energy can be reallocated to other issues. Of course, all this requires an investment of time, money, and brainpower — but the payoff is worth it. Companies that neglect this investment, or delay too long, may one day watch their business model unravel.

If you have a few minutes to spare, you can try this game where the goal is to create a creature that will learn to run, jump, or climb by using Genetic Algorithms. It is oddly addicting and results are surprising.

Editorial reviews by Deanna Chow, Liela Touré & Prateek Sanyal.

Want to work with us? Click here to see all open positions at SSENSE!

--

--

Gregory Belhumeur
SSENSE-TECH

I build AIs, models and algorithms that make our competitors think we're using cheat-codes --- Principal, AI/ML @ SSENSE + Partner @ Beaucoup Data