The open interval (0,1), interpreted as a probability.
Write the sigmoid formula.
σ(z)=1+e−z1.
What is σ(0)?
0.5.
What is the derivative σ′(z)?
σ(z)(1−σ(z)).
What quantity does logistic regression assume is linear in x?
The log-odds (logit), ln1−pp=w⊤x+b.
Why not use squared error for logistic regression?
It becomes non-convex and its gradient saturates when very wrong; cross-entropy is convex.
State the binary cross-entropy loss for one example.
−[ylnp+(1−y)ln(1−p)] with p=σ(z).
What is the gradient ∂J/∂wj?
m1∑i(pi−yi)xij — (pred−target)×input.
Where is the decision boundary?
Where w⊤x+b=0 (equivalently p=0.5); it is linear.
If log-odds =1.1, what are the odds and p?
Odds =e1.1≈3, so p=0.75.
Is logistic regression classification or regression?
Classification (name is historical).
Recall Feynman: explain to a 12-year-old
Imagine a machine that gives a "yes-ness score" — big positive means "definitely yes", big negative means "definitely no", zero means "no idea". But a score like 7 or −3 is confusing. So we pass it through a special squishy slide (the sigmoid) that turns any score into a number between 0 and 1 — like a percentage of confidence. Score of 0 → 50%. Big score → near 100%. We then teach the machine by nudging its dials whenever it's too confident and wrong, using the simple rule "how wrong you were × the input".
Dekho, linear regression toh ek number predict karta hai jo kuch bhi ho sakta hai — minus infinity se plus infinity tak. Par jab sawaal "haan ya na" ka ho (spam hai ya nahi, tumor malignant hai ya nahi), tab humein ek probability chahiye jo 0 aur 1 ke beech ho. Iske liye hum pehle ek linear score nikalte hain z=w⊤x+b, aur phir usko sigmoid function se dabaa dete hain: σ(z)=1/(1+e−z). Ye har score ko 0 aur 1 ke beech le aata hai, jise hum P(y=1) maante hain.
Sigmoid koi random function nahi hai. Agar tum log-odds (ln1−pp) ko linear maan lo, toh algebra se solve karne par automatically sigmoid nikal aata hai. Isliye ye natural choice hai. Boundary wahan hoti hai jahan z=0, matlab p=0.5 — aur ye boundary hamesha ek seedhi line/hyperplane hoti hai, isiliye ise "linear" model kehte hain.
Training ke liye squared error mat use karo — wo yahan non-convex ho jaata hai aur galat jagah gradient zero ho jaata hai. Iski jagah cross-entropy (log loss) use karte hain, jo maximum likelihood se aata hai aur convex hota hai. Sabse pyari baat: gradient ban jaata hai bilkul simple — (p−y)⋅x, yaani (prediction minus asli answer) guna input. Bilkul linear regression jaisa, bas prediction ki jagah sigmaid output.
Yaad rakhne ka trick: "Log-odds go linear, then squash." Aur sigmoid ka derivative? "s times one-minus-s" — σ(1−σ). Bas itna pakka kar lo toh logistic regression tumhaara dost ban jaayega.