Hello and welcome to this art tutorial.
Now that we get this curve, and now that we see
that we have an excellent model for our problem,
we are going to validate this model.
And this is the model
we were going to choose to make our final accurate prediction.
So let's do it.
I'm actually going to this new code section that I prepared for you.
So a first one to predict the salary associated
to a 6.5 level according to a linear regression model.
And then the second code section will predict the salary of the 6.5 level
according to our polynomial regression.
This one right here with a fourth degree.
Okay.
So let's start with the linear regression prediction.
We're going to do exactly the same as in simple linear regression.
We're going to use the predict function.
But actually something is going to be different and will interest many of you.
This time we're not going to make some predictions
on a whole test set that is on a vector of observations.
We are going to make a single prediction.
That is, we're going to make
a prediction of a single level, which is going to be the 6.5 level.
So you're going to see that the syntax
is going to change the technique to make this prediction is going to change.
But it's actually as easy.
So let's do it.
We're going to call this prediction widespread as before.
So be careful why pred was before a vector.
And now it's only going to be a single prediction value.
So let's still call it why pred anyway.
And same as before.
We're going to take the predict function.
So let's here take predict. Here we go.
And now in this predict function remember we need to specify first
the regressor we want to make the predictions with.
So that's the first argument.
And then the second argument is the new data of which
we want to make the predictions.
Okay. So let's input the first argument.
The first argument is our regressor.
And since we're predicting the result with the linear regression regressor.
And since we called this regressor linear,
then the first argument we need to input here is Lin rec.
All right.
So that's our regressor.
And now we need to input the new data of which we want to make the prediction.
So this new data is as you understood, a single element a single observation point.
And this observation point is actually the 6.5 level here.
So what we'll do now is to actually, you know,
since this 6.5 level doesn't exist in our data set,
we actually need to create a new data frame containing the 6.5 value.
We're not going to add this 6.5 level in our data set.
We're going to create a new data set of only one line and only one column.
That is of only one cell actually.
And this cell will contain the 6.5 level.
So let's do this.
The syntax in order to do that is very simple.
We just need to type here dataframe separated by a dot.
So frame here we go data frame.
And now as you can see it automatically added some parenthesis.
And in these parenthesis we need to input level
equals 6.5.
And that's it.
That's actually all you need to do to make a single prediction
using the predict function with a specific regressor.
That is here the linear regressor.
Let's check it out.
Let's select this line and execute okay.
Why pred correctly generated.
So as you can see why pred is the values here, we can already see
the predicted value of the 6.5 level salary
and it's actually $330,000,
so much higher than what this employee mentioned its salary was.
So that's actually a good start for us.
But remember, we don't want to keep the linear regression model.
We want to keep the most accurate regression model.
That is of course the polynomial regression model.
So what we're going to do now is make this same prediction.
But this time according to our polynomial regression model.