1
$\begingroup$

I built a CNN image classifier for a dataset that contains 6 classes. The dataset is balanced in all 6 classes. After training, the model gives pretty good prediction accuracy in all but 2 classes. To elaborate further, let us label these 6 classes with integers from '0' to '5'. The trained model does well in predicting classes from '0' to '3'. But almost 5%-10% of class '4' image is predicted as class '5' and similarly, 5%-10% of class '5' image is predicted as class '4'.

How should I deal with this situation?

$\endgroup$

2 Answers 2

1
$\begingroup$

How well does a model trained to predict just classes 4 and 5 (trained and tested on the data for these two classes) perform? If that performs well, you could use this model as a second classifier. So initially classify the image using your original classifier; then if that predicts either class 4 or class 5, re-classify it using the second classifier.

$\endgroup$
1
$\begingroup$

If these two classes are important to you relative to other classes, you should increase their class_weight during training.

In Keras, for example, this would be a parameter in the fit function. Like

c_weights = {0: 1., 1: 1., 2: 1., 3: 1., 4:2., 5:2.}
model.fit(..., class_weight=c_weights)

In this case, most probably, you get better accuracy for your preferred classes and slightly worse accuracy for other classes. Is this what you are looking for?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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