Hello and welcome to this art tutorial.
So for those of you who haven't checked the Python tutorials on kernel SVM,
I can't wait to show you the results.
It's going to be something you'll definitely see how the kernel
SVM classifier.
You can be a powerful classifier,
especially in our situation where the data set is not linearly separable.
Here you're going to see how it can manage to overcome this non-linear separability
and classify most of our users of the social network correctly.
So let's make this kernel SVM classifier
right now and quickly look at the results.
So as usual we're going to start by setting our working directory.
So right now I'm on my desktop.
I'm going to my machine learning A-Z folder part
three classification section kernel SVM.
And here we are.
Make sure that you have this social network add CSV file a new folder.
And if that's the case, you ready to click on this more button here
to set your folder as working directory.
Here it is all good.
And now let's start making our model.
So we made an awesome classification template
in the logistic regression section.
So we're going to use it.
So here we're going to take everything from here to the end.
Copy this and simply paste it in the kernel SVM.
Our file.
And now what we only need to do is to create our classifier here.
Because the template is made in such a way
to make your machine learning experience as efficient as possible.
So we're not going to create it now.
First we're going to, you know, select all the data pre-processing.
First step to preprocess the data.
So we're going to press Command and Control Plus and to execute.
And all good.
As you can see the code executed properly.
Now we can have a quick look at the data set the training set and the test set.
So we can see that we have 400 observations
in the data set, 300 that were selected to go to the training set.
And 100 selected to go to the test set.
That's because of our oh point 75 split ratio here.
And quick reminder, this dataset is about a social network
that contains information about users in a social network.
So we have their age.
The estimated salary, and the last column tells if yes or no.
The users bought a product of a business kind of this social network,
which is a car company.
So this car company put ads on the social network,
and the social network gathered those informations to see the users reaction.
And so zero means here that the user didn't buy the SUV.
And one here means that the user bought the SUV.
And our goal now is to make a classifier that classifies
those users into two categories.
The category of users that didn't buy the SUV, and the category of users
that bought the SUV.
So let's do this.
Let's do it with kernel SVM.
And so right now we need to create our classifier.
And as usual it's going to be very intuitive and simple.
We're going to use the best library for this.
And besides if you watched the SVM tutorials you're going
to see that we're using the same library and the same function.
We will just need to change some parameters.
So let's do this.
For those of you
who didn't follow the SVM tutorials, you need to install the package.
So to do this you type this command,
install the packages
and in parentheses and quotes E 1071.
So that's the most popular package for SVMs.
Another very popular package is kernel that you can play around and check it out.
It's actually quite simple.
It's kind of the same function, only with slightly different parameters to input.
But it's also a great package for SVMs.
But here we're going to use E 1071 which is one of the most popular packages.
And so that's for you guys who you know, if you go to your packages, this here.
And if you go to E 1071
you can see that, I have this package installed on my packages.
It might not be the case for you.
So that's why I'm adding this line here.
In case you don't have the package installed on your packages in R,
so I won't do it right now.
You just need to select this line and execute.
And it will install the package very quickly.
So I'm just going to put that in comment.
I just pressed command shift plus C and now we need to do.
Another important thing about this library is to you know type this common library.
And then in parentheses the name not in quotes of the library.
It 1071 okay.
And we need to add
this line is very important in case we have some automated scripts
that, you know, make some kernel SVM models today.
So imagine you have a workflow
and you want to include the kernel SVM model in this workflow.
Well you will need some automated scripts.
So it's important to add this line because this will automatically select
your library. Because as you can see here, it's not selected.
That means it's not imported in some way.
So you need this line that will automatically select this package.
Okay.
And now we are ready to create our classifier.
So it's going to be the same as for SVM
which is actually and SVM with a linear kernel.
Here we're not going to use a linear kernel.
We're going to use something else which will be the Gaussian kernel.
So let's do this.
We're going to call our classifier as usual classifier
and then equal.
And then here we're going to use the SVM function
of the E 1071 library.
And now we need to import the parameter.
So as usual let's have a look.
Here it is.
And now you need to click on this.
And here we are in the our documentation for SVM
1071.