Learn Before
Formula

Logistic Regression Cost Function

For mm labeled training examples, the logistic regression cost is the average binary cross-entropy loss: J(w,b)=1m∑i=1mL(y^(i),y(i))J(w,b)=\frac{1}{m}\sum_{i=1}^{m}L(\hat{y}^{(i)},y^{(i)}) J(w,b)=−1m∑i=1m[y(i)log⁡(y^(i))+(1−y(i))log⁡(1−y^(i))].J(w,b)=-\frac{1}{m}\sum_{i=1}^{m}\left[y^{(i)}\log(\hat{y}^{(i)})+(1-y^{(i)})\log(1-\hat{y}^{(i)})\right]. Thus, JJ aggregates the losses across the training set and is nonnegative. With y^(i)=σ(w⊤x(i)+b)\hat{y}^{(i)}=\sigma(w^{\top}x^{(i)}+b), this cost is convex in the parameters ww and bb.

Image 0

0

2

Updated 2026-09-19

Tags

Data Science