# Programming Machine Learning: Incorrect formula

**URL:** <https://forum.devtalk.com/t/programming-machine-learning-incorrect-formula/3716>\
**Category:** PragProg Customers\
**Tags:** book-programming-machine-learning, errata\
**Created:** [3 November 2020 09:31 UTC](https://forum.devtalk.com/t/programming-machine-learning-incorrect-formula/3716 "2020-11-03T09:31:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexandr](https://forum.devtalk.com/letter_avatar_proxy/v4/letter/a/71c47a/32.png) [@Alexandr](https://forum.devtalk.com/u/Alexandr)\
**Post date:** [3 November 2020 09:31 UTC](https://forum.devtalk.com/t/programming-machine-learning-incorrect-formula/3716/1 "2020-11-03T09:31:54Z")

</div>

Hi everyone!  
There is an error on the page 71 in the book “Programming machine learning from coding to depp learning” P. Perrotta. You can’t just change the weighted sum to a sigmoid without first taking the derivative of the sigmoid. See the explanation there [https://yadi.sk/i/T75bWimUYPAe7Q](https://yadi.sk/i/T75bWimUYPAe7Q)

Best regards.

---

<div class="post-metadata">

**Author:** ![nusco](https://forum.devtalk.com/user_avatar/forum.devtalk.com/nusco/32/5449_2.png) [@nusco](https://forum.devtalk.com/u/nusco)\
**Post date:** [3 November 2020 10:51 UTC](https://forum.devtalk.com/t/programming-machine-learning-incorrect-formula/3716/2 "2020-11-03T10:51:03Z")

</div>

Hey, Alexandr! Thank you for taking the time to report this, and even take a picture of your notes!

I kinda regret not putting that calculation in the book, because from the explanation I wrote, it looks like the derivative of the sigmoid just disappeared. Actually, the formula in the book does take that derivative into account. The sigmoid isn’t explicit in the final formula, but it’s baked into the values of y-hat.

It’s been a while since I went through the steps myself, but I googled for a step-by-step calculation and found this one: [https://medium.com/analytics-vidhya/derivative-of-log-loss-function-for-logistic-regression-9b832f025c2d](https://medium.com/analytics-vidhya/derivative-of-log-loss-function-for-logistic-regression-9b832f025c2d)

My apologies for not writing the steps by hand (busy day!), but I checked the calculation in the link above, and I cannot see any obvious errors. If you do, can you please point them out?

---

<div class="post-metadata">

**Author:** ![Alexandr](https://forum.devtalk.com/letter_avatar_proxy/v4/letter/a/71c47a/32.png) [@Alexandr](https://forum.devtalk.com/u/Alexandr)\
**Post date:** [3 November 2020 11:22 UTC](https://forum.devtalk.com/t/programming-machine-learning-incorrect-formula/3716/3 "2020-11-03T11:22:27Z")

</div>

Thank you!  
I just read it inattentively. I think it would be a good idea to insert that link ([https://medium.com/analytics-vidhya/derivative-of-log-loss-function-for-logistic-regression-9b832f025c2d](https://medium.com/analytics-vidhya/derivative-of-log-loss-function-for-logistic-regression-9b832f025c2d)) in the book.  
Best regards.  
P.S.  
Thank you! I think you’ve written the best book for beginners( I’ve read a lot of them).

---

<div class="post-metadata">

**Author:** ![nusco](https://forum.devtalk.com/user_avatar/forum.devtalk.com/nusco/32/5449_2.png) [@nusco](https://forum.devtalk.com/u/nusco)\
**Post date:** [3 November 2020 12:22 UTC](https://forum.devtalk.com/t/programming-machine-learning-incorrect-formula/3716/4 "2020-11-03T12:22:56Z")

</div>

No problem, Alexandr, and thank you for reporting the issue anyway!

---

<div class="post-metadata">

**Author:** ![shane](https://forum.devtalk.com/user_avatar/forum.devtalk.com/shane/32/4068_2.png) [@shane](https://forum.devtalk.com/u/shane)\
**Post date:** [6 April 2022 09:36 UTC](https://forum.devtalk.com/t/programming-machine-learning-incorrect-formula/3716/5 "2022-04-06T09:36:12Z")

</div>

Hi @nusco  
I am confused a problem in this book.

 ![image](https://forum.devtalk.com/uploads/default/original/2X/4/4e80a06fff8d83901c136cf837773260ba31356d.jpeg)

Hi Nusco  
in the highlighted content, I think that is incorrect, because the steeper the curve, the smaller the learning step should be, because when the curve is steeper, just a slight change in w, which will make the loss value change greatly.
