What is Logistic Regression?
Logistic Regression is a mathematical model used in statistics to estimate (guess) the probability of an event occurring using some previous data. Logistic Regression works with binary data, where either the event happens (1) or the event does not happen (0).
Where zero is typically taken as “negative class” and one as “positive class”, however you’re absolved to assign any illustration to that.
We’re solely doing 2 categories for currently, known as a “Binary Classification downside.”
One technique is to use simple regression and map all predictions bigger than 0.5 as a one and every thing less than 0.5 as a 0. This technique does not work well as a result of classification isn’t really a linear performance.
Our new form uses the “Sigmoid Function,” also called the “Logistic Function”:
To perform g(z), shown here, maps any real to the (0, 1) interval, creating it helpful for reworking associate degree arbitrary-valued performance into a performance higher suited to classification. strive for fidgeting with interactive plot of sigmoid performance : (https://www.desmos.com/calculator/bgontvxotm).
hθ will give us the probability that our output is 1. For example, hθ(x) = 0.7 gives us the probability of 70% that our output is 1.
Cost Function:
We cannot use the same cost function that we use for linear regression because the Logistic Function will cause the output to be wavy, causing many local optima. In other words, it will not be a convex function.
Instead, our cost function for logistic regression looks like:
The more our hypothesis is off from y, the larger the cost function output. If our hypothesis is equal to y, then our cost is 0:
If our correct answer ‘y’ is 0, then the cost function will be 0 if our hypothesis function also outputs 0. or If our hypothesis approaches 1, then the cost function will approach infinity.
or If our correct answer ‘y’ is 1, then the cost function will be 0 if our hypothesis function outputs 1. If our hypothesis approaches 0, then the cost function will approach infinity.
We can compress our cost function’s two conditional cases into one case:
Cost(hθ(x), y) = -y log(hθ(x)) – (1-y) log(1 – hθ(x))
We can fully write out our entire cost function as follows:
Gradient Descent:
So we can represent our gradient descent as:
in this gradient descent, we need to update the values of theta by running it through the for-loop of the respective programming language. So after running it through the optimum values of theta are generated , so that the logistic regression model can work with maximum efficiency. After bringing up optimum values for theta we directly substitute our X(feautures) in the logistic function , so that we will be able to predict out our binary values for the given features.
Summary and Farewell:
In this blog, we have gone through the basic concept of Logistic Regression. I hope this blog was helpful and would have motivated you enough to get interested in the topic and has given some useful insight regarding Logistic Regression.
written by: Naveen Reddy
reviewed by: Krishna Heroor
If you are Interested In Machine Learning You Can Check Machine Learning Internship Program
Also Check Other Technical And Non Technical Internship Programs