PairwiseRanker#

class scikitplot.corpus.PairwiseRanker(score_func, *, greater_is_better=True, use_normalized_text=True, score_cutoff=None, name=None, kwargs=None)[source]#

Ranker built from a pairwise relevance function.

Parameters:
score_funccallable

score_func(query, text, **kwargs) -> float; finite values only.

greater_is_betterbool, default=True

False for a distance: hits are scored -score_func(...).

use_normalized_textbool, default=True

Compare with a document’s normalized_text when it has one.

score_cutofffloat or None, default=None

Drop hits whose (signed) score is below it.

namestr or None, default=None

Recorded as native_metric; defaults to the function name.

kwargsmapping or None, default=None

Fixed keyword arguments of score_func.

Parameters:
  • score_func (Callable[..., Any])

  • greater_is_better (bool)

  • use_normalized_text (bool)

  • score_cutoff (float | None)

  • name (str | None)

  • kwargs (Mapping[str, Any] | None)

Notes

Build it with make_pairwise_ranker, which validates the arguments.

__call__(query, documents, config)[source]#

Return the best config.top_k documents for query.

Parameters:
querystr

Query text.

documentssequence of CorpusDocument

Candidates.

configRetrievalConfig

Supplies top_k.

Returns:
list of RetrievalHit

match_mode="pairwise", native_score the raw value, native_metric the function name, rank from 0.

Raises:
TypeError

If score_func returns something other than a real number.

ValueError

If it returns a non-finite value, naming the document position.

Parameters:
Return type:

list[RetrievalHit]