def test_get_random_hypothesis(self): self.configurations["EVOLVE_HMM"] = True self.configurations["EVOLVE_RULES"] = True self.initialise_segment_table("plural_english_segment_table.txt") data = ['kats', 'dogz', 'kat', 'dog'] rand_hypothesis = Hypothesis.get_random_hypothesis(data) log_hypothesis(rand_hypothesis)
def test_representative_random_hypothesis_rate(self): # Check how often random hypothesis represents the data self.initialise_segment_table("plural_english_segment_table.txt") data = ['kats', 'dogz', 'kat', 'dog'] total_hypotheses = 0 energy = float("inf") while energy == float("inf"): rand_hypothesis = Hypothesis.get_random_hypothesis(data) energy = rand_hypothesis.get_energy() log_hypothesis(rand_hypothesis) total_hypotheses += 1 print("Total hypotheses generated: ", total_hypotheses) print() log_hypothesis(rand_hypothesis)
def generate_population(self, population_size): return [ Hypothesis.get_random_hypothesis(self.simulation) for _ in range(population_size) ]