# Why 100% accuracy on test data is not good?

I was asked this question in an interview and wasn’t able to give a satisfactory answer not only upto the interviewers' expectations but of my own as well. The question was as above only, he later gave an example as if why if my model predicted the prices of oil of tomorrow 100% accurately why that might be bad or why having a model 100% accurate bad or is it? Is there something in the question or is there a deeper explanation?

• Remember you are predicting something and the probability isn't always 1 that it will happen always... ms thus 100% is just for namesake... Dec 30 '18 at 20:50

I see two ways to go: 1 - There is an error 2 - There is no error.

1 - Look for the error

• You probably have commited Data Leakage. You have added the target in one of the features and the model found out.

• The validation is not right, you have a time series and you have done random validation.

• Your test has only a few instances or it is unique.

• The test is repeated from the train.

2 - There is no error

If the prediction is right and you have 100% accuracy, then no need to do Machine Learning. Open the model find where is taking the decision and don't do machine learning, do classical modeling.

For example if your model is a decision tree, just plot it or print it and get the decision and put them yourself.

This sometimes happens when modeling a previous developed algorithm. The new ML model is able to learn what was going on before.

Shortest possible explanation: You might be overfitting your data.

Sure, that is happening in the TEST set, not the training one... but what if, by mistake, you have leaked data from the train set into the test one (this happens, trust me).

When you get 100% accuracy, it is most likely a form of overfitting, and that is ultimately a bug. Again, even on the test set... it might just be a data leaking.

If you have a model that has $$100%$$ accuracy on unseen test data there are some situations that I will explain.

1. If you have a situation that does not change over time and there are no exceptions in that, the mentioned accuracy is very satisfactory and you can say with confidence that your model has learnt what it should do. As an example, you can implement an LSTM network which can be able to find the sum of binary numbers. In this case, due to the fact that you always know the some of typical $$10 + 01$$ values is always $$100$$, and it is a fact that does not change, $$100$$% is acceptable.
2. There are cases where the situations of the current time are different from those of tomorrow's. It means that the behaviour of the nature that you are going to model it is not a function but a distribution. This means for the current feature space you may have different outcomes. This is the case where in the current feature space the distribution of different classes, i.e. in classification tasks, overlap. This means that it is impossible that you have $$100%$$ accuracy because the nature you are going to model is not a function. If I want to explain it again there are two situations. first, the nature of the distribution is time variant or invariant. The former case is something that is affected by the previous outcomes. The latter case can have contradictory outcomes with the same input features due to the overlap of distributions.

Not sure if this is going to be a satisfactory answer... 1st thing that comes to mind whenever I get a 100% accuracy on test data is "I must have done something wrong".

Most commonly, I've added a feature to the dataset that is actually a sort of proxy of the target variable. That is, I've made a silly mistake.

But sometimes it is not a silly mistake, like adding a feature. I don't really remember the source thus I cannot link to it. But I heard in a podcast about some guys that were trying to classify patients of cancer from some features (I mean not from images of cancer cells or anything like that), and they built a model that was pretty simple and surprisingly good (not 100% accuracy though). The point was they included some kind of id of the patient as a feature, and that id somehow contained information about the hospital that treated them. There were a few hospitals that treated the very bad cases, thus the model was learning that anybody going to those few hospitals was really sick, and not really learning about who was sick.

Hope it helps.

Training a heavy model on a small dataset, all from the same distribution, could cause an overfit. Even on the test set. When you deploy that model on real world data, you may experience a model drastic performance drop. (ie: getting high variance).

Edited: Rethinking the question again and this is what I was trying to explain. Imagine you're trying to train an bird classifier that can predict if there's a bird in a picture or video frame. You train and test your model with high quality and clear images of bird maybe surfed from the internet of taken professionally,.. You get an 100% accuracy on train and test set... But when you deploy your model... It may not perform as well because the images the model would be using may not be as clear as the training and test data. 100% test accuracy isn't bad but not a final performance metric...