First classifier -- Cat versus a Dog, a Monkey, and a House

For the initial Cat Classifier in Part 1 I downloaded a random image of a single cat and a single monkey. The cat was recognized correctly with a probability of 1. The monkey was recognized as a cat with a probability of .991. At first I thought I was doing something wrong so I uploaded an image of a house which was classified (not surprisingly) as “not a cat” with probability of .011126. Then I read the instructions that I should be using images of cats OR dogs. So the random dog image was correctly identified as “not a cat” with a probability of a whopping 0.000015.

Apologies for what may be an obvious question: Is it just random that one monkey image was recognized as a cat ? And was the classifier really good at distinguishing dogs from cats versus houses from cats because dogs and cats were used to train the model and houses were not?

I’m a relative beginner here, so take my words with a grain of salt.

Your intuition is right. The model has only been trained to expect a picture of a dog or a picture of a cat. So there are absolutely no guarantees on what it’ll predict if a photo has neither. I’ve made a dog/cat classifier beforehand and one of my favorite examples of this was, if you uploaded a photo of grass, the classifier was quite confident in saying “this is a dog,” because it had only seen grass in the dog images, and the only two options it has is “dog” and “cat.”

You can definitely make a classifier that says “cat” or “not cat”: just feed one category of cats and one category of many objects that aren’t cats. That’s just not what this model is.


Hi irl hope all is well! I agree with @mckennabrown points, and would add that the model hasn’t really learned to recognise cats and dogs but the relationship between the images and their labels of cats and dogs.

This means that if you pass it any image it uses the relationship/model to calculate which class the picture fits best.

This makes an interesting game one can play, which is before processing the image which the model is not trained for, you can try to guess what the classifier will predict.

There is a post somewhere on this forum where some people use an algorithm to change just one pixel in a image, which then changes the class the model predicts for that image.

There are also various posts and notebook 6 that contain techniques for reducing the chances of this happening.

Heres one such link How to make a classifier identify whether or not something fits into a category?

Cheers mrfabulous1 :smiley: :smiley: