def determinerClassesParMethodeNaive(): ''' Utilisation d'une méthode naive pour estimer les classes ''' S = app.get_Pi_T_E() I = S[0] T = S[1] E = S[2] test_table = encodeTestAsMatrix3n() for index in range(len(test_table)): if test_table[index][0] != "": test_table[index][2] = getMaxEmission(E, test_table[index][0]) return test_table
def determinerClassesParMethodeNaive(): S = app.get_Pi_T_E() I = S[0] T = S[1] E = S[2] print T test_table = encodeTestAsMatrix3n() for index in range(len(test_table)): if test_table[index][0] != "": test_table[index][2] = getMaxEmission(E, test_table[index][0]) return test_table
def determinerClassesParMethodeNaive(): '''Déterminer la classe en utilisant une methode naive : prendre l'état dont la probabilité est maximale pour l'observable (on ne prends pas en compte les probabilités de transition''' S = app.get_Pi_T_E() I = S[0] T = S[1] E = S[2] print T test_table = encodeTestAsMatrix3n() for index in range(len(test_table)): if test_table[index][0] != "": test_table[index][2] = getMaxEmission(E, test_table[index][0]) return test_table
def determinerClassesParViterbi(): ''' Utilisation de Viterbi ''' S = app.get_Pi_T_E() I = S[0] T = S[1] E = S[2] test_table = encodeTestAsMatrix3n() reading_observable_initiale = True for index in range(len(test_table)): if test_table[index][0] != "": if reading_observable_initiale: reading_observable_initiale = False test_table[index][2] = get_classes_max_proba_initiales(I, E, test_table[index][0]) else: test_table[index][2] = get_class_max_proba_transition(I, T, E, test_table[index-1][1], test_table[index][0]) else: reading_observable_initiale = True return test_table
return T listState = encod.get_categories(data+"/voc_etats") listState.append("") test_table = encodeTestAsMatrix3n() listObservables = range(len(test_table)) for k in range(len(test_table)): listObservables[k] = test_table[k][0] ### On construit un hmm avec le fichier d'apprentissage ### S = app.get_Pi_T_E() I = S[0] T = S[1] E = S[2] if perturbation: for obs in listObservables: for state in listState: if obs in E and not state=="": E[obs][state]+=(random.random()-0.5)*coef ########################################################### hmm = HMM_BW(listObservables, listState, 1) if hmm_determine: hmm.Pi = I hmm.Pi[""] = 0.0 T[""] = hmm.Pi