I’m using sklearn.version 0.23.2.
targets = np.random.randint(0, 100, (100,))
class_weights = compute_class_weight('balanced', classes=np.unique(targets), y=targets)

This way works for me either but I still get the warning…