-1

I'm trying to train a NN for binary classification but using multi-class approach, hence Class (C) =2. The accuracy on both train and test data sets is ~ 96%. However, manual checking reveals that Tensorflow always picks 0 for every example.

I'm interested in knowing how to go about debugging this issue and what I am doing wrong. Greatly appreciate your help. Thanks.

(Please let me know if I'm being too vague and not providing enough info in order for you to pinpoint a good solution. Thanks.)

Chris N
  • 17
  • 4
  • 3
    Please [look at MCVE](https://stackoverflow.com/help/mcve) and edit your question accordingly. – Vivek Kumar Oct 12 '17 at 06:06
  • 1
    We'll probably need the code of a MCVE (see comment above) to help you properly. Just checking the trivial answer: does your class 0 represent 96% of your data ? In that case there is no problem, it has just learnt to predict 0 all the time, which does yield 96% of good answers. Otherwise we'll need some code and a bit of knowledge about the data. – gdelab Oct 12 '17 at 08:03

1 Answers1

1

If you have 96% accuracy and all predictions are 0 then your dataset is probably imbalanced. You should balance it and make the number of samples from the positive and negative classes the same. You can also add weights for the class, penalizing more the class with less samples.

Lucas Ramos
  • 459
  • 4
  • 12
  • This answer and the one by @gdelab are right on. I took a look at the data set and indeed it's what you two had suggested. Any suggestions on how to address this issue? (Unfortunately, I don't have enough reputations to vote for your answers) – Chris N Oct 12 '17 at 17:15
  • For Neural Networks there is no simple work around, you can add weights to your model or fix the dataset. My solution would be resampling the dataset, you can undersample the predominant class so you have 50/50 of each class, or you can oversample the minority class. Theres a library in python with several solutions for that: https://github.com/scikit-learn-contrib/imbalanced-learn – Lucas Ramos Oct 13 '17 at 07:31