def __compute_probabilityCheck2(self, matrix, items, base, hyper,blanketNew):
     """ Calculating posterior.
     
     Arguments:
     matrix -- transition or emission
     items -- (hypothesis, evidence)
     base -- base probability
     hyper -- hyperparameter
     """
     x = get_value(matrix, items[0], items[1], items[2])
     y = get_value(matrix, items[1], items[2])
     
     return (x + self.__check21(blanketNew)+self.__check42(blanketNew)+ hyper) / (y +self.__check22(blanketNew)+self.__check32(blanketNew)+ base *hyper)
    def __compute_probability(self, matrix, items, base, hyper):
        """ Calculating posterior.
        
        Arguments:
        matrix -- transition or emission
        items -- (hypothesis, evidence)
        base -- base probability
        hyper -- hyperparameter
        """
        x = get_value(matrix, items[0], items[1], items[2])
        y = get_value(matrix, items[1], items[2])

        return (x +hyper) / (y + base *  hyper)
Пример #3
0
    def __compute_probability(self, matrix, items, base, hyper):
        """ Calculating posterior.
        
        Arguments:
        matrix -- transition or emission
        items -- (hypothesis, evidence)
        base -- base probability
        hyper -- hyperparameter
        """
        x = get_value(matrix, items[0], items[1])
        y = get_value(matrix, items[1])

        return (x + base * hyper) / (y + hyper)
    def __compute_label_probabilities(self, blanket):
        """ Computes the probability of each label.
        
        Arguments:
        blanket -- Markov blanket
        """
        _, previous_previous_label,previous_label, following_label,following_following_label, current_observation = blanket
        # Probabilities of each possible label
        probabilities = []

        for label in range(self.labels):
            blanketNew=label,previous_previous_label,previous_label, following_label,following_following_label
            # Chain rule
            probability = (self.__compute_probability(self.transition,
                                                      (label,previous_previous_label, previous_label),
                                                      self.labels,
                                                      self.alpha) *
                           self.__compute_probabilityCheck1(self.transition,
                                                      (following_label,previous_label, label),
                                                      self.labels,
                                                      self.alpha,blanketNew) *
                           self.__compute_probabilityCheck2(self.transition,
                                                      (following_following_label, label,following_label),
                                                      self.labels,
                                                      self.alpha,blanketNew) *
                           self.__compute_probability1(self.emission,
                                                       (current_observation, label),
                                                      get_value(self.stemdict, current_observation),
                                                      self.beta))
                           
            probabilities.append(probability)
        return probabilities
Пример #5
0
 def Start(self, params):
     self.params = params
     self.tamount.SetValue("")
     self.tamount.SetFocus()
     self.params['fvalue'] = get_value()
     self.ftcvalue.SetLabel(str(self.params['fvalue']))
     self.Show()
Пример #6
0
 def __compute_probabilityUnigram(self, matrix, item, hyper):
     """ Calculating posterior.
     
     Arguments:
     matrix -- transition or emission
     items -- (hypothesis, evidence)
     base -- base probability
     hyper -- hyperparameter
     """
     y = self.wordcount
     x = get_value(matrix, item)
     z = len(set(self.stemlist))
     #        print(x,y,base)
     return (x + hyper) / (y + z * hyper)
Пример #7
0
    def set_variable_info(self, scope, variable, read_memory):
        """Set the result analyzed by the debugger in the instance variable

        Args:
            scope (str): Scope in the script to debug
            variable (SBValue): Variable infomation by LLDB
            read_memory (function): Look into the memory of the current process
        """
        memory_raw = read_memory(int(str(variable.GetLocation()), 16),
                                 variable.GetByteSize())
        self._address = str(variable.GetLocation())
        self._scope = scope
        self._name = variable.GetName()
        self._data = get_value(str(variable))
        self._raw = format_raw(memory_raw)
        self._type = variable.GetTypeName()