Why is categorical conversion needed?

I am getting confused as to why we had to convert ‘Y’ into a 1 hot representation. Why couldn’t we go forward with class label only?

Hey @ambika11, actually if we will proceed with the integer values than our model will predict a single real number, and if we have multiple classes say 10, than you need to decide how to clip like value between 0.5 and 1.5 belong to class 1 etc. This would be ambiguous also accuracy achieved using this will not be good.

On the other hand we now predict probabilities of belonging to each class, this mean our model will predict 10 values (assuming softmax activation in last layer), corresponding to each class. Now we can take np.argmax and predict the corresponding class. Since our model has output of (no_of_exampels, number_of_classes) we need to have y_actual of same shape and that is the reason we need to create one hot encoding.

Hope this resolved your doubt.
Plz mark the doubt as resolved in my doubts sectoin. :blush:

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.