ensign.comp_top_k.get_top_k¶
-
get_top_k
(factors, labels, comp_ids, k=10)[source]¶ Computes the top k labels and corresponding scores for each mode for each component in the list.
- Parameters
- factorslist of ndarray
Factor matrices formatted as a list of ndarrays. Each factor matrix should be represented as an ndarray and have shape (mode_size, rank).
- labelslist of lists of str
List of label maps, each of which formatted as a list of strings. e.g. labels[1][5] should get the 5th label of mode 1.
- comp_idslist of int
List of component ids
- kint
The number of labels and scores to return from each mode for each component.
- Returns
- retdict
Nested dictionaries containing sorted lists of tuples. Keys are component ID and mode ID. Each tuple contains a label, its index in the mode, and its score in the factor matrix. (label, idx, score) e.g. Retrieve a tuple of the highest scoring label from mode 2 of component 10: ret[10][2][0]