Course 1 Week2, predict function query

I can use an if-else loop and convert activation to Y_Prediction as mentioned below

  1. Convert the entries of a into 0 (if activation <= 0.5) or 1 (if activation > 0.5), stores the predictions in a vector Y_prediction . If you wish, you can use an if / else statement in a for loop

Though there is also a way to vectorize this, can someone share vectorize version?

Please see this other recent thread.

2 Likes

Thanks Paul. astype method will solve the problem of casting the boolean to float.

1 Like