All right, so there we go.
Let's go inside.
And here is the name of the module SVM, of course.
And the class that we must now import in order to build our SVM model.
All right. So let's start with this as usual.
Let's get you know this path and let's adapt it inside our code cell.
You know how to do this.
We need to start with from so from the scikit learn library.
And then the SVM module of the scikit learn library,
we will import the SVC class okay.
So that's the first step.
And then the next natural step you know it by heart.
It is of course to create an object of this class.
And we need to keep here the name classifier.
Because in order to not have anything to change afterwards, the classifier
which will be nothing else, then the SVM model itself.
And so to create such an object we need to call this class.
Well I can just type it as SVC and then add some parenthesis.
And now the question is what do we need to input here as parameters.
Well I hope you have the reflex to think.
Of course we need to input the kernel because as I've just explained, this
SVC class allows us to build kernel SVM models with either a linear kernel
which is the classic SVM model, or a nonlinear kernel.
So here in our parameters we'll have to specify that we want
a linear kernel because we're starting with the classic SVM model.
And then in the next section you know
on kernel SVM we'll choose a nonlinear kernel like RBF or polynomial.
We'll see.
But there you go. That's our first argument.
And indeed when we have a look at the documentation, we can see
that indeed the second parameter here is kernel.
And the default value is RBF.
So we'll have to specify that we want linear to start with.
And then as you can see you have many many other arguments you know parameters.
And you can check out the description for each of them.
But no worries we won't change their default value.
We'll just keep their default value.
Like for example, the regularization parameter
for which we'll keep the default value of one.
That's fine.
You'll see in the visualization that there is not much
we can do in order to improve the model, or to avoid overfitting.
So there we go.
The only parameter that we'll take is this one kernel equals not RBF but linear.
All right. So let's do this.
Kernel equals in quotes
linear.
All right.
And then I know I've just said that we won't have to input any other parameters.
But let's add anyway you know this one.
The random state parameter and set it equal to zero.
Just to make sure that we get the same result displayed on our notebook.
You know, because there are some random factors when we built this SVM model.
And therefore for teaching purposes, it's
better if we all have the same results displayed in our notebook.
All right.
And that's it. Congratulations.
That builds the SVM model, the classic one with a linear kernel.
And now you know how to finish this.
Of course, our last step here is to take our classify data,
from which we're going to call the fit method
to train our SVM classifier on the training set.
And we have to input that here in two parts.
First, the matrix of features of the training set, which is X train,
and then the dependent variable vector of the training set, which is why train.
All right. So you know this perfectly well.
Now it's like your native language right.
Okay I hope I'm right.
But there you go. Congratulations.
This implementation is now over.
Thanks to this very efficient code template.
And so now well we'll just run everything and observe the final results Indian.
All right.
So let's do this.
Let's not forget to you know import the data set here.
You know upload it in the notebook.
So click this folder here.
Then you will have to wait a few seconds because your notebook
will be connecting to a runtime to enable file browsing.
And in a second we should see there we go the upload button.
So we're going to click that.
And well you know that's the data set.
But I'll show you the whole path again.
So you find your machine learning
is that folder codes
and data sets which you could download in the previous tutorial in the article.
Then you're going to go to part three classification, then to section
16 support Vector Machine and Python and Social Network.
At dot csv you click open and this will upload the data set inside the notebook.
There we go.
And now now you can run all the cells by clicking runtime here.
And then are you ready. Run.
and this will run all the cell and perfect.
Now we have our SVM model with a linear kernel with all the default
values of the parameters here except this one linear kernel.
And so there we go.
Then we have the rest of the cells.
When we predict the new result. Indeed we get the right prediction.
Remember at zero for that particular first customer of the test
set of age 30 and estimated salary $87,000.
Indeed, it is predicted not to buy the SUV as it is the case in reality.
Okay, then when we predict the test results once again,
we see that we have many correct predictions, except some of them.
This one, this one.
And you know this one.
Okay, but it looks very good.
However, what we're mostly interested in and we're about to get it right now
is to see the accuracy on the test set, you know, the number
of correct predictions or if you want the number of incorrect predictions.
Are you ready? We're about to get it right now.
Write that code cell, print the confusion matrix and display the accuracy.
And wow okay interesting.
So it beat actually the logistic regression model right.
Remember the logistic regression model had an accuracy of 89%.
And here the SVM slightly beat it by 1%.
However it doesn't beat the turkey in and model
which remember had an accuracy of 93%.