So you have seen how to train a model with a linear kernel.
Now we are going to see how any model that polynomial connotes.
It is not necessity that every time we use polynomial or radial grinnell's, the model will perform
better.
It largely depends upon the type of data and the relationship are independent variable, have the D
dependent variable.
If the relationship is more linear, binomial and radial chronometer will perform worse than the linear
milimeter.
So it depends on the type of relationship that are independent and dependent variables have between
them.
However, when we are running a polynomial cannon.
If you remember from your tutee, there will be an additional hyper parameter which will be D.
D, that is the degree of the polynomial.
And as you know, you only hyper barometer's.
We can do a grid search.
That is, we can use multiple values of the hyper parameter, check the performance of the model over
different values of that degree and find out which value of this degree D gives us the best performance
on best set.
Now, if the best performance can be found only at a degree of one that is a linear relationship, then
that grid search will give us output of Beezy equal to one.
So we can always do a polynomial Carmel method and run a grid search and find out whether there is a
linear type of relationship or not, depending on the value of the degree of the polynomial.
So let's start first of all, we will run a simple SBM function in which we will specify the value of
two hyper parameters.
One is the cost.
And one is the degree.
So the function is same as we am.
I'll put out this function will be stored in this as we in fact be variable.
I have put the speed to signify that this belongs to polynomial cabman.
First parameterize the formula.
Second, this data, which is train C, only the kernel changes from linear to polynomial cost.
I have said to one degree I had to do so.
It will be a polynomial degree to which we are trying to fit and train the model.
So I'll run this command.
You can see that a similar SBM fixed variable is created like the one which we created for linear government.
And this contains the information of a SBM model of degree, too.
Now, you can use the information in this SBM, in this SBM fixed variable to predict the values on
dataset and then check out its performance using a confusion matrix.
You know how to do it.
I'm not doing it here to save pain.
But if you're curious, I think you should write on your own.
But here we are going to do hyper barometer tuning.
Last time we tuned only one parameter, which is cost, since linear function has only one hyper barometer.
But when we are using a cardinal, we just polynomial.
There will be two hyper parameters.
One is this cost.
One which I am creating a series having these five values zero point zero zero one zero one one one
five.
Then you can choose values of your own choice or degree.
I have chosen these five values, 2.5 line two to fight another parameter.
I have included in this, which I did not include earlier, is this cross is equal to full.
As I told you earlier, this tuning function uses cross-validation to find out the cross validate the
error.
And l just the best model which has least cross-validation error to perform cross-validation.
It splits today down to 10 parts.
By default, uses nine of the parts to train the model.
And the end part to find out the cross validation edit.
And it runs the model 10 times using nine of the sets as training set and one set as they tested each
day.
So basically, if we have a cross validation value of ten, it will run the model painting Martyn's.
We already have these five combinations of cost and five combinations or degrees.
So we are already done in this model five, five, 25, 25.
If I have cross-validation of N here, it will have to run the same model 250 times.
So I am reduced to cross-validation count here to four.
So that this command does not take as much time.
This basically means that the training set will be made into four parts, three parts will be used to
train the data and the fourth part will be used to find out the cross validation error.
So when you have limited computational power and you want to check out more values of cost and degree
and some other hybrid parameter to be done, you have an option of reducing this cross parameter, which
is the number of cross validation set.
So I'll run this command.
It is still running.
So the command has run and you can see that we have a new erasable called Tuned Out Out B for people
to make.
I mean, you can see that it took a lot of time if we had the cross value of them.
It would have taken even more pain, probably 2.5 times more pain than this commanded.
So now you don our B has information of all the different models that we created.
So let us find out which is the best model will store the information on best model in best more be.
So no best might be as the information of the best polynomial Maudy.
Let us look at this.
Somebody on this list might be.
So in this best model, we get that best model has a cost value of 10 degree of one.
This means that if you if you are using a cardinal, the best binomial is coming out of degree, one
which is same as linear polynomial.
So even a polynomial, Cardinal Nellis telling us that the best relationship between dependent and independent
variable is linear.
However, this is telling us that cost is equal to 10 is giving us the best cross-validation result
into saying that the number of support vectors is 310 out of three.
Ninety eight, 157 of them are on one side, 153 of them are on the other side.
And it ran a fourfold cross validation on the training data.
And these are the accuracy values.
So let us predict values of that.
Start to asking variable on the desert and compared the performance of this model against the linear
model that we created earlier.
So why would be USD predicted values from this polynomial based model?
And we'll create this table, which is also called the confusion matrix.
So in this confusion matrix, you can see that we predicted that for forty three cases the movie will
not get any longer.
These articles could out of them for 32 cases.
We are correct.
Also, for 65 cases, a model predicted that we will get started Oscar.
Whereas 49 of those cases we are.
And I did not prediction.
So overall, the prediction accuracy is 71, divided by one zero eight.
It comes out to 65 percent.
So a linear polynomial with a cost value of 10 is giving us a prediction.
Accuracy of 65 percent.
Last time when we created a table on linear model, we correctly predicted.
Sixty seven guesses.
This time we were correctly predicting 71 cases.
So this is how we train our model in Polynomial Kernell SVM.
We use the dual function to do only hyper barometer's.
We have to help out barometer's cost and degree.
We find out the best value of cost and degree.
Use that best model to predict the values on a test or a new set.
And if we have the actual values, we can compare the performance of our predictions against the actual
values using the stable function, which creates the confusion matrix telling us how many were correct
and how many were wrong.
In the next video, we will learn about Radil governance.