Why is log(cost) plotted here? Isn't log(cost) = log(-log(prediction of sigmoid function))?)?)

Hello @Arisha_Prasain,

It is true that the logistic cost consists of log, and the log in log(cost) is an extra one. A plot having this extra log is called a log-plot. Furthermore, when we make a 2D log(x)-log(y) plot, we call it a log-log plot. The reason we log an axis is to show the detail of a curve across a wide range of order of magnitudes. For example, in the right plot, the cost spans from 10^-5 to 10^3 so that we are able to see clearly a valley that can’t be seen in the left one.

The cost has its own log for the purpose of calculating the logistic cost. Having an extra log is for visualization. They serve different purposes.



Thank you for answering. One more follow -up question, how did you know that the cost spans from 10-5 to 10^3? In the graph, there’s no mention of exponentiation of the base 10?

Hello @Arisha_Prasain, base 10 is the usual choice, and I think assuming that is sufficient for explaining the idea behind. The choice of base shouldn’t be the focus, and you may use base e or base 2 if you see it fit. The advantage of base 10 is definitely that you can convert it back without a calculator.

If you think it is important to verify that, you may check out the implementation of the function that plots it. The implementation should be in one of the .py files coming with the lab notebook.


1 Like