Skip to content

Instantly share code, notes, and snippets.

@kkoehncke
Last active August 12, 2018 20:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kkoehncke/bd31e3ce470ec0e34783e6627c9b7452 to your computer and use it in GitHub Desktop.
Save kkoehncke/bd31e3ce470ec0e34783e6627c9b7452 to your computer and use it in GitHub Desktop.
#Calculate class weights so we can account for the class imbalance
from sklearn.utils import class_weight
y_ints = [y.argmax() for y in y_train]
class_weights = class_weight.compute_class_weight('balanced',
np.unique(y_train),
y_ints)
feed_class_weights = {0: class_weights[0],
1: class_weights[1]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment