ranked_ids#
- scikitplot.corpus.ranked_ids(results, *, id_getter=None)[source]#
Return the identifiers of retrieval results, in rank order.
- Parameters:
- resultsiterable
A
RetrievalResponse, or any iterable of results, best first.- id_gettercallable or None, default=None
id_getter(result) -> str or int. WhenNone, each result gives its identifier by this fixed rule, first match wins:a
strorintis the identifier;a 2-tuple
(identifier, score)gives its first item (the shape ofRetrievalIndex.query);an object with
.docgives.doc.doc_id(RetrievalHit);an object with
.doc_idgives it (a document).
- Returns:
- list
Identifiers (
strorint), possibly repeated (several chunks of one document); the metrics decide what a repeat means.
- Raises:
- TypeError
If
resultsis astr,bytesor mapping, or a result yields nostr/intidentifier.
- Parameters:
- Return type:
Examples
>>> ranked_ids([("d2", 0.9), ("d1", 0.4)]) ['d2', 'd1'] >>> ranked_ids([{"id": 7}], id_getter=lambda r: r["id"]) [7]