Convering numerical data to categorical data

how do I convert y_pred which is a numpy array like [0,1,0,1] to an array of neg and pos

From what I understood, you want to one-hot encode the y_pred vector i.e. a conversion from [0, 1, 0, 1] to something like {“neg”: [1, 0, 1, 0], “pos”: [0, 1, 0, 1]}.

To do this directly, either use “to_categorical()” from “keras.utils” or if you don’t want to use keras, you can also do this pandas using “pd.get_dummies()”.

Let me know if you need usage examples too.
PS: Ensure y_pred is of type “int” or something related. Using “float” can give unexpected results.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.