Okay.
Actually, this is all we had to change in this regression template.
And now we are ready to execute the sections one by one
to create our model and find out about the final results
and the final verdict, whether it's truth or bluff.
So let's do it.
I'm going to import the dataset first.
All right here we go.
Well import it. We can have a look.
So these are our data set with the levels as the independent variable
and the salaries as the dependent variable.
Okay great.
And now we need to split the dataset into the training set and the test set.
No need for feature scaling
because we're using the very popular E10 71 library that includes it.
And now let's create our model.
So I'm going to select this whole section here.
Press Command and Control Plus and do the cute done regress or created.
Great.
And now let's predict the new results which I'd like to start
by visualizing the SVR results first or predicting the new result.
Well, let's actually predict the result because this is the most exciting step.
And let's keep the best for the end.
But this step is actually very exciting.
Also, because
we are getting the final prediction, we are getting the final predicted salary.
So you know it says you want if you're doing actually this code
by yourself before me, that's actually a very good exercise.
So I really encourage you to do this.
Choose whatever you want to execute first.
It's ready anyway.
You don't need to change anything more now.
So I'm going to execute that right now.
And actually we obtain a predicted salary
of $177,000.
Great.
So remember this employee who we are negotiating the future salary right
now, said that its previous salary was 160 K.
And our model predicted that its previous salary was 177 K.
So first of all, that's actually close to what this employee said.
And besides, it's on the good side of the negotiation.
So that's actually pretty good.
And we can be satisfied with this result and our model.
But to be really satisfied let's see what's happening with the graphic result.
So I'm going to execute this section
and let's have a look at the SVR model.
And here it is.
I'm going to zoom on it and better okay.
So first of all this model fits very well most of the data points.
As a reminder the real observation points are the red points here.
And all the points in this blue curve here which is the SVR model itself
are the prediction points.
So for example, if we're taking this red observation point here,
well the prediction is perfect because the prediction point
is the projection of this red points on the blue curve.
So it's actually the red point itself because the red point
is on the blue curve.
So that makes a perfect prediction.
But here for example
if we take a less accurate prediction but still a very good one,
then we take the real observation point here.
The red point we projected on the blue curve.
And that's the difference between the real salary
and the predicted salary, which is here.
If we projected back on the y axis, which contains the salaries.
But you can see that for all of these points from this one to actually this one,
the blue curve is actually getting very close to the real observation
points, the red points.
And so the predictions are very close to real results.
But that's for all these points of the data set except for this one here.
This one is left alone which by the way corresponds to the CEO.
So I'm sorry for the CEO,
but the reason for what is happening here is that this is actually an outlier.
Not to call the CEO, not liar.
But this is an outlier because as you can see,
this point is actually far from the other points in terms of salaries.
The CEO has a much higher salary than the previous positions.
So for the SVR model, that's an outlier.
And therefore he actually didn't consider it.
It's like it excluded this point in the model by not looking at it
and making its predictions on these points here.
So that's specifically due to the SVR algorithm itself.
But there are a lot of parameters.
And you can actually play with the parameters to change
the way the SVR model perceives outliers.
So for example,
these parameters are the penalty parameters, the regularization parameters.
It's most of the time well described in the description.
And of course the E 1071 library includes such techniques.
But we're not going to do it here in this tutorial because we actually don't need
to get a good prediction of the CEO salary and remember what we actually needed.
What is a good prediction
of the previous salary of this employee we are negotiating with?
And this employee has a level 6.5.
And around this point we can see that the SVR model fits very well
to our data set.
And we actually get a prediction of 177 K quite close to the real
or the mentioned salary of this employee, which is 160 K.
So that's actually pretty good.
And therefore the verdict of truth
or bluff according to our SVR model is rather true.