Hello my friends, and welcome to this new practical activity
on this time support vector regression.
So I have to start by telling you that the model we're about to implement
will be slightly more advanced than the models were built before,
but it's totally fine.
We will do it together and we will succeed 100%.
So why is it slightly more advanced?
Well, that's because we will have to play a lot with feature scaling.
And I can tell you that after this implementation of the SVR model,
you will be a master in feature scaling because you will know
not only how to apply the feature scaling transformation,
but also how to apply the inverse transformation.
You know, to go back to the original scaling.
So you will know all the Sep tools, let's say
a feature scaling, and you will handle them like a probe.
All right.
So if you're ready let's start.
And just before we go inside
the folder, let's make sure here that we are all on the same page.
I gave you the link to this folder containing all the codes and data sets
right before this tutorial in an oracle, so make sure to connect to it.
And now we should all be on the same page.
And therefore we're going to go of course to part two regression.
And then of course to support vector regression SVR.
All right. And as usual we're going to start with Python.
So we're going to go to that Python folder inside which will find
the same data set as before.
Because you know I would like to compare the performance of different regression
models on this data set, which proved to have some non-linear
relationships, you know, between the feature,
which is the level you know, the position level going from 1 to 10
and the salary going from 45,000 to $1 million per year.
So here again, this is exactly the same scenario.
We want to train this time a support vector regression model to learn
and understand the correlations between these position levels and these salaries,
and to quickly remind the context, we are hiring a new person
who is expecting 160 K salary, justifying this by the fact
that this person earned a 160 K salary in the previous company.
This data is exactly the data of the previous company.
You know, with the different position
levels from business analyst to CEO and their corresponding salary.
And so not only we want to train a model to learn these relationships,
but also we want to deploy this model to predict
the salary that this person had in this previous company,
knowing that indeed, this person was a region manager for a couple of years
and therefore is considered to have a position level of 6.5.
So that's the exact same scenario, exact same data set.
And so now let's build the support vector regression model on this data
set to see if it performs
better than the previous model which showed great results.
The polynomial regression model.
All right.
So let's do this.
Let's close this and let's open our support vector
regression implementation either with Google Colaboratory
if you love it, or with Jupyter Notebook because indeed it is an IP and B file.
All right.
So that's the whole implementation.
Let me quickly show you the structure of the implementation.
We're going to start by importing the libraries as usual
then importing the data set then applying feature scaling.
So this is interesting.
This time we have to apply feature scaling because in the SVR model
there is not this, you know, explicit equation
of the dependent variable with respect to the features.
And mostly there are not those, you know, coefficients multiplying
each of the features
and therefore not compensating with lower values for the features.
Taking high values. No.
This time the support vector regression model has an implicit equation
of you know, the dependent variable with respect to the features.
So we don't have such coefficients, and we will definitely
have to apply feature scaling for this model.
So you see you start to understand when and when not to apply features.
Getting well.
You know we don't have to apply feature scaling for linear regression models
where you have indeed
those coefficients that can compensate with the high values of the features.
And so of course these include simple linear regression, multiple linear
regression and polynomial regression.
And you will see later on in the course many other models.
And for other models which usually have an implicit equation,
you know, an implicit relationship
between the dependent variable y and the features x.
Well, usually for these models we have to apply feature scaling.
All right.
Then we will of course trained SVM model on the whole data set.
You know this time is the same.
We want split the whole data set into a training set and a test set,
because we want to leverage the maximum data to learn
these correlations between those position levels and the salaries.
So we won't do that split.
And we will directly train the SVR model on the whole data set.
Then after this training, well, we'll have a smart SVR model,
which therefore we're going to use to predict this new result and exactly
that salary of this position level of 6.5.
And we will compare, of course, that prediction with the prediction
of the polynomial regression model, which I've kept here.
And then of course, we will visualize SVR results in low resolution
and high resolution to see, of course, the regression curve of the SVR model.
All right.
I'm sure you noticed that I did not click on each of these contents.
Well, I did that on purpose.
It's because I don't want to reveal the prediction.
You know, the predicted salary by the SVR model.
I want us to save the surprise until, you know, we execute that cell
to return that predicted salary.