I tried to understand supervised learning of machine learning in an easy-to-understand manner even for server engineers 2

perceptron

Perceptron is an algorithm, an old one, You should know it when learning machine learning.

Simple perceptron

For example, try to calculate popular followers. Let's assume that the index at that time is the number of youtube channel registrations and the number of twitter followers.

For example

User name Number of registered channels Popular(If there is 1)
aaa 50 0
bbb 10000 0
ccc 100000 1
ddd 90000 0
eee 120000 1
User name tw Number of followers Popular(If there is 1)
aaa 100 0
bbb 10 0
ccc 7000 1
ddd 150000 1
eee 90000 1

In this case, since ◯ is ccc and eee, you will be able to see whether it will become popular at the following boundaries. スクリーンショット 2020-05-21 11.20.34.png

If both are popular, we will consider them popular. Speaking above, ccc and eee will be popular.

In this case, by creating a boundary, you can tell whether it is popular or unpopular. スクリーンショット 2020-05-21 11.22.56.png

To make this division in the actual program, w = weighting, theta = bias (inclination adjustment) Adjust by about the value so that it can be allocated by 0,1 (◯ × in the figure) Number of channels = w1 = 1.6 tw Number of followers = w2 = 0.11 And let's set the threshold of 0,1 to 160500 Hmm, how did you find this value? There is no choice but to hit it appropriately. First, find the value of tmp and see if it comes to 0 or 1. Can be judged. Temporarily set the threshold, if it is not correct It feels like fine-tuning w1, w2, theta. This manual work is also difficult for Perceptron.

def AND_famous(x1,x2):
    w1 = 1.6
    w2 = 0.11
    theta = 160500
    tmp = w1*x1 + w2*x2
    
    if tmp <= theta:
        y = 0
    else:
        y = 1
    return y

print(AND_famous(50,100))
print(AND_famous(10000,10))
print(AND_famous(100000,7000))
print(AND_famous(90000,150000))
print(AND_famous(120000,90000))

//console result
0
0
1
0
1

With the simple perceptron, you can divide the classification that can be grouped by one straight line.

Multilayer perceptron

There are cases where it cannot be done in the above cases. For example, what would you do with this result?

Judges those who excel in only one art (not including two arts) Judgment criteria will be genius (XOR) if either is true reference) https://wwws.kobe-c.ac.jp/deguchi/sc180/logic/gate.html https://the01.jp/p0004619/

User name Test score (3),4 is normal) talent(If there is 1)
aaa 3 0
bbb 70 0
ccc 92 1
ddd 6 0
eee 97 0
User name Painting ability score (up to 100) talent(If there is 1)
aaa 100 1
bbb 40 0
ccc 98 1
ddd 92 1
eee 70 0

In this case, only one of them excels It will be aaa, ddd, eee. The figure is as follows

スクリーンショット 2020-05-21 1.12.52.png

Looking at the figure above, I think you should go to classify by ○ and x. When you actually draw a grouping line, it looks like this. I won't program this time, but it's good to just remember that it can be achieved by connecting simple perceptrons.

スクリーンショット 2020-05-21 1.23.53.png

Summary, A simple perceptron can draw a 0,1 boundary with a straight line Multilayer perceptrons can draw 0,1 boundaries on curves, but only those that can be combined with simple perceptrons Will be.

So, isn't it possible to do everything with Perceptron? For example

--Boundary is closed --Those with multiple boundaries --Boundary is bent (thing that cannot be expressed by xor) There are such things, so by trying to be able to do it, The history of evolution is that evolutionary methods have emerged since Perceptron.

bonus

The shape is like this Diagram of multiple perceptrons

import matplotlib.pyplot as plt

#plt.plot(x3)

plt.plot(3,100,marker='o')
plt.plot(70,40,marker='x')
plt.plot(92,98,marker='x')
plt.plot(6,92,marker='o')
plt.plot(97,70,marker='o')

Recommended Posts

