Hello. My name is mizutakawater and I will be a member of society from April 2020. I like baseball and lacrosse. I'm learning about reinforcement learning in my graduation research, but machine learning! Artificial intelligence! AI! Isn't there anything that explains it in an easy-to-understand manner? I felt that. (In the first place, I often think that academic books and technical books of engineers are too unfriendly to beginners compared to liberal arts studies. Is it the culture of engineers to say things that are easy to understand incomprehensible? ??) ← It seems to be killed by a skilled engineer
By the way, _It's really easy for beginners to understand (← important concept) _Introduction of machine learning, I would like to use python! !! There may be differences in the details, but I will pursue easy-to-understand, like an engineer from a liberal arts background.
It's a sudden word, but I have to put up with it because there are only two (laughs). Even if you don't remember the words, there is no problem if you can understand only the outline.
Overview | Notation(Custom) | |
---|---|---|
Explanatory variable | Data used for prediction, also called features | X |
Objective variable | Numerical values and data you want to predict | y |
Example: Predict the 100m dash time (objective variable) from the height, weight, and age (explanatory variable) of track and field athletes.
Machine learning can be divided into three main categories! Immediately, I will learn while using the explanatory variables and objective variables that came out earlier (also as a review).
―― 1 Supervised learning
Explanatory variable(X)Objective variable using(y)Predict.
Correct answer data(Explanatory variable)Prepare the data you want from there(Objective variable)Image to predict
―― 2 Unsupervised learning
Predict what the objective variable itself is good from the explanatory variable when the objective variable is unknown
―― 3 Reinforcement learning
The program learns better choices on its own
This time, the concept is __ easy for anyone to understand, so let's learn about supervised learning, which is the basis of the basics! Unsupervised learning and reinforcement learning are different programs!
There are two types of supervised learning.
type | Contents | Example |
---|---|---|
Regression | Numerical forecast | 100m dash time forecast |
Classification | Category prediction | Prediction of male or female |
Regression, classification, and other difficult words ... → In the end, it's the difference between predicting numbers (= regression) and predicting attributes (= classification)!
Now, let's learn while practicing __supervised learning __regression!
First of all a simple problem. Let's think
There are A ~ D. Their height and weight are as follows. Mr. A: 40kg, 150cm Mr. B: 50kg, 160cm Mr. C: 60kg, 170cm Mr. D: 70kg, 180cm
Then, what is the height of Mr. E, who weighs 55 kg (can be predicted)?
Probably, as shown in the figure, connect the four lines with a straight line, and that straight line overlaps just 55 kg! !! !! Yes, 165 cm! I think it's like that. This is the first-order formula for x (the one I learned in 1!)
y(height) = x(body weight) + 110
It's really easy, that's right. And this straight line is the objective function for predicting the objective variable. __ Machine learning (regression) is almost the goal of finding this objective function __! (There are different approaches for different algorithms, but ignore them! I'm sorry!) Because
If you know the formula of this straight line, you can find the height by substituting X = 55
It's easy
But I don't think there is such convenient data!
So, it will be long, so next time, let's learn how to find the objective function when the data (explanatory variable) is more complicated ~ (Oh, what's the purpose? The purpose is __ to learn about the return of supervised machine learning __! How do you predict the height of a person weighing 55 kg when the explanatory variables are a little more complicated? ?? I'm glad if you understand the story ~)
This is the end of part 1 for theory. The following is the code implementation by python.
We also sang __using __python as a theme, so let's learn how to make this graph. It may be just right for beginners! Since it is for beginners, let's start with the environment construction! (Full-scale implementation of machine learning with python will be available next time!)
--Environment used: Anaconda, MacOs --Editor, execution environment: JupyterNotebook
Anaconda is a tool that allows you to easily manage the execution environment of Pytho. Building an environment for the first barrier to programming. You can do it quickly with Anaconda. There is no way not to use this.
Here, go to the official homepage instead of the terminal and install.
https://www.anaconda.com/distribution/#macos
Follow the on-screen instructions to install, but install the python3 version instead of python2. If you get lost, please refer to this page Anaconda Install
Below, the code to be implemented in the above editor
#Import of module to mural graph
import matplotlib.pyplot as plt
#Setting explanatory variables
X = [40, 50, 60, 70]
#Setting the objective variable
y = [x+110 for x in X]
#Graph mural
#Instantiation of graph
plt.figure(facecolor="w", figsize=(8, 6))
#grid(Mesh)Put in
plt.grid(True)
#Height and weight of each person
plt.scatter(X, y)
plt.scatter(55, 165, color="red")
#Pink straight line of objective function
plt.plot(X, y, color="pink")
#Graph overview
plt.xlabel("weight(kg)")
plt.ylabel("height(cm)")
plt.title("predict")
# plt.savefig("Directory path you want to save"/File name you want to save") #If you want to save the graph
Now, if you press something like the play button on the upper left, the graph should be displayed!
This time, I learned the introduction of "Learn Machine Learning", the construction of a programming execution environment, and the implementation of simple graphs. I wrote all of them that I wish I had. next time
-What is simple regression analysis I would like to write. Thank you!
Recommended Posts