Hello and welcome to this art tutorial.
So in the previous tutorials we prepared our data set.
Then we fitted the simple linear regression model to our training set.
And now we're going to predict the test set results.
Because we trained our model on the training set.
And we want to see how it can predict new observations.
So to do this we're going to create our vector of prediction y pred.
I'm calling it why pred.
Because this is a vector of predictions.
That is the vector that will contain the predicted values of the test set.
Observations.
And we are going to use the predict function.
So I'm going to write that here.
So that's the predict function parentheses.
And in this predict function it's really really simple.
We will just need to input two arguments.
The first one is our regressor.
So that's the simple linear regressor.
And then comma.
And then the second argument is new data.
So that's that's the name of the argument.
But then this new data is the data
that contains the new observations that we want to predict the result.
And so obviously that's the test set.
And actually that is ready.
We are ready to build our vector of predictions.
I will just remind what this is going to do.
Here we have a test set.
This is the column of the number of years of experience.
So what will happen is that our simple linear regression
will predict for each of these test set observations, the salary.
So it won't be the same salary here because these are the real salaries,
the salaries that actually exist in real life.
But since we saw that there is a strong linear
dependency between the years of experience and the salary, the predictions
returned by our simple linear regression model should be close to the salary.
Anyway, we're going to see that in the final step of this simple linear
regression model, because we will visualize on the graph all the results.
But so far, just to explain you what we are expecting.
So let's go back to our model and let's select
this command or Control plus enter to execute.
And here we go.
The vector of prediction is now created.
So let's have a look at it.
We're going to type widespread here in the console.
And here it is.
These are all the salary predictions for our ten observations in our test set.
Okay.
So for example let's let's have a look at the first observation.
The real value, the real salary of the first,
employee of the test set was 46,000 and $205.
And let's see what our model predicted.
It predicted $37,000.
So okay, so that's not too close.
But then if we look at the second observation,
which is the fourth employee, let's call it the fourth employee.
His real salary is 43,000 and $525.
And our model predicted $44,322, which is this time much closer.
Okay, so that's it with this tutorial.
And now the next tutorial is my favorite part,
the part where we visually see what everything that we've been making.
That is, we will be visualizing on a graph the training set results
and the test set results.
So we will make two graph a first graph showing the predictions
of the training set observations, and the second graph
showing the predictions of the test set observations.
And we will see how the simple linear regression line approach
the real observations.
So I look forward to seeing you in the next tutorial.
And until then enjoy machine learning.