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 ...?

Recommended Posts

Introduction to Artificial Intelligence with Python 1 "Genetic Algorithm-Theory-"
Introduction to Artificial Intelligence with Python 2 "Genetic Algorithm-Practice-"
Introduction to Python Image Inflating Image inflating with ImageDataGenerator
[Introduction to Python] Let's use foreach with Python
[Python] Introduction to CNN with Pytorch MNIST
The first artificial intelligence. Challenge web output with python. ~ Flask introduction
Markov Chain Chatbot with Python + Janome (1) Introduction to Janome
Markov Chain Chatbot with Python + Janome (2) Introduction to Markov Chain
Introduction to Tornado (1): Python web framework started with Tornado
Introduction to Python language
Introduction to OpenCV (python)-(2)
Introduction to formation flight with Tello edu (Python)
Introduction to Python with Atom (on the way)
Introduction to Generalized Linear Models (GLM) with Python
[Introduction to Udemy Python3 + Application] 9. First, print with print
[Introduction to Python] How to iterate with the range function?
Playing with a user-local artificial intelligence API in Python
[Chapter 5] Introduction to Python with 100 knocks of language processing
An introduction to Python distributed parallel processing with Ray
Introduction to Mathematics Starting with Python Study Memo Vol.1
Reading Note: An Introduction to Data Analysis with Python
I tried to implement an artificial perceptron with python
[Chapter 3] Introduction to Python with 100 knocks of language processing
[Chapter 2] Introduction to Python with 100 knocks of language processing
[Chapter 4] Introduction to Python with 100 knocks of language processing
Connect to BigQuery with Python
Introduction to Python Django (2) Win
Predict candlesticks with artificial intelligence
Connect to Wikipedia with Python
Post to slack with Python 3
Introduction to RDB with sqlalchemy Ⅰ
Introduction to serial communication [Python]
Switch python to 2.7 with alternatives
Write to csv with Python
[Introduction to Python] <list> [edit: 2020/02/22]
Introduction to Python (Python version APG4b)
An introduction to Python Programming
Introduction to Python For, While
Python sample to learn XOR with genetic algorithm with neural network
Introduction to her made with Python ~ Tinder automation project ~ Episode 6
20200329_Introduction to Data Analysis with Python Second Edition Personal Summary
Introduction to her made with Python ~ Tinder automation project ~ Episode 5
Introduction to Python for VBA users-Calling Python from Excel with xlwings-
[Raspi4; Introduction to Sound] Stable recording of sound input with python ♪
[Introduction to Python] How to get data with the listdir function
[Introduction to Udemy Python3 + Application] 51. Be careful with default arguments
[Introduction to Udemy Python 3 + Application] 58. Lambda
[Introduction to Udemy Python 3 + Application] 31. Comments
Python: How to use async with
Link to get started with python
Introduction to Python Numerical Library NumPy
Practice! !! Introduction to Python (Type Hints)
[Introduction to Python3 Day 1] Programming and Python
[Python] Write to csv file with Python
Create folders from '01' to '12' with python
Nice to meet you with python
[Introduction to Python] <numpy ndarray> [edit: 2020/02/22]
[Introduction to Udemy Python 3 + Application] 57. Decorator
Try to operate Facebook with Python
Introduction to Python Hands On Part 1
[Introduction to Python3 Day 13] Chapter 7 Strings (7.1-7.1.1.1)