[PYTHON] Training data and test data (What are X_train and y_train?) ②

Continuing from the previous ①, we will divide the training data and test data a little more practically.

First, prepare the data.

Now there are two variables x. image.png Thus, in machine learning, when there are two or more variables x We will combine them into one and treat them as uppercase $ \ mathbf {X} $.

Next, divide it into training data and test data.

Training data image.png test data image.png Then, we will create a model formula from the training data. If this is calculated by the method of least squares, it can be calculated as follows.

y=0.9+2x_1+2.0\times10^{-16}x_2

And we will apply this to the test data.

y_{pred}=0.9+2x_{1_{test}}+2.0\times10^{-16}x_{2_{test}}=9,11

From the above, for y_test of the correct answer data I found that the y_pred I expected was roughly correct.

If there are two or more $ x $ for $ y $ Basically, think of training data and test data as above.

In actual machine learning, for data like this one y is the rent, x1 and x2 are the constituent elements (station walk, age, etc.) We are analyzing the data.

Also, the previous article ① and this article ② Both of them use a method called linear regression. I hope to post again in the near future.

Recommended Posts

Training data and test data (What are X_train and y_train?) ①
Training data and test data (What are X_train and y_train?) ②
What are "sudo ln -s" and "ln -s"?
[Python] What are @classmethods and decorators?
(Beginner) What are cores and threads?
What are go mod, go get and go mod vendors?
What are Linux POSIX options and GNU options?
[Mathematics] Let's visualize what are eigenvalues and eigenvectors
Machine learning Training data division and learning / prediction / verification
What are you comparing with Python is and ==?
What are python tuples and * args after all?
Creating training data
Distribution and test
Statistical hypothesis test of A/B test and required number of data
[PyTorch Tutorial ⑦] Visualizing Models, Data, And Training With Tensorboard
MySQL installation on Aws Linux 2 and test data preparation