An anomaly on the surface scores zero
counterexample▲▲△The best width-one linear autoencoder for the four points , , and projects onto . Its squared reconstruction error is used as an anomaly score, and any input scoring above is flagged.
(a) Find the scores of the four training points.
(b) Find the scores of and of , and the distance from each to its nearest training point.
(c) Which of the two is flagged?
(d) What does the score measure, and what would be needed to flag the other one?
Hint
Write each new point in the eigenvectors and . The score is the square of the component.
Solution
(a) Each training point has a component of along , so every score is . The threshold of passes all of them.
(b) The point is . It lies on the principal axis and its score is . Its nearest training points are and , each at distance .
The point is . Its score is . Its nearest training points are and , each at distance .
(c) Only is flagged. The point passes with the lowest score of any input seen so far, lower than every training point, though it is more than three times as far from the data as the point that was flagged.
(d) The score is the squared distance from the reconstruction surface, here a line. It says nothing about where along the line an input falls. The line extends without end, and the data occupy a short stretch of it.
To flag one must know which codes are usual. Its code is , where the training codes are . Reconstruction error does not look at the code, and (I.12.1) defines no distribution over codes against which could be judged improbable. A threshold on the size of the code would catch this case and would be a second detector, added by hand.
The failure grows with the quality of the model. A decoder that generalises well reconstructs inputs it was never shown, and each of them scores as normal.