Now, in the last lecture, we have centralized our data.
Now it's Spain, Ukraine over SBM classification MURDEN.
First, we need to import a swim from a Skillern.
And we will use as we see function of our SVM to create classification, Morton.
Now, if you remember for regulation, we were using, as we add, but for classification, we need
to use as we see the other steps are almost similar.
We first need to create our object, then we need to train it using the word extreme.
And why train data?
And then the next step is to predict the values of white and then whites using this trained object.
And then we will use some valuation parameter to check the performance of over more than.
Now, let's start with importing a swim.
Now, in this cell, we are first creating this object.
Our object variable name is VLF underscore as we m. underscore l here l stands for Linear.
This is a variable name.
You can give your own variable name as well.
Then we are creating this object, using as we see function and in as we see if you open the hell,
these are the parameters and these are their default values.
By default, the cardinal is radial.
So since we are creating our first model as linear model, we need to provide this parameter of cardinal
equal to linear.
Then if you remember, one of the most important parameter of SVM is the cost parameter, which has
been ordered by sea.
And here we are providing the value of C as zero point zero one.
So let's clear this object.
And let's also find out what extent is standard and why crane data?
Now, remember to use extreme standard data and pseudo fewer extreme to train this modern standardization
is very important.
Before graining, you're as a model.
Now, we have trained our model.
We have fitted our external inviting data in this object.
Now, let's predict the values of why using overtrained more than.
Predicting value is very easy.
You just have to use Dort Braddick method of field grain.
More than.
So I can write, see a live, underscore a swim underscoring this, the same object as this, then I
can use Daudt predict method so I can write Dort predict.
And then we have to just broyd the values of X.
If I am providing values of extreme, I will get wide trend data and if I am avoiding values of expressed,
I will get predicted values of White House data.
So here I am, saving my prepared values and two well-trained, underscored red and white test underscore
pride variable.
Let's run this to get the predicted values.
And if you want to look at the total values, you can just use any of these two variables.
You can see these are the predicted values of a work as dataset.
Now, next step is to evaluate the performance of over more than now in the regression we were using
Artist Square and MASC value.
And classification, we generally use accuracy, score and confusion metrics.
No accuracy is school is the percentage of observations that our model is predicting correctly.
The other metrics we want to look at is confusion, metrics.
Let's import these two functions from a skill and our metrics.
So Escalon has already provided us these two functions.
We do not have to manually compute the accuracy score and confident matrix using were created an actual
values.
We can just important the functions and let us draw confusion metrics on our test dataset.
The process is very simple.
You can just write confusion, metrics, function, and then if you look at the parameters first, you
have to provide the actual values of the way.
And then the TED values of Y.
Since we want convenient metrics of forward, tell certa we just need to provide Y test.
Since our Y test contains the actual value and then.
The second parameter is the accredited values of flight test, which we have calculated here.
Let's run this.
So this the confusion matrix here, rules represent the actual values and columns represent the predicted
values.
And these numbers are the number of observation.
They're not falling into that category.
So, for example, if I select this first girl.
First, a sense for number of actual zeros.
So there are 44 observations in this first straw.
That means in our dataset there are 44 actual zeros and there are 58 actual one.
Now, this column's it stands for the values.
So and then what predicted values?
There are total sixteen zeroes.
And there are total it be six ones.
You can also calculated using this table here, a VM put the data off over Vytas predicted variable.
So in this also, there are 16 zeros and it is six months.
So.
In short, this confusion matrix is telling me that for this eleven records, the actual value is also
zero and the predicted value is also zero.
Since this is in the first floor and the first column for this five records, the actual value is one,
but the total value is zero for this thirty three records, the actual value is zero since this is in
the first row.
But the credit card value is once and this is in the second column for this 53.
The actual value is also one and the total value is also one.
So we are correctly identifying this 53 record and this eleven records, and we are not able to accurately
predict these five records.
And this 33 records.
So what accuracy will be 53 less?
Eleven.
That is 64, divided by the total number of observations.
So you can compute it manually also, but you can also use this accuracy underscored escort function.
And here also you force her to provide the actual values and then the predicted values.
Let's find out.
Decorously.
The accuracy of the murder lists 62 percent, if you calculated from here also, you will get the same
result.
And one more thing about country and metrics, since the actual value of this 11 record is zero.
And we are also predicting it as zero.
We call them groo negative.
That is the Ted Lewis crew.
And actually, they are negative for this 53 records.
The actual value is one.
And the predicted value is also one.
Therefore, we call them crew positive.
That is the actual Ray Lewis one.
And we are also predicting it as one.
So they are group positives.
No, for a swim than you can also find out the number of support vectors you have in your unmodern.
So to find out the number of support vector, you need to use the attribute and underscore, support,
underscore.
So just write your more name.
And then write this attribute, dot and underscore support, underscore Vuuren, this.
So you will get two numbers.
The first number is number of support vector for your first class.
And the second number is the number of support vector for your second class.
Since we have two class zero and one.
So this is that number of support vector for the zero class.
And this is the number of support vector for one class.
So in total, we have 375 support vectors.
If you want to learn more, you can also have a look at this official documentation of Eskinder about
support vector classification here.
We will get details of all the parameters.
We have already discussed few of the important parameters, such as sea, kernell, etc..
And then you have attributes also.
So after you have grown your model, you can call on this attributes to get more information about your
more than.
We use this attribute to get the number of support vectors.
If you want to view your support directory, you can just straight.
You are more the name.
Support, underscore, vectors underscore.
And it will give you all the support vectors.
So you can have a look at this attributes and parameter to get more information about classification
models of SVM.
In the next lecture, we will use grid search to optimize this value of sea.