# Introduction to Artificial Intelligence with Python 1 "Genetic Algorithm-Theory-"

## Relatively easy-to-understand genetic algorithm

This is what artificial intelligence (AI) does not require that much physical strength to understand from 1 to 10. Even those who have stood at the entrance to artificial intelligence are encouraged to work on it and make full use of their ideas in this wonderful algorithm.

## What is a "genetic" algorithm?

For example, suppose there is a cockroach that moves with 100 parameters. The parameters are randomly determined and there are a total of 50 cockroaches. If you race them in a foot race or something, they all have different parameters, so some will run faster and some will run slower. Then rank them. If you give birth to a child in first and second place, can that child become an early one? You can be ** "genetic" **. With that kind of feeling, if you give birth to the top 10 animals and change members with the slower ones out of the original 50 animals, you will have a group with more excellent ones than before.

And if you compete again, give birth to genetically superior children, replace them, compete again, and so on, one day, a tremendously fast guy will come out.

That is the background of the genetic algorithm.

In the first place, AI includes random forests and neural networks, but most of them are the same as solving optimization problems. The genetic algorithm (GA) is one of them, and the outline is to make many organisms appear, compete for survival, and then decide the strongest one.

This can be classified into the following procedures.

** ⑴ Generate an initial population ⑵ Evaluation ⑶ Crossover (heredity) ⑷ Mutation ⑸ Group change (generation change) After that, repeat steps ⑵ to ⑸ **

Let's take a look at each.

### ⑴ Initial group (first generation)

The example was about cockroaches, but of course I think about the settings myself. Here, when the sequence of the set of parameters is considered, it is ** as if the genetic information (genome) of an organism **. The initial number of individuals and the number of parameters are determined, individuals are randomly generated, and this is used as the first generation.

### ⑵ Evaluation

Decide what to rank and evaluate each individual accordingly. In the above example, the "running speed" of cockroaches is the evaluation criterion.

### ⑶ Crossover

This is the process that uses the concept of heredity. At the evaluation stage, consider how to determine the parameters of a child when giving birth to a child with excellent parents as parents. Often used is n-point crossover, in which the parent gene (a sequence of parameters) is divided at n-points and inherited in half.

### ⑷ Mutation

The gene of the offspring inherited by crossing is randomly modified with a certain probability. As a result, competition does not get stuck even if the same individual occurs (that is, it makes a difference between individuals by giving ** randomness **).

## Summary

what about. The person who thinks about this must be a genius. It is a really interesting algorithm to refer to the survival model of an organism. This is exactly what genetic manipulation is. Now, let's put it into practice. You should enjoy the beauty of this algorithm by yourself.

Introduction to Artificial Intelligence with Python 2 "Genetic Algorithm-Practice-"

By the way, according to a paper somewhere, FX automatic trading etc. can get the best results by using this than other AI ...?