I tried to understand supervised learning of machine learning in an easy-to-understand manner even for server engineers 2
[For beginners] I want to explain the number of learning times in an easy-to-understand manner.
[Python] I tried to explain words that are difficult for beginners to understand in an easy-to-understand manner.
[Deep Learning from scratch] I tried to explain the gradient confirmation in an easy-to-understand manner.
[Python] I tried to summarize the set type (set) in an easy-to-understand manner.
An introductory reader of machine learning theory for IT engineers tried Kaggle
I tried to summarize Cpaw Level1 & Level2 Write Up in an easy-to-understand manner
I tried to summarize Cpaw Level 3 Write Up in an easy-to-understand manner
I tried to display the analysis result of the natural language processing library GiNZA in an easy-to-understand manner
Introduction to Deep Learning (1) --Chainer is explained in an easy-to-understand manner for beginners-
I tried to predict the change in snowfall for 2 years by machine learning
I tried to build an environment for machine learning with Python (Mac OS X)
[Machine learning] Let's summarize random forest in an easy-to-understand manner
[Machine learning] I tried to summarize the theory of Adaboost
I tried to understand it carefully while implementing the algorithm Adaboost in machine learning (+ I deepened my understanding of array calculation)
I tried to make an analysis base of 5 patterns in 3 years
How to use machine learning for work? 01_ Understand the purpose of machine learning
I will explain how to use Pandas in an easy-to-understand manner.
[Machine learning] I tried to do something like passing an image
An introduction to OpenCV for machine learning
An introduction to Python for machine learning
(Machine learning) I tried to understand Bayesian linear regression carefully with implementation.
I tried to understand the learning function in the neural network carefully without using the machine learning library (second half).
An introduction to machine learning for bot developers
[For beginners] Introduction to vectorization in machine learning
I tried to organize the evaluation indexes used in machine learning (regression model)
[Azure] I tried to create a Linux virtual machine in Azure of Microsoft Learn
I tried to predict the presence or absence of snow by machine learning.
I tried to implement various methods for machine learning (prediction model) using scikit-learn.
I tried to process and transform the image and expand the data for machine learning
I want to do machine learning even without a server --Time Series Edition -
I tried to understand the learning function of neural networks carefully without using a machine learning library (first half).
I tried to explain how to get the article content with MediaWiki API in an easy-to-understand manner with examples (Python 3)
I tried to move machine learning (ObjectDetection) with TouchDesigner
[Linux] I learned LPIC lv1 in 10 days and tried to understand the mechanism of Linux.
Build an interactive environment for machine learning in Python
I tried to compress the image using machine learning
Since I touched Tensorflow for 2 months, I explained the convolutional neural network in an easy-to-understand manner with 95.04% of "handwritten hiragana" identification.
I tried to compare the accuracy of machine learning models using kaggle as a theme.
Matching app I tried to take statistics of strong people & tried to create a machine learning model
I tried to verify the yin and yang classification of Hololive members by machine learning
The result of Java engineers learning machine learning in Python www
I tried using Tensorboard, a visualization tool for machine learning
I tried machine learning to convert sentences into XX style
I tried to implement ListNet of rank learning with Chainer
I tried to implement blackjack of card game in Python
I tried to create an article in Wiki.js with SQLAlchemy
An introduction to machine learning
[Machine learning] Understand from mathematics that standardization results in an average of 0 and a standard deviation of 1.
I tried to make Othello AI with tensorflow without understanding the theory of machine learning ~ Introduction ~
I tried to make Othello AI with tensorflow without understanding the theory of machine learning ~ Implementation ~
I tried to create an environment of MkDocs on Amazon Linux
Note that I understand the algorithm of the machine learning naive Bayes classifier. And I wrote it in Python.
I tried machine learning with liblinear
I wrote a book that allows you to learn machine learning implementations and algorithms in a well-balanced manner.
I tried to make Othello AI with tensorflow without understanding the theory of machine learning ~ Battle Edition ~
I tried calling the prediction API of the machine learning model from WordPress
How to use machine learning for work? 02_Overview of AI development project
Comparing the basic grammar of Python and Go in an easy-to-understand manner
Search for technical blogs by machine learning focusing on "easiness to understand"
I want to color a part of an Excel string in Python