How to Solve NameError: name 'class_weight' is not defined -- sklearn

Solution: Import the 'class_weight' module

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

from sklearn.utils import class_weight

 

For more information:
Python sklearn class_weight