Reputation: 129
I am trying to accomplish the following:
Y_Pred[Y_Pred < 0.99 and Y_Pred > 0.98] = 1
Y_Pred[Y_Pred <=0.98 or Y_Pred >= 0.99] = 0
But the and
and the or
aren't correct?
Upvotes: 0
Views: 30
Reputation: 150735
You should use bitwise operations |
and &
instead of and
and or
. Also, you can use np.where
like this:
Y_Pred = np.where((Y_Pred < 0.99) & (Y_Pred > 0.98),1,0)
or just:
Y_Pred = ((Y_Pred < 0.99) & (Y_Pred > 0.98)).astype(int)
Upvotes: 4