title: Evaluating DenseNet model in Keras with weighted classes
body: <p>I am doing a binary classification in Keras, using DenseNet.</p>
  <p>Created weighted classes:</p>
  <pre><code># Assign weights
  weight_for_0 = num_normal/(num_normal + num_covid)
  weight_for_1 = num_covid/(num_normal + num_covid)
  class_weight = {0: weight_for_0, 1: weight_for_1}
  
  # Print
  print(f&quot;Weight for class 0: {weight_for_0:.2f}&quot;)
  print(f&quot;Weight for class 1: {weight_for_1:.2f}&quot;)
  </code></pre>
  <p>As a result, I have</p>
  <pre><code>Weight for class 0: 0.74
  Weight for class 1: 0.26
  </code></pre>
  <p>I fitted the model with <code>class_weight</code></p>
  <pre><code>history_dense201_weighted = model_dense_201.fit_generator(train_generator, epochs = 20, 
  validation_data = valid_generator, class_weight = class_weight, callbacks = [# mcp_save,                                                                                                                                                            
  early_stopping, tensorboard_callback])
  </code></pre>
  <p>But when I want to evaluate the model, I am not sure how to evaluate the weighted model, because the <code>class_weight</code> is a part of the history.</p>
  <p>How to update this code, using instead of default <code>model_dense_201</code> model a weighted model?</p>
  <pre><code># Evaluation 
  evaluation = model_dense_201.evaluate(valid_generator)
  print(f&quot;Validation Accuracy: {evaluation[1] * 100:.2f}%&quot;)
  evaluation = model_dense_201.evaluate(train_generator)
  print(f&quot;Train Accuracy: {evaluation[1] * 100:.2f}%&quot;)
  </code></pre>