Let's understand the mathematics behind regression in this session, we will use an example to get started.
The example I'm considering.
He is.
A student studies for a certain number of hours and he gets different kinds of marks.
Are trying to establish a correlation between the number of hours to read and the mark something.
OK, I'm going to use Excel to create the scatterplot.
OK, this can be created using Python or are as well, OK, or any programming language for that matter.
If you see this view, Scatterplot Scatterplot is using regression and it shows the extent of relationship
between X and Y.
What is the dependent variable, an independent variable in this case.
My obtained is the dependent variable, a member of our study is the independent variable because Mathabane
is dependent on the member of our study.
Right.
A number of our study is not dependent on anything.
OK, maybe it's dependent on something about which we are not concerned for now.
OK, we are interested in establishing the relationship between number of us to the max.
OK, so how will you go about creating this in Excel?
So you facilitate the data points and you come to insert and then click the option here.
OK, and then you will click this scatterplot, OK, and you will have a graph like this.
Right.
So that is the starting point for you on here.
The relationship between the two is linear.
OK, it is not logarithmic or anything else.
So what is logarithmic?
We are going to see that shortly.
That means when I say that the relationship is linear, it means I can show this relationship in the
form of a straight line.
Right.
So that is known as a linear relationship.
OK, I can show the relationship between my dependent variable and independent variable in the form
of a straight line.
And what what is the straight line that I'm talking about?
I am going to fit a line that will cover all these data points.
In fact, that line is known as goodness of fit.
Right, so let's create the goodness of it, how will I do it?
I first to select these data points, just click one of the data points and right.
Click you can see these options will be there.
Click at Trend Line.
Unusual how this straight line came up and you also choose display equation on chart.
OK, you can also choose display R-squared, the number we covered the square in the previous session.
So I display the equation.
So this equation shows the relationship between dependent variable and independent variable.
If you recollect your mathematics, there's this equation looks like a explicit Y equals M explicit.
That means number of marks of pain equals ten point eight six to into number of our studied plus forty
one point nine zero one.
Right, if, let's say a student comes in on, that particular student comes and tells that he has studied
for one point to us all, I can all I need to do is I need to put one point to fight here.
That is ten point eight, six two and one point two five plus forty one point nine zero one will give
marks the student will get when he or she studies for one point to fires nine.
So I have not only established the fact I can also predict the future.
Right.
Are you getting it?
So what is this Y equals M explosive.
M is known as gradient and C is known as the intercept.
This intercept corresponds to the value where the line means the y axis and slope is nothing but this
distance divided by this distance.
It is also known as Delta White, divided by Delta X..
In this case, this distance is four and this distance is to four.
Divided by two is to.
I can also draw a smaller triangle and the same height divided by base that will give the same value
of M.
OK, I can draw a smaller triangle or a slightly bigger triangle also.
OK, whatever.
You draw a triangle on this line and when you compute the height divided by base, the value of him
that you get will be the same, right.
Are you understanding linear regression?
OK, members of our study done massively OK in this case.
The line meets the y axis at minus four, so interceptors minus four and gradients, see, I've drawn
a smaller triangle.
I didn't draw a bigger triangle like this.
And the same height divided by base two, divided by one will you might slope or gradient.
And they can have more than one variable also, like in the example that I just share, a member of
Australia's one independent variable.
And in the case of multiple linear regression, you will have more than one independent variable.
Please note that dependent variable will always be onely one, right?
So here I am looking at two variables, right in the case of multiple linear regression.
I'm trying to predict what will be the quantum of carbon dioxide emission in a vehicle.
And I am predicting that using two independent variables, volume of the vehicle and weight of the vehicle.
Right.
So there is a case of multiple linear regression.
Right.
I don't have just one factor, but I am more than one factor, and yet also the relationship is linear.
That means I can express this in the form of a straight line.
Right now, let's see logistic regression.
OK, let's understand that with an example.
Here we are trying to predict the malignancy of a tumor, what is malignancy that means whether the
tumor is really cancerous or not, malignancy means cancer.
I am trying to predict malignancy based on tumor size.
I have plotted instances of Dumarsais on the malignancy here and I have represented in the form of a
graph.
If I tried to fit a linear relationship in this, which is a straight line, I cannot fit all the points
right.
As you can see here, if I tried to fit a straight line like this, even if I move that line a bit to
the left, these points will be left on.
Right.
So my foot is not good at all, a straight line cannot cover all the data points.
If you reconnect the linear regression, the straight line word, almost all the data points, that
means the food is good here.
The food is so bad that you cannot have a linear regression.
You need what is known as logistic regression, because when it is in the form of a column like this,
it covers all the data points.
Right now, do you understand who you are?
Because I have a cover, it covers all the data points, almost all the data points, OK?
And in the case of a linear model, I have what is known as Y equals M explicit or B not plus B on X,
B one is the slope and B not is the intercept.
In the case of logistic regression, we use what is known as sigmoid function, OK, which is nothing
but one plus E to the power of minus B, not plus B 1x.
This E to the power of minus is basically a way of writing logarithmic value.
Right.
And the output is in the case of linear regression, the output is the numeric value.
In the case of a logistic regression or a logic model, the output is a probability.
Right.
That is whether the tumor is cancerous or not, it will have a value between zero and one.
Are you understanding the difference between a linear relationship and a.
Logistic relationship.
OK, let's see an example where we compare linear and logistic using similar or same independent variables.
OK, let's take the carbon dioxide emission.
I'm using these to X1 next to vehicle volume and vehicle weight.
That's my independent variables.
I'm trying to predict the quantum of carbon dioxide emission.
I use multiple linear regression if I predict what is the likelihood of carbon dioxide emission coming
from that vehicle, I use logistic regression.
Please note here, I'm using the word likelihood.
That means it is a probability, which means it can have a value between zero and one.
Are you getting it?
In logistic regression, one more aspect is because the dependent variable had as a value between zero
and one, your X1 x2 should also have a value between zero and one.
But you see here, the values here are not between zero and one.
Right.
They are numeric values.
So I need to convert the numeric into.
Logarithmic value, and then I will apply logistic regression.
How you understanding is this clearly?