Notes on logistic regression
Notes on logistic regression
The Logistic Regression is classified under classification algorithms. For classification we need answer
in terms of yes or no i.e. 1 or 0. For example, whether a tumor is benign or malign.
We cannot use linear regression here as it is not suitable for this problem so we use a special function
called the Sigmoid function or the Logistic function.
⃗⃗ ,𝑏 (𝑥 ) = 𝑧 = 𝑤
𝑓𝑤 ⃗⃗ • 𝑥 + 𝑏
1
𝑔(𝑧) =
1 + 𝑒 −𝑧
1
⟹ 𝑔(𝑤
⃗⃗ • 𝑥 + 𝑏) = ⃗⃗ •𝑥+𝑏)
1+ 𝑒 −(𝑤
This can be interpreted as the probability that y = 1 or the output is equal to 1.
(𝑖) (𝑖)
As 𝑓𝑤
⃗⃗ ,𝑏 (𝑥 ) → 1 𝑡ℎ𝑒𝑛 𝑙𝑜𝑠𝑠 → 0 and as 𝑓𝑤
⃗⃗ ,𝑏 (𝑥 ) → 0 𝑡ℎ𝑒𝑛 𝑙𝑜𝑠𝑠 → ∞
(𝑖) (𝑖)
Loss is lowest when 𝑓𝑤
⃗⃗ ,𝑏 (𝑥 ) predicts close to true label 𝑦 .
(𝑖) (𝑖)
As 𝑓𝑤
⃗⃗ ,𝑏 (𝑥 ) → 0 𝑡ℎ𝑒𝑛 𝑙𝑜𝑠𝑠 → 0 and as 𝑓𝑤
⃗⃗ ,𝑏 (𝑥 ) → 1 𝑡ℎ𝑒𝑛 𝑙𝑜𝑠𝑠 → ∞
(𝑖) (𝑖)
The further prediction 𝑓𝑤
⃗⃗ ,𝑏 (𝑥 ) is from target 𝑦 , the higher the loss.
If 𝑦 (𝑖) = 0 :
(𝑖) (𝑖)
⃗⃗ ,𝑏 (𝑥 , 𝑦 )) = − log(1 − 𝑓(𝑥 ))
𝐿 (𝑓𝑤