Hinton and Salakhutdinov (2006) judge document codes by retrieval. Each test document is used as a query; the other test documents are ranked by the cosine of the angle between their code and the query's code, and the score is the fraction of the retrieved documents that have the same class as the query, averaged over all possible queries. Plotting that score against the number retrieved compares an autoencoder's codes with those of latent semantic analysis. Compute the curve.
Implement retrieval_accuracy(codes, labels, ks).
Inputs
codes: shape (n, d), one code per document, .labels: length n, the class of each document (ints).ks: a list of numbers of documents to retrieve, each between 1 and .Rules
Output: a list of floats, one per entry of ks, in the same order.