test_set = tools.reduce_data_to_features(data_test, list_features, list_features_final) dim_features = np.ones(len(list_features_final)) print('DEBUG list of final features ', list_features_final) plt.plot(train_set[0][:, 3]) plt.show() # Training the model model = ModelHMM() model.train(train_set, labels_train, list_features_final, dim_features) # Testing the model pred_labels, proba = model.test_model(test_set) #debug sere #pred_labels, proba les ecrire dans un fichier F1_temp = [] for i in range(len(labels_test)): F1_temp.append( tools.compute_F1_score(labels_test[i], pred_labels[i], list_states[num_track])) F1_score.append(np.mean(F1_temp)) print(F1_score) if (flag_save): model.save_model(path_model, name_model, "load_handling_" + name_track)
transition_error = [] short_transition_error = 0 MCC = 0 F1_fisher = [] F1_wrapper = [] F1_f = [] F1_w = [] if (nbr_cross_val == 0): model = ModelHMM() model.train(data_win, real_labels, best_features, dim_features) if (save): model.save_model(path_model, name_model, "load_handling") for n_subject in range(len(list_participant)): data_reduce = deepcopy(data_win) labels_reduce = deepcopy(real_labels) if (test_generalisation): data_gen = [] labels_gen = [] seq_subject = 0 count = [] for i in range(len(info_participant)): if (info_participant[i] == list_participant[n_subject]): data_gen.append(data_win[i]) labels_gen.append(real_labels[i])
F1_f = [] F1_w = [] if (nbr_cross_val == 0): data_reduce = [] for data in data_win: df = pd.DataFrame(data) df.columns = list_features data_reduce.append(df[best_features_wrapper].values) data_ref, labels_ref, data_test, labels_test, id_train, id_test = tools.split_data_base2( data_reduce, real_labels, ratio) model = ModelHMM() model.train(data_ref, labels_ref, best_features_wrapper, dim_features) model.save_model('model', 'test_video_action', "load_handling") info_split = [] for seq, num_seq in zip(info_sequences, range(len(info_sequences))): if (num_seq in id_train): info_split.append('training') else: info_split.append('testing') df = pd.DataFrame({'Sequence': info_sequences, 'Base': info_split}) df.to_csv('model/test_video_action.csv', index=False) sys.exit("Shut down")