So now that we have split the data into two parts and we are going to use green sea, did I say to bring
the model?
There is one important thing that you should note, as I told you earlier, that for now we are doing
classification and later on we'll be doing integration.
The function that we'll be using to run the Espey, a model will be seen for classification and regulation.
However, that function identifies whether it has to then diggnation or classification basis, the type
of the dependent variable that is the variable that we are predicting.
If that variable is categorical, then it will do classification.
And if that variable is numeric, it will do regression.
So if you look at my treinta dataset.
We go to the right.
This tartikoff skirt is a dependent variable.
The city variable that we want to predict.
But if I hover over the name of this variable, you can see that it has numeric values with range zero
to one.
If I use this variable as many Brenin variable, the SVM function will see that this is numeric and
it will run a regulation.
So it is important that we change this to a categorical variable which are identified as factors.
So we need to run this these two lines, which is converting the same numeric data into factors.
So if I run this command and go and look at the Trinity variable.
Daintily does it?
Now, if I scroll, the starting Oscar variable is no factor.
We live IDs do level dirty to anyone.
So this is no categorical variable.
Same thing we will do with test, see?
And both of these data sets.
Now has the starting Oscar variable as factor.
Now this variable can be used to do classification.
So let me want to SBM know to run SVM.
We need to use this package.
The package is called E one zero seven one.
Most probably you don't have this package installed.
You need to install these packages, as I showed you earlier, to install a package.
We need to write install lock packages and within the brackets and single code will write the name,
which is E one zero seven one.
So this package is downloaded and installed to make it active.
We will run the library command and the packages active also know we can use this package.
So the brain and SVM model, we use this SVM function.
This is Veum function as part of this even zero seven one library.
We will store the output of this as function into this as we unfit variable.
So SBM function takes all these parameters.
The first barometer is the formula.
And this we need to specify which is the dependent variable and which are the independent variables
which are to be used as predictive variables.
So this telecine, you can find this dealer saying.
On your keyboard, above the tab key.
This delay sign is used to separate dependent and independent variables.
Anything to the left of the delay is the dependent variable.
And all the independent variables that you want to use to predict this variable will be on the right
of daily.
So I want to predict Star Trek Oscar.
So that is on the left on.
Billy.
And I want to use all other variables from my dataset.
That is why I have put our daughter.
So to represent that, I want to use all the variables as predictive variables, I have water don't.
If I want to use only one variable, say, budget, I go to have written budget here.
If I wanted to use two variables, I could have written budget plus time taken.
So using plus symbols, I can add multiple independent variables here.
But since I want to use all the other variables and it does not make sense to write the name of 18 other
variables here by using plus symbols.
We have just bought our daughter here, which signifies that we want to use all of the valuables.
The second parameter is data, which is to be used.
The data did train see dataset.
Third parameter that we are giving is cardinal as we have Govardhan are two reclass.
The linear gomel SVM is the same as support vector classifier model longto.
So turning this come on will be same as running a support network classifier.
Also, this is a linear support with the machine.
So here we are using a good analogy called to linear parameter.
The fourth barometer is the cost barometer, as they discussed in the two re-elected, we use budget
or cost as I put parameters so that we control the rate of the margin and we allow some of the point
to be misclassified to this cost is equal to one is giving us the cost of misclassification.
The last perimeter that we are using is skill.
We have four skill is equal to two, which means that we will be scaling all the variables in our dataset
when we scale the variables.
We change in values so that they have a mean of zero and the standard deviation of one.
We do this because SVM is skill sensitive.
What this means is if you have a variable in your dataset which has a very large value, say it is in
millions and there is another variable in your dataset which is very small.
So it is of the range of point zero zero one two point zero one.
Now, when we use these two variables, since as we will be calculating distance, the variable which
has very high scale, will be given more importance.
Another issue that you will face in a scale since the model is, for example, if you have currency
in your dataset, if you have one dollar and the data set, it will be considered differently than if
that same value is in euros or in rupees or yangs and so on.
So we have to make this data scale indifferent.
To do that, we use scale is a goal to prove very few times the data does not need scaling in such a
scenario.
We can use scale is equal to faults also.
You can add few more parameters.
Also, if you click anywhere on dysfunction and press F1, you will see that the help for this function
opens up.
And in this function you can see all the argument that you can give.
So I've discussed the important ones deform large data, scale Connel, etc. This type argument will
be chosen by default.
So as I told you, depending on the type of are dependent variable, that is where there is.
It is numeric or factor.
That type is elected, whether it should be classification or regression.
So if you want to specifically give the tape, you can also specify that.
So all these are arguments available.
But I suggest that we use all these arguments.
You can check out the other arguments also.
These are the ones that you must know about.
So I'll run this.
Come on.
And you can see that as we in fact, variable is now created and as we unfold, contains the information
of the SVM model.
If you want to get a summary of the information in this model, you can run the summary command.
So somebody within brackets, we write the name of the model and.
You can see.
That we ran a classification type of model with a Carmeli near the Costa said one.
We have three and therefore support wetters out of the 398 observations in Deep Ringley desert.
So the margins that this model created within those margins, we have three hundred four point nine
out of these three hundred four point one, fifty four point are on one side and 150 points are on the
other side of the hyper plane number of classes to deliver that data in one.
So this is the summary of the information in this as a model.
So now that we have trained the model and the information is stored in as we in fact, we can check
its performance on the test to Geddie performance.
We will first use this model and the independent variables in the test dataset to get the predicted
value on those observations and data set.
Then we will compare these predictions.
What is the actual value in these tests?
It.
So this first line, which is why bread is equal to predict SBN fit Comac Bessie is storing the predicted
values in this whitebread variable.
The values that are predicted using this predict function first barometer to this function is the model
name.
And the second parameter is deep test set.
Here, you need not provide, which will be the dependent variable and which will be the independent
variable, because in the model we already know, which were the independent variables, it will automatically
take values of those independent variable from this day said.
And using those values of independent variables, it will predict the values.
Of dependent variable.
And it restored them into widespread value.
But.
Now, the actual value is in STC dataset.
Indeed.
Star Trek Oscar variable, the predicted values are in my bread variable.
To compare these predictions against the actual values, we use this table function.
And this table function on the rules.
We will get the predicted values and unbe columns.
We will get the actual values.
Creating this table is also called creating a confusion matrix.
Let me first rounders predict function to predict predictive values, and I will then on this day will
function and you can see that the predicted values are on the arrows.
So.
What these 45 cases, my model predicted that these 45 cases will not get an Oscar.
Out of the 45 cases, actually 32 did not get Oscar and 13 did get the Oscar.
And my model predicted that 63 movies will get Oscar out, of which 37 actually got the Oscar and 26
did not get the Oscar.
This matrix is also called confusion matrix.
This is used to compare the performance of classification models.
So here you can see that 69 nine of the cases were correctly predicted by our model and 39 guesses were
incorrectly predicted by the model.
So if you want to calculate the prediction accuracy of our model, you can simply write.
Sixty nine divided by one zero eight.
Since we correctly predicted four sixty nine cases and we have one zero eight observations.
Indeed.
Essid.
So if I run this command, it is telling us that we are getting an accuracy of nearly 64 percent.
So using this model with an accuracy of 64 percent, I can predict whether a particular movie is going
to get an Oscar or not.
This last line here, which is, as we inferred, dollar index.
This is used to check which of the observations are support vectors, since in this scenario we are
getting a lot of observations.
This may not make any sense, but if you have very few observations and out of which two or three support
vectors, you may want to find out which of the observations are support vectors.
Change your model completely depends on those few observations.
So a slight change in any of those observations can change your model.
So you may want to find out which observations are your support vectors to find out which observations
other support workers will on this command, SBM three dollar index.
And you can see here that first sixt well, 13.
All these are the index of observations, which are your support vectors in this video.
We have seen how to train the SBM model with a linear Cottonelle and we then.
So how do you use that train model to predict values on a test set or a new set?
And then we used those predicted values of dataset to find out deep prediction, accuracy of our model.
And lastly, we also saw how to find out which of these observations are the support vectors.
In the next video, we will see how to find out that value of this hybrid parameter.
This cost parameter.
We want to find out such a value of this cost parameter, which gives us maximum accuracy.
So we will learn how to tune this hyper parameter.