Logictic or Linear Regression? Are they same? Look alike? Haha it's not
Before going through the concept I was really ?? about is there any difference between these two learning methods. I tried my best to gather information for these two topics and yes there's a huge difference between these.
Logictic regression is all about, if you smoke, drink and drive will you die in a road accident in night. Haha yes it predicts yes and no only that's why called classification algorithm and comes under supervised machine learning.
I wish by gingn your 10 minutes you will also find the difference between these two and where you have to use these 2 algorithms. Thanks for learning with me.
If you know already, then here you go to look at the code implementation of logistics regression with other models as well.
What is logistic regression?
Logistic regression is a statistical model that is used to predict the probability of a categorical outcome. The outcome can be binary, such as whether a customer will default on a loan (yes or no), or it can be multiclass, such as whether a tumor is malignant (yes or no) or benign (yes or no).
Logistic regression works by finding the relationship between the independent variables (the features) and the dependent variable (the outcome). The independent variables can be continuous or categorical. For example, in a loan default prediction problem, the independent variables might include the customer's credit score, income, and debt-to-income ratio.
The logistic regression model is a linear model, but the dependent variable is transformed using a sigmoid function. The sigmoid function is a non-linear function that takes a real number as input and outputs a number between 0 and 1. This means that the logistic regression model can predict probabilities.
When is logistic regression used?
Logistic regression is used in a variety of applications, including:
The difference between logistic regression and linear regression
Logistic regression and linear regression are both regression models, but they differ in the type of outcome that they are used to predict. Linear regression is used to predict continuous outcomes, such as the price of a house or the weight of a person. Logistic regression is used to predict categorical outcomes, such as whether a customer will default on a loan or whether a tumor is malignant.
Another difference between logistic regression and linear regression is the way that they are fit to the data. Linear regression uses the least squares method to minimize the sum of the squared errors between the predicted values and the actual values. Logistic regression uses the maximum likelihood estimation method to maximize the probability of the observed data.
The theory of logistic regression
The theory of logistic regression is based on the sigmoid function. The sigmoid function is a non-linear function that takes a real number as input and outputs a number between 0 and 1. The logistic regression equation is:
p = 1 / (1 + e^(-z))
where:
领英推荐
The logistic regression equation can be interpreted as follows:
How to fit a logistic regression model
There are two main methods for fitting a logistic regression model:
The maximum likelihood estimation method is the most common method for fitting a logistic regression model. This method finds the parameters of the model that maximize the likelihood of the observed data.
The stepwise regression method is a heuristic method that fits the model by adding or removing independent variables one at a time. This method is less efficient than the maximum likelihood estimation method, but it can be easier to use.
How to evaluate a logistic regression model
There are a number of metrics that can be used to evaluate a logistic regression model, including:
The accuracy score is a simple metric that is easy to understand. However, it can be misleading if the classes are imbalanced. The confusion matrix provides more detailed information about the model's performance. The ROC curve is a more comprehensive metric that can be used to compare different models.
The limitations of logistic regression
Logistic regression has a number of limitations, including:
Too much of theory and its every where, is it really that easy to implement if that is going in your head after coming till here , Then I bet you yes it is.
logistic_regression.ipynb with dataset Social_Network_Ads.csv