In this lecture, we will learn how to split our dataset into two parts test and train data set.
Then we will train our logistic regression model on training dataset and we will evaluate the performance
of that model using the test dataset.
I have already written all of the codes, my data going new to write all of these quotes on your own
while you are practicing.
First, to split our data into test and.
We need this function green test split and you can import this function from Escalon, not model selection.
The output of this function is in the form of four variables.
First variable should be your independent green data.
Second variable should be you're independent based data and then you are dependent on data and dependent
test data that are for argument for this function.
The first one should be the independent variables from your or is no other doorframe.
We have already created X variable.
Therefore, we are using X.
The second argument here is the dependent variable.
We have already created Y.
That's why we are using Y.
Then the next argument is further test size.
So as we discuss in our two Reflektor ideal split for this strain, is it being 20 percent or two percent
for Crean and 20 percent for test?
And here you can mention the portion of your whole dataset you want in your test data.
Since we won 20 percent of test data, therefore we will read zero point two.
If you want to do percent of tests today, you can read zero point three and sort of zero point to the
next argument is for random assert.
Here you can provide any value.
But if you grow eight zero, you will get the same desert as I'm getting from this randomly split.
If you write one or any other value, this function will work exactly the same.
But the only difference will be that you will not get the exact same result as me because you are random
numbers will be different from my random numbers.
So if you want to get the same split every time, you'll have to stick to only one random state.
No, I'm using zero.
And for all future test this state, I will use zero
not initially in our X and Y variable.
There were five hundred and six rows.
Now let's look at the shape of extreme expressed by train and by test.
If you are using updated version of Biton, you need to put parenthesis with the print.
Come on.
I feed on this, you can see that 80 percent of data is an extreme.
And the remaining 20 percent is in its best 404 observation are an hour extended to and under.
And two observations are in order.
Experts data.
Now, let's fit a logistic regression model on our training dataset.
We'll follow the same step.
First, we will create the object.
Seacliff underscore a lot and then we will fit our extreme and white dream in this object.
We have fitted our model.
Now let's predict the value on what X test does say.
You can notice here I am using expressed and sort of extreme because I want to credit the values on
my test data set.
Now let's look at the accuracy and the confusion metrics of this model to get the accuracy score and
confusion metrics.
We will import these, too, from Escalon metrics.
We will run it, then will clear the confusion metrics for our via test and why test predict.
These are the actual values of our white test.
And these are the predicted value of a lot of test.
Here are what rules represent.
The actual class and the column represent the predicted class.
So for the statistics, no, we are seeing that the actual value was not sold.
And the predicted value was also not sold for this 36 records.
If you remember, these are known as crude negatives.
Similarly here, our actual value is one.
But the predicted value is zero.
These are known as false negatives.
And for this 22, the actual value was zero and the predicted value was one.
These are known as false positives.
So when the ladies are positive.
Now, the accuracy score is the percentage of observations.
My model is able to predict correctly, so the accuracy score will be the sum of 36 plus 31 divided
by the total number of observations.
You can do that manually also, but there is a small function to calculate it phonetically.
The accuracy of forward model on our test dataset is zero point six five.
It's not great, but it is good enough.
And it is always coming day to use your test data set to create the confusion metrics and to calculate
the accuracy score.
Now I have calculated this accuracy score and confusion metrics for logistic regression for a.
You can grade on your own and you can also compare the accuracy score between the two models and the
next video.
We will learn how to create game and model and Biton.