TransWikia.com

setting class weights for imbalanced dataset, how using EarlyStopping?

Data Science Asked on October 2, 2021

I want to train a CNN with Early Stopping (Keras).
The data set is imbalanced, so I have set class_weights to ‘balanced’ like follows:

class_weights=class_weight.comput_class_weight('balanced', np.unique(y_train),y_train)

I would like also use Early Stopping, and here is the problem.
Which metric for monitor should I use?
Because I have still balanced the data set with the class weights, shouldn’t it be ok when using val_loss?

Hoping for hints and thank you in advance

One Answer

Early stopping is not directly affected by imbalanced data.

Also comput_class_weight effects the training, not the evaluation.

As far as picking a metric for evaluating imbalanced data, it depends on the specific problem. The most common choices are F-score, precision, and recall. It appears that you are using scikit-learn which offers a weighted option, finding average weighted by class support.

Answered by Brian Spiering on October 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP