Hello and welcome to this art tutorial.
So today we are going to implement our second nonlinear regression model.
It's going to be the SVR support vector for regression.
So let's do it.
We're going to use a regression template.
And you're going to see how it's going to be so easy.
So let's start by doing the basics.
Set the right folder as working directory.
So we'll go to Machine learning A-Z part two regression.
And then support vector regression right.
That's the right folder.
All good.
Let's click on set as working directory to set the folder as a working directory.
Great. And now we can start.
So we're going to take our regression templates.
And we're going to take everything from here to here.
Copy and paste it in our SVR model.
Here we go.
And now we just need to change a few things.
So let's start by changing the basics.
We're going to replace regression model here by SVR.
Okay.
And same here SVR results.
Okay. And same here.
All right.
That was the easy step.
And now let's get to the interesting step.
So this interesting step is of course to create our SVR regressor.
And we are creating it here.
So I'm going to remove this.
And now let's create this regressor.
It's going to take 3 or 4 lines as usual.
It's going to be very simple.
We're going to use a function which is the SVM function,
very simply because the SVR you know is a support vector machine algorithm.
But for regression, that's why we call it SVR.
And therefore we're just taking it from the SVM function.
And you will understand why perfectly.
So first let's import the required package because this function
is contained in a package which is the E10 71 package.
So let's go to our package is here and let's check if we have it.
So I have it because of course I used it before, but you might not have it.
So in case you don't have it, I'm going to type this line here
that you will need to execute to install this package.
So you type install that package is here.
And then in the parenthesis and in the quotes you type
the name of the package which is E10 71.
All right.
And then you just select this line and execute.
And this will install the package.
I'm not going to do it because mine is already installed.
And therefore I'm going to put that in comment.
Just press command plus shift plus C.
All right.
And now let's actually also add this line library.
And in parenthesis E10 71 not in quotes.
And this will select automatically the package here
E10 71 because this will not always be selected.
But by including that in your script you will be all fine.
This will always be selected. Okay.
And now let's start creating our SVR regressor.
So as usual we're going to start by defining our regressor
regressor and then equals.
And then as I mentioned before we're going to use the SVM function
which is actually this.
And then in parentheses.
And now let's press here
F1 to have a look at the arguments and see what we need to input.
So the first argument is formula.
So you start to know perfectly what it is.
Of course the formula is
our dependent variable
which is remember salary
and then tilde I just press alt n and then a dot here.
And the dot specifies that we are taking all the independent variable
of our data set.
We actually have
one independent variable which is the level independent variable.
So we could also type here level.
But most of the time we use the dot because of course
we have a lot more than one independent variable.
But as a reminder, I'm taking one independent variable here
so that we can clearly see the visual graphic results
of the different nonlinear models that we are building.
Okay. So now let's add the second argument.
So I'm adding a comma here.
And then next argument.
So the next argument is data okay
I guess you know what this data argument will be.
It's going to be of course our data set data set here
because we did not create any training set or test set.
You know before we used the training set.
Here is the data. But here we don't have any training set.
So of course we're going to take the whole data set
because we want to make very accurate predictions okay.
And now finally most important argument.
Well all the arguments are important.
But the most relevant for this section about SVR
is actually the next arguments we are about to input.
So this argument is actually not x or y.
These are optional arguments.
The most important argument I was just talking about is this one
the type, because this argument type will actually specify
if you're making an SVM model, which is used for classification,
or an SVR model which is used for regression.
So here, since we're building a non-linearity regression model,
we will choose the EPS regression type.
We could choose actually EPS regression or new regression.
But as you can see we want to take the most common one.
The EPS regression.
And if we were making a SVM model
for classification then we would have chosen C classification here.
As you can see, association is the default type for classification.
So in short if you want to do regression you choose type equals EPS regression.
And if you want to do classification then you choose type equals C classification.
And actually in the next part about classification we will make an SVM model.
And for this specific model we will choose the classification type
okay.
But here we are doing regression.
So we choose the EPS regression type.
So let's input it I'm going to type here type
equals eps regression.
All right.
And you need to put that in.