INNER CODE UNIT · Python

get_observation_df

NorskRegnesentral/skweak · skweak/aggregation.py:112

    def get_observation_df(self, doc: Doc):
        """Returns a dataframe containing the observed predictions of each labelling
        sources for the document. The dataframe has one row per unique span for span 
        labelling, and one row per token for sequence labelling."""

        raise NotImplementedError("must implement get_observation_df")    


    def filter_observations(self, obs:pandas.DataFrame) -> pandas.DataFrame:
        
        # We count the votes for each label on all sources 
        def count_fun(x):
            return np.bincount(x[x>=0], minlength=len(self.observed_labels)) 
        
        label_votes = np.apply_along_axis(count_fun, 1, obs.values).astype(np.float32)
        out_label_votes = label_votes.dot(self._get_vote_matrix())
        relevant_rows = (out_label_votes.sum(axis=1) > 0.0)
        

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…