Logictic or Linear Regression? Are they same? Look alike? Haha it's not
Learn and Predict

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?

No alt text provided for this image
Formulas

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?

No alt text provided for this image
Output Boolean

Logistic regression is used in a variety of applications, including:

  • Predicting customer churn:?This is the process of predicting which customers are likely to stop using a product or service.
  • Fraud detection:?This is the process of identifying fraudulent transactions.
  • Medical diagnosis:?This is the process of predicting whether a patient has a disease.

The difference between logistic regression and linear regression

No alt text provided for this image
Difference

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

No alt text provided for this image


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:

  • p is the probability of the event happening
  • z is the linear combination of the independent variables
  • e is the exponential function

The logistic regression equation can be interpreted as follows:

  • The probability of the event happening is equal to 1 minus the probability of the event not happening.
  • The linear combination of the independent variables determines the probability of the event happening.
  • The higher the value of z, the higher the probability of the event happening.

How to fit a logistic regression model

No alt text provided for this image

There are two main methods for fitting a logistic regression model:

  • The maximum likelihood estimation method
  • The stepwise regression method

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

No alt text provided for this image

There are a number of metrics that can be used to evaluate a logistic regression model, including:

  • The accuracy score: This is the percentage of predictions that are correct.
  • The confusion matrix: This shows the number of true positives, false positives, true negatives, and false negatives.
  • The ROC curve: This shows the tradeoff between the true positive rate and the false positive rate.

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

No alt text provided for this image

Logistic regression has a number of limitations, including:

  • The curse of dimensionality: This is the problem that the number of parameters in a logistic regression model grows exponentially with the number of independent variables. This can make the model difficult to fit and interpret.
  • The overfitting problem: This is the problem that the model fits the training data too well and does not generalize well to new data.


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



要查看或添加评论,请登录

社区洞察

其他会员也浏览了