How to Solve NameError: name 'to_categorical' is not defined -- keras

Solution: Import the 'to_categorical' module

To Solve the error, add the following line to the top of your code.

from keras.utils import to_categorical

 

For more information:
Python keras to_categorical