INNER CODE UNIT · Python
_get_probs
NorskRegnesentral/skweak · skweak/aggregation.py:369
def _get_probs(self, agg_df: pandas.DataFrame) -> Dict:
"""Takes as input a 2D dataframe of shape (nb_entries, nb_labels)
assocating each token to the probability of an output label, and returns
a dictionary mapping each token to a distribution over labels"""
return utils.token_array_to_probs(agg_df.values, self.out_labels)
def get_observation_df(self, doc: Doc):
"""Returns a dataframe containing the observed predictions of each labelling
sources for the document. The content of the dataframe depends on the prefixes.
The dataframe has one row per token."""
# Extracting the sources to consider (and filtering out the ones to avoid)
sources = self._get_sources_to_aggregate(doc)
data = utils.spans_to_array(doc, self.observed_labels, sources)
return pandas.DataFrame(data, columns=sources)