title: How to calculate class weights of a Pandas DataFrame for Keras?
body: <p>I'm trying</p>
  
  <pre><code>print(Y)
  print(Y.shape)
  
  class_weights = compute_class_weight('balanced',
                                       np.unique(Y),
                                       Y)
  print(class_weights)
  </code></pre>
  
  <p>But this gives me an error:</p>
  
  <pre><code>ValueError: classes should include all valid labels that can be in y
  </code></pre>
  
  <p>My <code>Y</code> looks like:</p>
  
  <pre><code>       0  1  2  3  4
  0      0  0  1  0  0
  1      1  0  0  0  0
  2      0  0  0  1  0
  3      0  0  1  0  0
  ...
  14992     0  0  1  0  0
  14993      0  0  1  0  0
  </code></pre>
  
  <p>And my <code>Y.shape</code> looks like:
  <code>(14993, 5)</code></p>
  
  <p>In my <code>keras</code> model, I want to use the <code>class_weights</code> as it is an uneven distribution:</p>
  
  <pre><code>model.fit(X, Y, epochs=100, shuffle=True, batch_size=1500, class_weights=class_weights, validation_split=0.05, verbose=1, callbacks=[csvLogger])
  </code></pre>