Logistic Regression is a statistical method used for binary classification, which means it helps predict one of two possible outcomes based on one or more input variables.


šŸ” Key Idea:

Instead of predicting a continuous value (like linear regression), logistic regression predicts the probability that a given input belongs to a certain class — usually labeled as 0 or 1.


🧠 How It Works:

  1. Linear Combination of inputs:

    Like linear regression, it starts by computing a weighted sum:

    z=w0+w1x1+w2x2+⋯+wnxnz = w_0 + w_1x_1 + w_2x_2 + \dots + w_nx_n

  2. Apply Sigmoid Function:

    The output z is passed through a sigmoid (logistic) function:

    σ(z)=11+eāˆ’z\sigma(z) = \frac{1}{1 + e^{-z}}

    This maps the result to a value between 0 and 1, representing the probability of class 1.

  3. Decision Rule:

    If σ(z)>0.5\sigma(z) > 0.5, predict class 1; otherwise, predict class 0.


šŸ“ˆ Example:

Suppose you're predicting whether an email is spam (1) or not spam (0), based on features like:

Logistic regression finds the weights for these features to best separate spam from not spam.


šŸ› ļø Use Cases: