def __call__(self, rlabels, hlabels):
        """

        Parameters
        ----------
        rlabels, hlabels : iterable
            Reference and hypothesis labels

        Returns
        -------
        counts : dict
        details : dict

        """

        # counts and details
        counts = {
            MATCH_CORRECT: 0,
            MATCH_CONFUSION: 0,
            MATCH_MISSED_DETECTION: 0,
            MATCH_FALSE_ALARM: 0,
            MATCH_TOTAL: 0
        }

        details = {
            MATCH_CORRECT: [],
            MATCH_CONFUSION: [],
            MATCH_MISSED_DETECTION: [],
            MATCH_FALSE_ALARM: []
        }

        NR = len(rlabels)
        NH = len(hlabels)
        N = max(NR, NH)

        # corner case
        if N == 0:
            return (counts, details)

        # this is to make sure rlables and hlabels are lists
        # as we will access them later by index
        rlabels = list(rlabels)
        hlabels = list(hlabels)

        # initialize match matrix
        # with True if labels match and False otherwise
        match = np.zeros((N, N), dtype=bool)
        for r, rlabel in enumerate(rlabels):
            for h, hlabel in enumerate(hlabels):
                match[r, h] = self.match(rlabel, hlabel)

        # find one-to-one mapping that maximize total number of matches
        # using the Hungarian algorithm
        mapping = self._munkres.compute(1 - match)

        # loop on matches
        for r, h in mapping:

            # hypothesis label is matched with unexisting reference label
            # ==> this is a false alarm
            if r >= NR:
                counts[MATCH_FALSE_ALARM] += 1
                details[MATCH_FALSE_ALARM].append(hlabels[h])

            # reference label is matched with unexisting hypothesis label
            # ==> this is a missed detection
            elif h >= NH:
                counts[MATCH_MISSED_DETECTION] += 1
                details[MATCH_MISSED_DETECTION].append(rlabels[r])

            # reference and hypothesis labels match
            # ==> this is a correct detection
            elif match[r, h]:
                counts[MATCH_CORRECT] += 1
                details[MATCH_CORRECT].append((rlabels[r], hlabels[h]))

            # refernece and hypothesis do not match
            # ==> this is a confusion
            else:
                counts[MATCH_CONFUSION] += 1
                details[MATCH_CONFUSION].append((rlabels[r], hlabels[h]))

        counts[MATCH_TOTAL] += NR

        # returns counts and details
        return (counts, details)
def __call__ ( self , rlabels , hlabels ) : counts = { MATCH_CORRECT : 0 , MATCH_CONFUSION : 0 , MATCH_MISSED_DETECTION : 0 , MATCH_FALSE_ALARM : 0 , MATCH_TOTAL : 0 } details = { MATCH_CORRECT : [ ] , MATCH_CONFUSION : [ ] , MATCH_MISSED_DETECTION : [ ] , MATCH_FALSE_ALARM : [ ] } NR = len ( rlabels ) NH = len ( hlabels ) N = max ( NR , NH ) if N == 0 : return ( counts , details ) rlabels = list ( rlabels ) hlabels = list ( hlabels ) match = np . zeros ( ( N , N ) , dtype = bool ) for r , rlabel in enumerate ( rlabels ) : for h , hlabel in enumerate ( hlabels ) : match [ r , h ] = self . match ( rlabel , hlabel ) mapping = self . _munkres . compute ( 1 - match ) for r , h in mapping : if r >= NR : counts [ MATCH_FALSE_ALARM ] += 1 details [ MATCH_FALSE_ALARM ] . append ( hlabels [ h ] ) elif h >= NH : counts [ MATCH_MISSED_DETECTION ] += 1 details [ MATCH_MISSED_DETECTION ] . append ( rlabels [ r ] ) elif match [ r , h ] : counts [ MATCH_CORRECT ] += 1 details [ MATCH_CORRECT ] . append ( ( rlabels [ r ] , hlabels [ h ] ) ) else : counts [ MATCH_CONFUSION ] += 1 details [ MATCH_CONFUSION ] . append ( ( rlabels [ r ] , hlabels [ h ] ) ) counts [ MATCH_TOTAL ] += NR return ( counts , details )
Parameters
        ----------
        rlabels, hlabels : iterable
            Reference and hypothesis labels

        Returns
        -------
        counts : dict
        details : dict