INNER CODE UNIT · Python
_get_vote_matrix
NorskRegnesentral/skweak · skweak/aggregation.py:210
def _get_vote_matrix(self, include_underspec=True) -> Tuple[np.ndarray, np.ndarray]:
"""Creates a boolean matrice of shape (nb_observed_labels, nb_out_labels)
which specifies possible mappings between observed labels and actual
output labels.
If include_underspec is set to True, we also include "partial" votes due to
underspecified labels (e.g. ENT)."""
votes = np.zeros((len(self.observed_labels),
len(self.out_labels)), dtype=np.float32)
for i, label in enumerate(self.observed_labels):
if label in self.out_labels:
votes[i, self.out_labels.index(label)] = 1
for coarse_label, fine_labels in self.label_groups.items():
for fine_label in fine_labels:
if include_underspec and fine_label in self.out_labels: # underspecification