2
$\begingroup$

I am trying to model a packet data with 1 dimensional CNN but I have a very imbalanced classes in my target. I have 3 classes as class 0 has 53000 cases, class 1 has 300 cases and class 2 has 150 cases. Thanks in advance!

I have tried what you have suggested but I do not think I am getting a good results(loss and accuracy), from the model.

enter image description here

$\endgroup$
2
  • $\begingroup$ Class imbalance is not a problem: stats.stackexchange.com/questions/357466/…. You are, however, quite low on data and probably don’t have enough to estimate the thousands or millions of parameters that will be in your neural network. $\endgroup$
    – Dave
    Mar 3, 2021 at 2:10
  • $\begingroup$ Thanks for answering! I have added a picture of what i have done but i am not sure if it is right though. $\endgroup$ Mar 4, 2021 at 15:10

1 Answer 1

0
$\begingroup$

If you are using TensorFlow to write your architecture,

  1. You can create 3 training datasets( one for one class) using tf.data and then you can use tf.data.experimental.sample_from_datasets with the same weightage to generate the batch data. Check weights parameter in the documentation.

  2. You can initialize well in the final layer. Please check this blog from Andrej Karpathy.

  3. You can add the class_weight parameter while training.

$\endgroup$
2
  • $\begingroup$ Thanks for your answer. I have tried with class_weight parameter while training but the loss of the model is increasing instead of decreasing and my accuracy is held fixed by the model( it always gives me 99.60% Accuracy), i do not think that this method works to me or probably i am doing something else wrong. Can you ellaborate more what you mean with creating a 3 training datasets(one for once class) using tf.data and then you can use tf.data.experimental.sample_from_datasets with the same weightage to generate the batch data... $\endgroup$ Mar 4, 2021 at 10:56
  • $\begingroup$ I have added a picture of what i have done. $\endgroup$ Mar 4, 2021 at 15:10

Not the answer you're looking for? Browse other questions tagged or ask your own question.