# Unseen classes - 'Other' class or classifying based on the existing classes

Let's suppose that I have a classifier which detects whether a script of code is written in Python or C++ or Java.

Therefore, my classifier has 3 outputs which give the probabilities that a certain code script is one of these 3 programming languages above.

However, unfortunately, there is the chance that the test data my contain some code scripts written in other programming languages such as Javascript, Ruby, PHP etc.

If I leave my classifier as it is then it going to classify these code scripts as being in Python or C++ or Java and this will be certainly pretty wrong and misleading.

Does it make sense to add another class called 'Other' which would contain code scripts of various other programming languages (Javascript, Ruby, PHP etc) or even irrelevant text to cope with that?

Is there any better idea?

• I think your approach makes sense. Of course it would be best to have all possible outcomes (classes) in the training set, but this might not be possible. With the „other“ class you may at least avoid that code snippets are classified entirely wrong. Ultimately, it is about testing the approach, but I can imagine that it works well. May 31 '19 at 15:47
• Thanks @Peter , I will listen to the opinions of others too and think about it. May 31 '19 at 15:55

• Thanks, I have actually seen this post. However, predict_proba is not really a confidence score which will help in the case of unseen classes because in predict_proba the output probabilities always sum up to 1. It would be interesting if we could have some output probabilities that do not necessarily sum up to 1 but they may be all very low and let's say sum up to 0.3 if an irrelevant text is given as an input. May 31 '19 at 16:31