title: Significantly lower accuracy while using class_weight for imbalanced dataset in keras
body: <p>I have rather unintuitive problem. I am doing the sentiment analysis on Amazon Book reviews and the data set is heavily imbalanced. Positive reviews are almost 10 times the negative reviews, accuracy for both training and testing are around 90% (with imbalanced dataset). However, when I try to balance the dataset with the help of <code>class_weight = {0:10 , 1:1}</code> both training and testing accuracy drops to around 65%. Again if I do <code>class_weight = {0:1 , 1:10}</code> accuracy booms again, so apparently I am setting the <code>class_weight</code> wrong but as I understood because the number of positive reviews(1) are 10 times the number of negative reviews(0), shouldn't the <code>class_weight</code> be set as {0:10 , 1:1} ?</p>
  
  <p>This is how I classify training and testing data:</p>
  
  <pre><code>x_train, x_test, y_train, y_test = train_test_split(sequences,labels, test_size = 0.33, random_state = 42)
  </code></pre>
  
  <p>This is my model:</p>
  
  <pre><code>model = Sequential()
  model.add(Embedding(max_words, embedding_dim))
  model.add(Dropout(0.5))
  model.add(LSTM(32, dropout=0.5, recurrent_dropout=0.5))
  model.add(Dense(2, activation='sigmoid'))
  model.compile(optimizer='rmsprop', loss='binary_crossentropy',metrics=['acc'])
  model.fit(x_train, y_train, epochs=10, batch_size=320, class_weight = {0:1 , 1:10})
  </code></pre>