In this video, we will learn how to split the available data into a test and train set.
Then we will use the training set to train our model and we will create the confusion matrix on the
test set to take the performance of our model to split the data and to test and train it.
I prefer to start this package called See It Tool.
If you have it installed, it'll be shown here.
You just have to take if it does not at all.
You know how to install a package.
You have to write installer packages and within double quotation marks you need to mention the name
of the package.
So first we need this packet.
See adults.
Next, we are going to set a seed.
The concept of setting a seed is that when we are splitting the data and to test and dream are, we'll
be doing it randomly.
But if I set the seed at a particular value and use the same seed at the same value, we both will get
these same split.
That is the observation in the training set, which I will get.
You will get the same observation in your training set.
So we will be setting the scene at zero to rate, said NCD.
We didn't record the right to the lenders.
So the seat is now set at zero.
So now we create a bit evil called split, which will help 80 percent of the value this group and 20
percent value just falls to create that.
We will.
Right.
Split is equal to sample or split.
Aaron, d'accord.
The first parameter will be our data, which is D.F..
And the second parameter is split ratio, which will say 2.8.
This means that 80 percent of the data will be training set and 20 percent will be tested.
So we'll run this combined.
You can see that there is a variable called split.
And it has values like falls through approvals and so on.
So the training set will be the subset of.
The FBI does it, which has split values through.
So will the training set
is equal to subject.
The data is D.F. and displayed value is split equal to equal to two.
Single.
Equal to is an assignment operator level equal to is used to compare values.
So split values should be true.
You can see that our training set has 386 observations, which is nearly 80 percent, not exactly 80
percent of the observations, but merely Deverson.
And for the tests, it will use the split value to be false.
So test set is equal to subsect.
The idea of split is what?
You can see on the right.
We have train set with 386 observations and test set with the remaining 120 observations.
Now our job is done.
We have to repeat the same things which we did on the complete dataset.
So we will train the model using train set.
And we create the confusion matrix using dataset.
So I'll show you how to train the logistic regression model with the training set and create the confusion
matrix using your test.
You'll have to trendy linear discriminant analysis on the training set and created confusion metrics
on the test set on your own.
You probably know how to do logistic regression.
We will create a new variable called Trained Outfit
is equal to Jelen GLAAD function, which is used for doing logistic regression
dependent variable.
The.
We are using all the variables or dart data is trained said.
And family is by no means.
Let us run this.
So now we have another very well trained outfit which contains the information of the logistic regression
model.
Now to find the predicted probabilities for the desert, we will use the predict function.
We will write test, not probes.
This is the variable name is equal to predict.
The first batter, my dad is the model which is trained outweight.
Second parameter is the data on which we want to predict.
It is Essid.
Just go check it out.
But I'm Dave Davies, equal to response.
That is it on this.
So we have performed training on one side and based on a completely different set.
We have these probabilities of the desert.
If we want to assign classes using a default boundary condition of point five, we will first create
an array which will have all the values as no.
And we will change those elements which have probably value greater than point five to.
Yes.
So first we recreate the array will create test.
Fred.
Does it do predictions?
So they start praying.
Is he going to wrap with tanks?
What?
Repeat, repeat?
No.
No one doing detainees since Desert has 120 observations, the you have today, which has noted no one
doing detainees will run this.
Now, for all those elements were probably easier than point three within two years.
So let's start Red
Square bracket.
All right.
This dark, Rob.
This great event point for you.
Is equal to.
Yes.
Grandis.
So now, wherever probability is more than point five.
We have the yes.
Now we have the predicted probabilities.
What the said you have the actual values in this sword.
Very well indeed.
They said we can compare these by creating a confusion matrix to create a confusion matrix.
We will use these people function so well.
Right.
Table
distorted comma the sorry variable of detested or tested dollar.
No less sordid.
Let's run this.
So you can see now we have seven to eight correct predictions out of total 120.
So 78 by one doing D.
D prediction accuracy, which is lower than the training set.
But still, it can be considered a good classifier.
Now, you have to create this confusion matrix on the test set using linear discriminant analysis and
compare the performance of LDA against logistic regression in the coming videos.
We'll be learning about get nearest neighbors.
And then we will be predicting the desert values using the Game Limited.