Patage, tumorsize are my input features.
Diagnosislabel:my output label
Preds are linear regression values which go as inputs into sigmoid.
Sigout are final sigmoid function outputs of Preds values.

which means it is not an error, but the output isn’t what you are expecting for. In this way, I would only recommend you to print the variables out and check one by one to see which one is not normal. For example, in this part of the line:

You may want to do something like below inside the loop

Note that I won’t be only doing the 2nd line of prints, but also the 3rd line which only additionally uses np.log there. Similarly, instead of only doing the 1st and the 3rd, I am also doing the 4th which simply multiply the 1st and the 3rd together.

Hope you will see something unexpected to pin down the source of the problem.

Thanks have to do some digging for sure. did some quick calculation using libre calc and got same sort of error in it. Uploading the screenshot.
my suspicion… coding bug …

Hi
after careful checking of runtime warning inside the loop where loss function is being computed:
I noticed this discrepancy:
for a knownoutputlabel which is 0, then loss function shall be: *- (1-knowndiagnosis[eachrow])np.log(1-sigmoidoutput[eachrow]))
I further broke down this formula and after some check iterations, I narrowed it down to this scenario whenever knowndiagnosislabel is 0, I get the runtime warning.

Corresponding Value of (f_wb_i) sigmoidoutput[eachrow] is 1.0

Next checked for part of simplified loss function when outputlabel =0; which is -1*log(1-f_wb_i) 3. np.log(1-1.0) is throwing a runtime error as ‘inf’.
Mathematically, it makes sense what is causing this runtime error here.
![Screenshot from 2022-09-29 11-04-05|456x74]
(upload://4dWcCuLtmAMx3jcmQnkmd2mDdOR.png)

@rmwkwok Finished part of my ML C1 W3 assignment; up until Regularized logistic regression. I implemented the code successfully on the 1st go it self. Now this baffles me more, b’coz I finished the assignment from lines in my local program which was giving these run time warnings.

As you said, np.log(0) should get you some unexpected result. As for the assignment, maybe it never touches 0 in the log? You can verify this by, again, printing anything that’s been put inside np.log.

@rmwkwok So, in a way controlling number of significant figures, that go into log calculation might help in avoiding this runtime error? (with ref to:np.clip function)