Hello, my friends.
All right, let's make that prediction with the SVR model.
So we're going to create a new code cell here.
And here we go.
We're going to start of course from our regressor
from which we're going to call the predict method that will take as input.
And now I'm asking you what what will it exactly take as input.
Well it's not directly the 6.5 level
but the scaled value of the 6.5 level.
Right.
Because our SVR model was trained on the scaled values at the training set,
and therefore in the predict method, we must enter the scaled value
of the input that we want to predict.
And therefore here we must call our scalar x object
from which we're going to call the transform method.
There we go.
And then in this transform method of our scaler object,
well that's where we can enter our position level of 6.5.
But remember we have to enter it in a double pair of square brackets
because the predict method expects any input as a 2D array.
All right.
So let's enter 6.5. And now that's not all.
There are two extra things we need to do.
Remember that we not only scaled the inputs in X
but we also scaled the output.
Remember I'll go back to feature scaling here.
We made that scaler object for the input x
but also that scaler object as y for the output y.
And indeed we used that scaler y object here to scale the output y.
And therefore since the output y was killed, well, in order to get
the prediction in the original scale, meaning the original salaries,
well, we must apply a reverse scaling to that whole prediction.
Right.
And the method that will do exactly this is a method called inverse transform.
And this will exactly reverse this killing that we applied to the output y.
All right. So let's do this. Let's call this method.
First we have to call it from our c underscore
y object because we want to reverse the scaling of the output y.
So let's see why from which we call this inverse underscore.
There it is inverse transform method.
And then we will put this whole prediction in the parentheses
of this inverse transform method of the object.
So here we go.
We add a parenthesis here and we close it right here.
All right almost ready.
We're almost ready to get that prediction.
But there is one less thing we need to do.
And you don't need to worry too much about this.
This is just for the SVR model.
You won't have to apply too much of reshapes
and all the other models of this course, but to avoid a format error,
we must just add inside the parentheses of the inverse transform
method another reshape which is dot reshape
and then in parentheses you enter minus one and one.
And this way
we will all avoid a format error and we'll all be able to get the prediction.
All right.
So that's it.
We are ready to get the prediction.
But first remember that in the previous tutorial we didn't run the cell.
So let's do it now to train the SVR model.
Here it is.
And so now if you're ready let's get the predicted
salary of the position level 6.5 by the SVR model.
Here we go.
Let's run this cell and we get $170,370.
All right. It looks pretty good.
It looks to make pretty good sense, but that we will double check
in the next tutorial by visualizing the SVR results.
Try to do it before me.
You will again have to play with the transform
unless you are inverse transform. But you can do it.
You can of course start from the codes
at the end of the polynomial regression notebook.
At least that's where we'll start from.
So I look forward to this.
And until then, enjoy machine learning.