Skip to content
FacebookTwitterLinkedinYouTubeGitHubSubscribeEmailRSS
Close
Beyond Knowledge Innovation

Beyond Knowledge Innovation

Where Data Unveils Possibilities

  • Home
  • AI & ML Insights
  • Machine Learning
    • Supervised Learning
      • Introduction
      • Regression
      • Classification
    • Unsupervised Learning
      • Introduction
      • Clustering
      • Association
      • Dimensionality Reduction
    • Reinforcement Learning
    • Generative AI
  • Knowledge Base
    • Introduction To Python
    • Introduction To Data
    • Introduction to EDA
  • References
HomeImplementationSupervised LearningClassificationWhat is Logistic Regression?
Classification Knowledge Base

What is Logistic Regression?

March 10, 2024March 10, 2024CEO 192 views
Logistic Regression is a statistical method used for binary classification tasks, where the outcome variable is categorical and has two classes. Despite its name, it is used for classification rather than regression. The logistic regression algorithm models the probability that a given input belongs to a particular class.

The logistic regression model applies the logistic function (also known as the sigmoid function) to a linear combination of input features. The logistic function transforms any real-valued number into a value between 0 and 1. The equation for logistic regression can be expressed as follows:

\( P(Y=1) = \frac{1}{1 + e^{-(b_0 + b_1x_1 + b_2x_2 + … + b_nx_n)}} \)

Here:

  • ( \(P(Y=1)\) ) is the probability that the dependent variable ( Y ) belongs to class 1.
  • ( \(e\) ) is the base of the natural logarithm.
  • \(( b_0, b_1, b_2, …, b_n )\) are the coefficients.
  • \(( x_1, x_2, …, x_n )\) are the input features.

Logistic Regression uses a process called Maximum Likelihood Estimation (MLE) to find the optimal values for the coefficients that maximize the likelihood of observing the given data.

Once the model is trained, predictions can be made by comparing the predicted probabilities to a chosen threshold (often 0.5). If the predicted probability is above the threshold, the instance is classified as belonging to class 1; otherwise, it is classified as belonging to class 0.

Logistic Regression is widely used for binary classification problems, and it is a foundational algorithm in the field of machine learning. It is simple, interpretable, and can be a good choice for certain types of datasets. However, it assumes a linear relationship between the input features and the log-odds of the output, and it may not perform well on highly non-linear datasets.

What is ‘log odds’ in Logistic Regression?

To understand log odds, we should first understand odds ratios. In statistics, ‘odds’ is typically defined as the likelihood that an event will occur divided by the probability that it will not occur. In other terms, it is the proportion of successes (or wins) to losses (or failures).

\(Odds=\frac{P}{1-P}\)

Where P = Probability of the event occurring

For two events, A and B, the odds ratio is defined as the ratio of the odds of A in the presence of B and the odds of A in the absence of B, or equivalently (due to symmetry), the ratio of the odds of B in the presence of A and the odds of B in the absence of A.

\(Odds \space Ratio=\frac{Odds \space of \space A}{Odds \space of \space B}=\frac{\frac{P_A}{1-P_A}}{\frac{P_B}{1-P_B}}\)

The log odds are obtained by taking the logarithm of the odds ratio.

Log odds (also known as the logit function) are extremely important as they are the coefficients in logistic regression. This means that plugging the values into the logistic regression equation will provide the (natural) log-odds value for the given data.

What is the Sigmoid function?

The sigmoid is a mathematical function that takes any real number and maps it to a probability between 1 and 0.

The sigmoid function forms an S-shaped graph, which means as x approaches infinity, the probability becomes 1, and as x approaches negative infinity, the probability becomes 0.

The below figure shows what a sigmoid function looks like:

log odds, logistic regression, odds ratio, sigmoid

Post navigation

Previous Post
Previous post: NumPy function argmax
Next Post
Next post: Choosing the right estimator
  • Recent
  • Popular
  • Random
  • No image
    7 months ago Low-Rank Factorization
  • No image
    7 months ago Perturbation Test for a Regression Model
  • No image
    7 months ago Calibration Curve for Classification Models
  • No image
    March 15, 20240Single linkage hierarchical clustering
  • No image
    April 17, 20240XGBoost (eXtreme Gradient Boosting)
  • No image
    April 17, 20240Gradient Boosting
  • No image
    February 28, 2024Linear regression model coefficients
  • No image
    June 2, 2024Building a CNN model for Fashion MNIST…
  • No image
    January 16, 2024Improve model with hyperparameters
  • Implementation (55)
    • EDA (4)
    • Neural Networks (10)
    • Supervised Learning (26)
      • Classification (17)
      • Linear Regression (8)
    • Unsupervised Learning (11)
      • Clustering (8)
      • Dimensionality Reduction (3)
  • Knowledge Base (44)
    • Python (27)
    • Statistics (6)
May 2025
M T W T F S S
 1234
567891011
12131415161718
19202122232425
262728293031  
« Oct    

We are on

FacebookTwitterLinkedinYouTubeGitHubSubscribeEmailRSS

Subscribe

© 2025 Beyond Knowledge Innovation
FacebookTwitterLinkedinYouTubeGitHubSubscribeEmailRSS