Now let's learn how to create a logistic regression model in Python.
So in Python, there are two ways to create logistic regression model.
First, using Escalon libraries.
And second method is using state smarter library.
There are a lot of documentation and implementation techniques available for a skill.
That's why it is more preferred by professionals.
Whereas a site model is the new library.
And there are hardly any documentation and there are some bugs as well.
But search model provides all the statistical information that is needed from all logistic regression
model.
So we will create this model using both of these two libraries.
But before that, we need to create our X and Y variables.
This time, we are only selecting one independent variable.
That is price and our vye dependent variable is the Soviet variable.
So first.
We will clear our equitable will, right x equity to be if.
And then to square record, we will right price in Eskil on your ex or independent variable should be
a two dimensional.
That's why we are using two squared records.
And the word via variable is sold.
So we'll write like way to.
Sorry and single this quarter.
We will rate soared.
Now, let's.
Check the sample of these two data frames, right, x dopehead.
We have only one variable, which is players in the league, we will check, assemble or fly.
So first, we will create our model using a scale, then we have to import logistic regression from
a Skillern.
So we will write from Escalon totally Nantel Mardon.
In both logistic regression.
You don't have to remember all this Gord's.
You can visit Eskil Skillern documentation or you can copy this skorts from this notebook, which is
a test in the resource section of this video.
For Escalon, we followed three steps.
First, we create our classification object.
Then we find that object using our X and Y variable.
And the third step is to predict our Y variable.
Using that drained classification model.
So first we will create our object.
CLV underscore a lattice CLV is for classification and allow this sense for logistic regression.
And we are using logistic regression with single variable.
That's why we are putting in this word.
C11 underscore a is a variable name.
And we won this object to take logistic regression.
Now we will fit our X and Y with even Buffett.
We just have the right outfit, so we'll write CLV, underscore LARUS, not fit, and then record will
first mention our dependent variable, which is X and then our dependent variable, which is why.
We'll run this, we have grain, though, what a model to check the coefficient and intercept of a model
that is B does little and B Devon.
I hope you remember we does it when we govern from a word to reflect reelected.
We'll see value of B does it when we do when we can.
Right.
CLV underscore Allardice.
Not if underscore or if it stands for coefficient, and this is the attribute of over modern.
We on this, we are getting this value.
This is a value of between to see the value of B to zero, relates VLF.
On that score, a lot is not intercept underscore.
Again, this school, if and intercepts are the attributes of forward logistic regression model.
There's the value of zero.
So using this bit does it when we touch one, you can create a logistic equation that we discuss in
our theory lecture and you can use this.
What does it when we don't need to predict the value of Y from here when news of X?
This is the first method.
Of creating logistic regression model.
Now let's move on to the second method, which is using a service model to create logistic regression.
Now, one drawback of using a set model is that by default, set model do not use a consent form, which
means that you are does zero will be zero by default.
So to add concern, Tom, and do a lot more than we first need to do, concern them in a word, dependent
variables.
To do that, we will first import, said Smardon Lord Apia.
As Esson.
We'll run it.
No, we'll create another door frame for our dependent variable, which is X under Scott Korsnes.
This.
Contain one single, call them as a constant.
All right.
Xander Scott wants equally to ascendent at constant.
Again, you don't have to.
Remember all this codes, you can copy this code and follow this code for your future projects.
Let's again, we will see a sample of four X concent will right x kohn's da tagged.
You can see there is one consent I did in two or X.
Now to import the logistic regression classifier from a Setswana right?
Import.
Then sets modern, discreet, not discreet, modern.
And we will import this as s.m.
We'll run this.
Now we need to screen our X and Y evitable and do a model, so we'll write logic lodged as our variable
name.
s.M, not logic.
Here first, we need to mention our white variable.
We will write why and then our X is X underscore Korsnes.
Remember, we are adding a constant thumb and door X variable.
And then we need to fit.
Fit on this auto model, is that Audi?
To see the somebody off a little more than.
We'll wait logic, but somebody.
Here you can see all the information about the logistic regression model.
We are only getting this using a search model.
We were not getting this using a Skillern.
Here you can see at the bottom, we have Budos forces for consent.
And second one is for Kreiss.
Then in the first column, we go, if this are the coefficient, the coefficient of consent is also
known as does zero and this the coefficient of price will be a lot to be done.
We have a standard at our values corresponding to this coefficient.
And then we have the Z value for this confusion.
In the fourth column, we have the P-value.
We will discuss about the standard error ZEWAIL You and the P-value.
And our next theory lecture.
On the top of this fable, you can see or deliver dependent variable.
What is the model?
And my third, remember, my third is maximum likelihood estimate that that's what it is.
M.
L.
E.
Then we have no observations.
The residuals and other details of a logistic regression model.
So remember, we are getting this information online.
It start Smardon.
And start small, we can see all this information about our model.
But professionals use a Skillern for most of their work because of the high quality of documentation
and the additional features that are present in Escalon.