Skip to content

    Logistic Regression

    Machine Learning · Beginner

    Definition

    Logistic regression is a classification model that outputs a probability using the sigmoid function.

    It is a fast, interpretable baseline for yes/no problems like spam detection.

    Diagram

    inputs→ z→ σ(z)→ class 0/1

    Flowchart

    Weighted sum z = w·x + bApply sigmoid σ(z)Probability 0..1Threshold at 0.5Train with log loss

    Example: Sigmoid

    import math
    sig = lambda z: 1 / (1 + math.exp(-z))
    print(round(sig(2), 3))

    Output: 0.881

    Key points

    • Used for classification, not regression
    • Outputs calibrated probabilities
    • Extends to multiclass via softmax

    Interview questions

    Why not use MSE for classification?

    Log loss gives a convex objective and better gradients.

    More Machine Learning topics