# Is there a way to ensure that my model is able to recognize an unseen example?

My question is more theoretical than practical. Let's say that I am training my cat classifier with a dataset that I feel is pretty representative of cat images in general. But then a new breed of cat is created that is distinct from other cats and it does not exist in my dataset. My question is, is there a way to ensure that my model is still able to recognize this unseen breed, even though I didn't know it would come into existence when I originally trained my model?

I have been trying to answer this question by intentionally designing my dev and test sets such that they contain examples that are quite distantly related to those that exist in the training set (think of it like intentionally leaving out specific breeds of cats from the training set). The results are interesting. For example, slight changes to parameters can dramatically change performance on the distantly related test examples, while not changing performance very much for the more closely related examples. I was wondering if anyone has done a deeper analysis of this phenomenon.

• Hi and welcome to AI SE. This is an interesting question. I added the tag neural-networks because I assumed your models are neural networks. Furthermore, your title wasn't directly related to your main question in the body, so I changed it. – nbro Feb 25 '20 at 1:28
• I am tempted to conclude that the best way to ensure that the network still performs well on unseen examples is to regularize it as much as possible (Dropout rate of 0.5 at every layer, for example). Do you think this intuition is correct? – mdurrant Feb 25 '20 at 18:01
• Dropout is just one way of introducing a regularization effect. There are others. Dropout should help to avoid overfitting and thus the network shouldn't memorize the training dataset (i.e. approximate the function that the training set represents), but, instead, approximate a different function (not the one represented by the training set). Clearly, this should help to predict something that isn't in the training set, but this will not ensure that a specific unseen example will be predicted correctly. – nbro Feb 25 '20 at 18:32
• The term regularization is often used ambiguously. For example, in L1 or L2 regularization, the goal is to constrain the parameters to lie in a certain range. In other cases, for example, in the case of dropout, the idea is that you attempt to decorrelate the units of the network (by randomly dropping or killing them during training). In the case of Bayesian neural networks, the regularisation is said to be integrated into the networks because they are based on Bayes rule, so, in a certain way, the uncertainty associated with the learned distributions depends on the available data. – nbro Feb 25 '20 at 21:38
• To answer your question directly, regularization may help, but it may depend on the regularization that you use. – nbro Feb 25 '20 at 21:40

The comments already are giving you some good tips about how to improve what your model recognizes, but I think your question goes above that asking if there's a way to ensure that it will always recognize the cats.

The slightly longer answer is "yes, but cheating".

Regardless, there are a lot of steps you might take to improve the generalization aspect of your model.

## A drama: cat classification in three acts

### Act I: Cat as texts

Let's start with an example. Say that your model is trained with these inputs, and learns to correctly recognize them as a cat or not a cat:

cat → yes!
Cat → yes!
ferret → no
cat. → yes!
Cat! → yes!
Three MC's and one DJ → no


Your goal is to train your model so that every new variation, even unseen ones, will correctly be identified.

With a good level of generalization, your model will correctly classify new inputs that it has never seen before:

skunk → no
cat? → yes!
dog → no
CAT → yes


With this scenario, let's say the model now finds this:

kat → ?


Is that a "cat" misspelled? Is that short for Katherine? What should the model do?

### Act II: But surely this doesn't happen in real life

Leaving the analogy for a bit, will your model that's looking at domestic cats properly accommodate for Savannah Cats, or will it consider them out? (They kind of look like cheetahs.) What about Sphinx cats? (They look like raw chicken to me.) Elf cats? (They look like bats.) This is just an example, but you can probably figure out more.

And the reason behind this problem is that the distinction itself between different classifications (in real life) is not binary, but rather a transition between "yes, that's a textbook cat" and "that's a chair". Your model will output binary decisions (maybe accompanied by a confidence interval, but even with it, you'll make the call into deciding if it's a cat or not).

Setting specific boundaries will help. You can define that your model will only detect domestic cats, maybe no bigger than a certain size, only of certain colors, etc... This is limiting what the model will correctly recognize as a cat when we (humans) might disagree. For instance, I would still argue that flourescent cats are still cats.

Going back to the simple text analogy, this is similar to deciding that to be detected as a cat, it has to start with a "c". So now you've discarded ¡Cat!.

In this way, it's not possible to ensure (notice the word) that your model will detect all of these unknown variations. There will be always some room for error that needs to be accepted, as long as the errors are infrequent or rare enough that they can be accepted as a regular part of the model.

### Act III: Concept drift, a cautionary tale

Finally, the problem becomes even harder as we might be dealing with concepts that change over time, outside of the knowledge of the model, and outside of the knowledge of the person that supervised the model learning.

As and the breeds of cat changes, your model will have to accommodate by what we (users of the model) consider a valid definition of cat. Which might change in really unexpected ways and not really "look" like a cat. And since your model can only learn from what "looks" like a cat, it's always held in a disadvantaged position.

This will happen with almost any machine learning model that is approximating a result, regardless of the technique/algorithm. Approximations include a level of error because reality is usually complex in ways that we either don't know about or that are too computationally expensive.

• I think that explaining by example is usually easier to grasp, so I thought it would make a better answer. However, being an example it doesn't really tackle the underlying issues with model errors in detail, leaving it incomplete. If readers want to expand on it, please, feel free to do so. – Alpha Feb 26 '20 at 22:16
• Thank you for this answer! Definitely got me thinking, much appreciated. – mdurrant Feb 27 '20 at 0:16
• @mdurrant I'm glad! In your particular case, I would suggest just setting up acceptable boundaries and moving forward. Yes, the model might not be future-proof of 100% accurate... but it still might be useful! – Alpha Feb 27 '20 at 13:08