Question

I have performed fruits classification using CNN but i am paused at a point where all things are going right confusion matrix accuracy score all are correct it seems there is no overfitting but it always classifies wrong fruit. Why would this happen. Link to source code is provided below. Thank You!

Github source code link

Was it helpful?

Solution

It looks like the new data has a different distribution from the training data. It looks like the training data is just a single fruit, with white background, and the new image you've passed is a picture of bananas with blue background. The model has probably learned something like: if blue image, then blueberries, and for this reason it classifies the blue bananas picture as blueberries.

Whenever the distribution of new data is different from the data you've trained on, don't expect the model to work very well, as ML models just interpolate.

OTHER TIPS

If your dataset is too small, it won't apply to other new data easily. In this case, you should either:

  1. try to increase your training dataset

    Find new images and classify them to increase the training data size, the model will improve as you add new images, but this can be time consuming

  2. use transfer learning

    Find a model that someone else built on a similar dataset and use that as a starting point for your model. They would have already found a large training dataset, built a model on that dataset, and saved the model to a public location for others to use and apply to new datasets. Need to find a model that is built on a dataset that is somewhat similar to your data.

  3. Data augmentation

    Can also help with #1, but you still need many images to train with.

Here is a good reference to use for transfer learning: https://machinelearningmastery.com/transfer-learning-for-deep-learning/

Licensed under: CC-BY-SA with attribution
Not affiliated with datascience.stackexchange
scroll top