Write a solution for <a name="2.4"></a> 2.4 Cost function for logistic regression In…
- User
Write a solution for
2.4 Cost function for logistic regression
In this section, you will implement the cost function for logistic regression.
Exercise 2
Please complete the
compute_costfunction using the equations below.Recall that for logistic regression, the cost function is of the form
J(\mathbf{w},b) = \frac{1}{m}\sum_{i=0}^{m-1} \left[ loss(f_{\mathbf{w},b}(\mathbf{x}^{(i)}), y^{(i)}) \right] \tag{1}
where
-
m is the number of training examples in the dataset
-
is the cost for a single data point, which is -
-
- Assistant
To implement the cost function for logistic regression as described, you can follow the steps below. We'll create the function which takes in the parameters , , , and to compute the cost.