<p>The problem you're describing can perhaps be treated as "anomaly detection". Google the term in quotes, you'll get a ton of references. So the idea would be to first train an anomaly detector to separate the "apples, oranges, and other fruits" from non-fruits (or "nonsense" in OP terminology). Then train a classifier on the fruits.</p>

<p>Update. In light of additional answers -- and too long for a comment.
The problem with declaring a "non-fruit" category highlights the distinction between classification and anomaly detection. In classification, we assume 2 or more coherent classes. Apples, oranges, bananas -- these all have well-defined common characteristics. On the other hand, "non-fruit" is not a coherent category. It can only be meaningfully defined as something like "not fulfilling enough of the fruit characteristics". Anomalous objects are not a coherent class; they are by definition anything that is not sufficiently close to a "normal" object. We do not expect examples of anomalous objects to be informative for training. After all, you can just generate random pixel-images and get tons of anomalous examples for free!</p>

<p>This is why anomaly detection requires techniques distinct from classification.</p>

CC BY-SA 3.0
2017-12-21T17:33:47.140Z
2017-12-22T09:28:52.430Z
2017-12-22T09:28:52.430Z
Aryeh
<blockquote>
  <p>Do you have to train your neural network to have 3 categories, "apple", "orange" and "neither"?</p>
</blockquote>

<p>Yes, you would have to.  </p>

<blockquote>
  <p>Eg. if you have a bot that is supposed to label stuff as either orange or an apple, how can you gurantee that it won't label a random image of noise as either of the two?</p>
</blockquote>

<p>You would need to include images of the third category "neither-apple-orange" so that you train your classifier to learn three categories. </p>

CC BY-SA 3.0
2017-12-22T05:51:45.753Z
2017-12-22T05:51:45.753Z
Alexander S King
<p>Afaik, the problem with many machine learning algorithms is that they will often label nonsense into some categories.</p>

<p>What measures can one take to discard nonsense results?</p>

<p>Eg. if you have a bot that is supposed to label stuff as either orange or an apple, how can you gurantee that it won't label a random image of noise as either of the two?</p>

<p>Or label a car as either of the two?</p>

<p>Do you have to train your neural network to have 3 categories, "apple", "orange" and "neither"?</p>

<machine-learning>
Can machine learning algorithms be trained to discard nonsense?
HopefullyHelpful
# Can machine learning algorithms be trained to discard nonsense?

(Asked by: username_0 on 2017-12-21)

Afaik, the problem with many machine learning algorithms is that they will often label nonsense into some categories.

What measures can one take to discard nonsense results?

Eg. if you have a bot that is supposed to label stuff as either orange or an apple, how can you gurantee that it won't label a random image of noise as either of the two?

Or label a car as either of the two?

Do you have to train your neural network to have 3 categories, "apple", "orange" and "neither"?

**Tags:** machine-learning


---

## 2 answers

### Answer by username_1 on 2017-12-21. Score: 4 | Accepted answer

The problem you're describing can perhaps be treated as "anomaly detection". Google the term in quotes, you'll get a ton of references. So the idea would be to first train an anomaly detector to separate the "apples, oranges, and other fruits" from non-fruits (or "nonsense" in OP terminology). Then train a classifier on the fruits.

Update. In light of additional answers -- and too long for a comment.
The problem with declaring a "non-fruit" category highlights the distinction between classification and anomaly detection. In classification, we assume 2 or more coherent classes. Apples, oranges, bananas -- these all have well-defined common characteristics. On the other hand, "non-fruit" is not a coherent category. It can only be meaningfully defined as something like "not fulfilling enough of the fruit characteristics". Anomalous objects are not a coherent class; they are by definition anything that is not sufficiently close to a "normal" object. We do not expect examples of anomalous objects to be informative for training. After all, you can just generate random pixel-images and get tons of anomalous examples for free!

This is why anomaly detection requires techniques distinct from classification.


---

### Answer by username_2 on 2017-12-22. Score: 1

> Do you have to train your neural network to have 3 categories, "apple", "orange" and "neither"?

Yes, you would have to.

> Eg. if you have a bot that is supposed to label stuff as either orange or an apple, how can you gurantee that it won't label a random image of noise as either of the two?

You would need to include images of the third category "neither-apple-orange" so that you train your classifier to learn three categories.


---

