segmentation/bmoss/change_detec.py
def trim_hypotheses(self, minprob=1.0e-6, maxhypot=20):
        """Prune hypotheses to limit computational complexity.

        The computational complexity of the algorithm can be managed by
        limiting the number of hypotheses maintained. This method limits the
        number of hypotheses maintained by the model by:

            1) Removing any hypotheses with a support (probability) less than
               ``minprob``.

            2) Preserving the first ``maxhypot`` likely hypotheses and
               discarding the rest.

        """

        # Skip pruning if less hypotheses exist than the maximum allowed.
        if len(self.__hypotheses) <= maxhypot:
            return

        # Sort the hypotheses in decreasing log probability order.
        self.__hypotheses.sort(key=lambda dct: -dct['log_probability'])

        # Store the indices of likely hypotheses.
        minprob = np.log(minprob)
        index = [i for i, hypot in enumerate(self.__hypotheses)
                 if hypot['log_probability'] > minprob]

        # Trim the hypotheses.
        index = index[:maxhypot] if len(index) >= maxhypot else index
        self.__hypotheses = [self.__hypotheses[i] for i in index]

        # NOTE: This final ordering can preserve the original order of the
        #       hypotheses. Interestingly, the algorithm specified in update
        #       does not require that the hypotheses be ordered! This sort can
        #       safely be ignored.
        # self.__hypotheses.sort(key=lambda dct: dct['index'])

        # Normalize the hypotheses so that their probabilities sum to one.
        logsum = -np.inf
        for hypot in self.__hypotheses:
            logsum = self.__soft_max(logsum, hypot['log_probability'])
        for hypot in self.__hypotheses:
            hypot['log_probability'] -= logsum
Prune hypotheses to limit computational complexity.

        The computational complexity of the algorithm can be managed by
        limiting the number of hypotheses maintained. This method limits the
        number of hypotheses maintained by the model by:

            1) Removing any hypotheses with a support (probability) less than
               ``minprob``.

            2) Preserving the first ``maxhypot`` likely hypotheses and
               discarding the rest.

        
Prune hypotheses to limit computational complexity.
The computational complexity of the algorithm can be managed by
limiting the number of hypotheses maintained. This method limits the
number of hypotheses maintained by the model by.

1) Removing any hypotheses with a support (probability) less than
``minprob``.

2) Preserving the first ``maxhypot`` likely hypotheses and
discarding the rest.
Prune hypotheses to limit computational complexity . The computational complexity of the algorithm can be managed by limiting the number of hypotheses maintained . This method limits the number of hypotheses maintained by the model by . 1 ) Removing any hypotheses with a support ( probability ) less than ` ` minprob ` ` . 2 ) Preserving the first ` ` maxhypot ` ` likely hypotheses and discarding the rest .
def trim_hypotheses(self, minprob=1.0e-6, maxhypot=20):
        if len(self.__hypotheses) <= maxhypot:
            return
        self.__hypotheses.sort(key=lambda dct: -dct['log_probability'])
        minprob = np.log(minprob)
        index = [i for i, hypot in enumerate(self.__hypotheses)
                 if hypot['log_probability'] > minprob]
        index = index[:maxhypot] if len(index) >= maxhypot else index
        self.__hypotheses = [self.__hypotheses[i] for i in index]
        logsum = -np.inf
        for hypot in self.__hypotheses:
            logsum = self.__soft_max(logsum, hypot['log_probability'])
        for hypot in self.__hypotheses:
            hypot['log_probability'] -= logsum
def trim_hypotheses ( self , minprob = 1.0e-6 , maxhypot = 20 ) : if len ( self . __hypotheses ) <= maxhypot : return self . __hypotheses . sort ( key = lambda dct : - dct [ 'log_probability' ] ) minprob = np . log ( minprob ) index = [ i for i , hypot in enumerate ( self . __hypotheses ) if hypot [ 'log_probability' ] > minprob ] index = index [ : maxhypot ] if len ( index ) >= maxhypot else index self . __hypotheses = [ self . __hypotheses [ i ] for i in index ] logsum = - np . inf for hypot in self . __hypotheses : logsum = self . __soft_max ( logsum , hypot [ 'log_probability' ] ) for hypot in self . __hypotheses : hypot [ 'log_probability' ] -= logsum
Prune hypotheses to limit computational complexity.
Prune hypotheses to limit computational complexity .
"""Prune hypotheses to limit computational complexity.

        The computational complexity of the algorithm can be managed by
        limiting the number of hypotheses maintained. This method limits the
        number of hypotheses maintained by the model by:

            1) Removing any hypotheses with a support (probability) less than
               ``minprob``.

            2) Preserving the first ``maxhypot`` likely hypotheses and
               discarding the rest.

        """ # Skip pruning if less hypotheses exist than the maximum allowed. # Sort the hypotheses in decreasing log probability order. # Store the indices of likely hypotheses. # Trim the hypotheses. # NOTE: This final ordering can preserve the original order of the #       hypotheses. Interestingly, the algorithm specified in update #       does not require that the hypotheses be ordered! This sort can #       safely be ignored. # self.__hypotheses.sort(key=lambda dct: dct['index']) # Normalize the hypotheses so that their probabilities sum to one.
self
minprob
maxhypot