def setUp(self): week0 = Instance(label=['Hot', 'Cold', 'Hot', 'Cold'], data=['good', 'bad', 'good', 'bad']) week1 = Instance(label=['Cold', 'Cold', 'Cold'], data=['good', 'bad', 'bad']) week2 = Instance(label=['Hot', 'Hot', 'Hot'], data=['good', 'good', 'good']) self.training_set = [week0, week1, week2] hmm = HMM() hmm.populate_alphabets(self.training_set) hot_index = hmm.label_alphabet.get_index('Hot') cold_index = hmm.label_alphabet.get_index('Cold') good_index = hmm.feature_alphabet.get_index('good') bad_index = hmm.feature_alphabet.get_index('bad') hmm.initial_probability = numpy.array([1, 1]) #if the week starts out hot, it must stay hot. If cold, stay cold # HHH and CCC are allowed hmm.transition_matrix[hot_index, cold_index] = 0 hmm.transition_matrix[hot_index, hot_index] = 1 - hmm.transition_matrix[hot_index, cold_index] hmm.transition_matrix[cold_index, hot_index] = 0 hmm.transition_matrix[cold_index, cold_index] = 1 - hmm.transition_matrix[cold_index, hot_index] hmm.emission_matrix[hot_index, good_index] = 0.75 hmm.emission_matrix[hot_index, bad_index] = 1 - hmm.emission_matrix[hot_index, good_index] hmm.emission_matrix[cold_index, good_index] = 0.50 hmm.emission_matrix[cold_index, bad_index] = 1 - hmm.emission_matrix[cold_index, good_index] self.hmm = hmm