Ranker

Ranker sorts the objects in the Corpus by a given scoring function and annotates the objects with their rankings.

Example usage: Ranking users in r/Cornell by the number of comments they have made.

class convokit.ranker.ranker.Ranker(obj_type: str, score_func: Callable[[convokit.model.corpusComponent.CorpusComponent], Union[int, float]], score_attribute_name: str = 'score', rank_attribute_name: str = 'rank')

Ranker sorts the objects in the Corpus by a given scoring function and annotates the objects with their rankings.

Parameters
  • obj_type – type of Corpus object to rank: ‘conversation’, ‘speaker’, or ‘utterance’

  • score_func – function for computing the score of a given object

  • score_attribute_name – metadata attribute name to use in annotation for score value, default: “score”

  • rank_attribute_name – metadata attribute name to use in annotation for the rank value, default: “rank”

summarize(corpus: convokit.model.corpus.Corpus, selector: Callable[[convokit.model.corpusComponent.CorpusComponent], bool] = <function Ranker.<lambda>>)

Generate a dataframe indexed by object id, containing score + rank, and sorted by rank (in ascending order) of the objects in an annotated corpus, with an optional selector selecting which objects to be included in the dataframe

Parameters
  • corpus – annotated target corpus

  • selector – a (lambda) function that takes a Corpus object and returns True or False (i.e. include / exclude). By default, the selector includes all objects of the specified type in the Corpus.

Returns

a pandas DataFrame

summarize_objs(objs: List[convokit.model.corpusComponent.CorpusComponent])

Generate a dataframe indexed by object id, containing score + rank, and sorted by rank (in ascending order) of the objects in an annotated corpus, or a list of corpus objects

Parameters

objs – list of annotated corpus objects

Returns

a pandas DataFrame

transform(corpus: convokit.model.corpus.Corpus, y=None, selector: Callable[[convokit.model.corpusComponent.CorpusComponent], bool] = <function Ranker.<lambda>>) → convokit.model.corpus.Corpus

Annotate corpus objects with scores and rankings.

Parameters
  • corpus – target corpus

  • selector – (lambda) function taking in a Corpus object and returning True / False; selects for Corpus objects to annotate.

Returns

annotated corpus

transform_objs(objs: List[convokit.model.corpusComponent.CorpusComponent])

Annotate list of Corpus objects with scores and rankings.

Parameters

objs – target list of Corpus objects

Returns

list of annotated COrpus objects