Week 3- Planar_data_classification_with_one_hidden_layer Assignment- ex9 predict

Hi, I have some difficulties in computing predictions. I can’t get how to classifies
to 0/1 using the given threshold. I wrote “predictions =(X > 0.5)” and when I run the tests the output is:
Predictions: [[ True False False]
[False True False]]
Error: Wrong shape
Error: Wrong output

Thanks in advance for the help!

Hi @mela, as stated in the excercise comment:
# Computes probabilities using forward propagation, and classifies to 0/1 using 0.5 as the threshold.
It seems to me you have not calculated the probabilities but used the inputs directly to calculate the classification result. Hope this helps you

1 Like

Hi, thanks a lot for your answer. I calculate the probabilities with
“A2, cache = forward_propagation(X, parameters)” (Sorry in the post above I missed this line). I don’t know how to classify because what I have in mind is an if-then-else statement or a for loop, but maybe is too much and there is a simpler way. I also tried an if-then-else statement in one line, but I don’t really get how to assign a value to the predictions.
Thanks again in any case
Have a nice day :slight_smile:

ok, then I think the problem is that you have to calculate the prediction on A and not on X

1 Like

Yes, of course. It was not so hard! Thanks a lot!!!