0

I have a y_actual array of size (1250, ) and a y_predicted array of size (1250,1). I want to compute the absolute value of the difference between y_actual and y_predicted, that I achieve with : diff_y = np.abs(y_actual[:,] - y_predicted[:,0])

I would like to modify values is diff_y for the specific case where y_actual is > 0 and y_predicted is < 0. Let's assume I want to multiply it by 2. I made several unsuccessful attemps, like : diff_y[y_actual[:,]> 0 and y_predicted[:,0] <0] *=2 but I don't succeed. Any idea how to proceed ? Thx in advance

1
  • 1
    Side note: you could use np.abs(y_actual - np.squeeze(y_predicted)) for the first snippet. Commented Aug 16, 2020 at 16:23

1 Answer 1

1

You can try this

y_predicted = y_predicted.reshape(y_actual.shape)
diff_y = np.abs(y_actual - y_predicted)
diff_y[(y_actual> 0) & (y_predicted<0)] *=2
print(diff_y)
Sign up to request clarification or add additional context in comments.

1 Comment

Great ! Thanks a lot

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.