When creating a post, please add:
- Week 3 must be added in the tags option of the post.
- Link to the classroom item you are referring to: Coursera | Online Courses & Credentials From Top Educators. Join for Free | Coursera
- Description :
For Binary classification Loss function for Logistic Regression can be defined as : - loss(f_{\mathbf{w},b}(\mathbf{x}^{(i)}), y^{(i)}) is the cost for a single data point, which is:
loss(f_{\mathbf{w},b}(\mathbf{x}^{(i)}), y^{(i)}) =
- log(f_{\mathbf{w},b}( \mathbf{x}^{(i)} )) & {if y^{(i)}=1}
- log ( 1 - f_{\mathbf{w},b}( \mathbf{x}^{(i)} ) ) & {if y^{(i)}=0}
-
f_{\mathbf{w},b}(\mathbf{x}^{(i)}) is the model’s prediction, while y^{(i)} is the target value.
-
f_{\mathbf{w},b}(\mathbf{x}^{(i)}) = g(\mathbf{w} \cdot\mathbf{x}^{(i)}+b) where function g is the sigmoid function.
The loss function above can be rewritten to be easier to implement.
loss(f_{\mathbf{w},b}(\mathbf{x}^{(i)}), y^{(i)}) = (-y^{(i)} log(f_{\mathbf{w},b}( \mathbf{x}^{(i)} ) ) - ( 1 - y^{(i)}) log ( 1 - f_{\mathbf{w},b}( \mathbf{x}^{(i)} ) )
This is a rather formidable-looking equation. It is less daunting when you consider y^{(i)} can have only two values, 0 and 1. One can then consider the equation in two pieces:
when y^{(i)} = 0, the left-hand term is eliminated:
and when y^{(i)} = 1, the right-hand term is eliminated:
My question here how to implement or calculate Loss function and cost function for Multiclass classification using Logistic Regression. Please help me here in the same thread.