def evaluate_endtoend_identification(training = False, num_folds = 10, fcn_filters = 128, augm = False, augm_type=AugmentationType.RND): model_name = generate_model_name(representation_type=RepresentationType.EE, fcn_filters = fcn_filters, augm = augm, augm_type = augm_type) if training == True: df_idnet = pd.read_csv("input_csv_gait/idnet_raw.csv", header = None) if augm == True: df_idnet = get_augmented_dataset(df_idnet, augm_type) df_idnet = normalize_rows( df_idnet, st.NormalizationType.ZSCORE) train_model(df_idnet, model_name, fcn_filters = fcn_filters, representation_learning=True) df1 = pd.read_csv("input_csv_gait/zju_session1_frames_raw.csv", header = None) df2 = pd.read_csv("input_csv_gait/zju_session2_frames_raw.csv", header = None) df1 = normalize_rows( df1, st.NormalizationType.ZSCORE) df2 = normalize_rows( df2, st.NormalizationType.ZSCORE) features1 = get_model_output_features( df1, model_name) features2 = get_model_output_features( df2, model_name) print("\nSession 1") evaluate_identification_CV(features1, num_folds = num_folds) print("\nSession 2") evaluate_identification_CV(features2, num_folds = num_folds) print("\nCross-Session")
def evaluate_endtoend_identification(training=False, augm=False, augm_type=AugmentationType.RND): if augm == True: if augm_type == AugmentationType.RND: model_name = "gait_fcn_rnd.h5" else: model_name = "gait_fcn_cshift.h5" else: model_name = "gait_fcn.h5" if training == True: df_idnet = pd.read_csv("input_csv/idnet.csv", header=None) if augm == True: df_idnet = get_augmented_dataset(df_idnet, augm_type) df_idnet = normalize_rows(df_idnet, st.NormalizationType.ZSCORE) train_model(df_idnet, model_name) df1 = pd.read_csv("input_csv/zju_session1_frames_raw.csv", header=None) df2 = pd.read_csv("input_csv/zju_session2_frames_raw.csv", header=None) df1 = normalize_rows(df1, st.NormalizationType.ZSCORE) df2 = normalize_rows(df2, st.NormalizationType.ZSCORE) features1 = get_model_output_features(df1, model_name) features2 = get_model_output_features(df2, model_name) evaluate_identification_CV(features1, num_folds=10) evaluate_identification_CV(features2, num_folds=10) evaluate_identification_Train_Test(features1, features2)
def verification_block_traintest(users_eval, num_blocks=1, verbose=False): df1 = pd.read_csv("input_csv_mouse/sapimouse_" + raw_data_type.value + "_3min.csv") df2 = pd.read_csv("input_csv_mouse/sapimouse_" + raw_data_type.value + "_1min.csv") df1 = normalize_rows(df1, st.NormalizationType.ZSCORE) df2 = normalize_rows(df2, st.NormalizationType.ZSCORE) df1_eval = df1.loc[df1.iloc[:, -1].isin(users_eval)] df2_eval = df2.loc[df2.iloc[:, -1].isin(users_eval)] # Feature extraction df1_eval_features = get_model_output_features(df1_eval, model_name) df2_eval_features = get_model_output_features(df2_eval, model_name) # Authentication roc_data_filename2 = 'results/roc_' + str(num_blocks) + '.csv' evaluate_authentication_train_test(df1_eval_features, df2_eval_features, data_type, num_blocks, representation_type, verbose=verbose, roc_data=True, roc_data_filename=roc_data_filename2) # plot ROC title = 'ROC curve ' + str(data_type.value) + '_' + str( raw_data_type.value) plot_ROC_single(roc_data_filename2, title=title)
def evaluate_raw_authentication(training=False, verbose=False, filename='results/raw_scores.csv'): df1 = pd.read_csv("input_csv/zju_session1_frames_raw.csv", header=None) df2 = pd.read_csv("input_csv/zju_session2_frames_raw.csv", header=None) df1 = normalize_rows(df1, st.NormalizationType.ZSCORE) df2 = normalize_rows(df2, st.NormalizationType.ZSCORE) features1 = df1 features2 = df2 auc1, eer1 = evaluate_authentication(features1, verbose) auc2, eer2 = evaluate_authentication(features2, verbose) auc_cross, eer_cross = evaluate_authentication_cross_day( features1, features2, verbose) # dictionary of lists dict = { 'AUC1': auc1, 'EER1': eer1, 'AUC2': auc2, 'EER2': eer2, 'AUC_cross': auc_cross, 'EER_cross': eer_cross } df = pd.DataFrame(dict) df.to_csv(filename, index=False)
def evaluate_raw_identification(): df1 = pd.read_csv("input_csv/zju_session1_frames_raw.csv", header=None) df2 = pd.read_csv("input_csv/zju_session2_frames_raw.csv", header=None) df1 = normalize_rows(df1, st.NormalizationType.ZSCORE) df2 = normalize_rows(df2, st.NormalizationType.ZSCORE) evaluate_identification_CV(df1, num_folds=10) evaluate_identification_CV(df2, num_folds=10) evaluate_identification_Train_Test(df1, df2)
def evaluate_raw_authentication(verbose=False, filename='results/raw_scores.csv'): representation_type = RepresentationType.RAW df1 = pd.read_csv("input_csv_gait/zju_session1_frames_raw.csv", header=None) df2 = pd.read_csv("input_csv_gait/zju_session2_frames_raw.csv", header=None) df1 = normalize_rows(df1, st.NormalizationType.ZSCORE) df2 = normalize_rows(df2, st.NormalizationType.ZSCORE) features1 = df1 features2 = df2 roc_data_filename = 'results/roc_session1_' + str( representation_type.value) + '_' + str(data_type.value) + '.csv' auc1, eer1 = evaluate_authentication(features1, data_type, representation_type, verbose=verbose, roc_data=True, roc_data_filename=roc_data_filename) roc_data_filename = 'results/roc_session2_' + str( representation_type.value) + '_' + str(data_type.value) + '.csv' auc2, eer2 = evaluate_authentication(features1, data_type, representation_type, verbose=verbose, roc_data=True, roc_data_filename=roc_data_filename) roc_data_filename = 'results/roc_cross_session_' + str( representation_type.value) + '_' + str(data_type.value) + '.csv' auc_cross, eer_cross = evaluate_authentication_cross_day( features1, features2, data_type, representation_type, verbose=verbose, roc_data=True, roc_data_filename=roc_data_filename) scores_filename = 'results/auc_eer_users_' + str( representation_type.value) + '_' + str(data_type.value) + '.csv' dict = { 'AUC1': auc1, 'EER1': eer1, 'AUC2': auc2, 'EER2': eer2, 'AUC_cross': auc_cross, 'EER_cross': eer_cross } df = pd.DataFrame(dict) df.to_csv(scores_filename, index=False)
def evaluate_raw_identification(num_folds = 10): df1 = pd.read_csv("input_csv_gait/zju_session1_frames_raw.csv", header = None) df2 = pd.read_csv("input_csv_gait/zju_session2_frames_raw.csv", header = None) df1 = normalize_rows( df1, st.NormalizationType.ZSCORE) df2 = normalize_rows( df2, st.NormalizationType.ZSCORE) print("\nSession 1") evaluate_identification_CV(df1, num_folds = num_folds) print("\nSession 2") evaluate_identification_CV(df2, num_folds = num_folds) print("\nCross-Session") evaluate_identification_Train_Test(df1, df2)
def evaluate_authentication_session2(augm=False, verbose=False, augm_type=AugmentationType.RND): # RAW df1 = pd.read_csv("input_csv_gait/zju_session2_frames_raw.csv", header=None) df1 = normalize_rows(df1, st.NormalizationType.ZSCORE) representation_type = RepresentationType.RAW roc_data_filename1 = 'results/roc_session2_' + str( representation_type.value) + '_' + str(data_type.value) + '.csv' evaluate_authentication(df1, data_type, representation_type, verbose, roc_data=True, roc_data_filename=roc_data_filename1) # AE representation_type = RepresentationType.AE fcn_filters = 128 model_name = generate_model_name(representation_type=RepresentationType.AE, fcn_filters=fcn_filters, augm=augm, augm_type=augm_type) encoder_name = "encoder_" + model_name features1 = get_autoencoder_output_features(df1, encoder_name) roc_data_filename2 = 'results/roc_session2_' + str( representation_type.value) + '_' + str(data_type.value) + '.csv' evaluate_authentication(features1, data_type, representation_type, verbose, roc_data=True, roc_data_filename=roc_data_filename2) # EE representation_type = RepresentationType.EE model_name = generate_model_name(representation_type=RepresentationType.EE, fcn_filters=fcn_filters, augm=augm, augm_type=augm_type) features1 = get_model_output_features(df1, model_name) roc_data_filename3 = 'results/roc_session2_' + str( representation_type.value) + '_' + str(data_type.value) + '.csv' evaluate_authentication(features1, data_type, representation_type, verbose, roc_data=True, roc_data_filename=roc_data_filename3) # plot ROC roc_filename = 'Same-day evaluation: session2' title = 'ROC curve ' + str(data_type.value) plot_ROCs(roc_data_filename1, roc_data_filename2, roc_data_filename3, title=title, outputfilename=roc_filename)
def generate_features(augm, augm_type): if augm == True: if augm_type == AugmentationType.RND: model_name_endtoend = "gait_fcn_rnd.h5" model_name_autoencoder = 'encoder_gait_autoencoder_fcn_rnd.h5' else: model_name_endtoend = "gait_fcn_cshift.h5" model_name_autoencoder = 'encoder_gait_autoencoder_fcn_cshift.h5' else: model_name_endtoend = 'gait_fcn.h5' model_name_autoencoder = 'encoder_gait_autoencoder_fcn.h5' df = pd.read_csv("input_csv/zju_session0_frames_raw.csv", header=None) df = normalize_rows(df, st.NormalizationType.ZSCORE) # df.to_csv('output_csv/session0_raw.csv', index=False) features_endtoend = get_model_output_features(df, model_name_endtoend) features_endtoend.to_csv('output_csv/session0_endtoend' + '_' + augm_type.value + '.csv', index=False) faetures_autoencoder = get_autoencoder_output_features( df, model_name_autoencoder) faetures_autoencoder.to_csv('output_csv/session0_autoencoder' + '_' + augm_type.value + '.csv', index=False)
def evaluate_autoencoder_authentication( training=False, augm=False, augm_type=AugmentationType.RND, verbose=False, filename='results/autoencoder_scores.csv'): if augm == True: if augm_type == AugmentationType.RND: model_name = "gait_autoencoder_fcn_rnd.h5" else: model_name = "gait_autoencoder_fcn_cshift.h5" else: model_name = "gait_autoencoder_fcn.h5" if training == True: df_idnet = pd.read_csv("input_csv/idnet.csv", header=None) df_idnet = normalize_rows(df_idnet, st.NormalizationType.ZSCORE) if augm == True: df_idnet = get_augmented_dataset(df_idnet, augm_type) train_autoencoder(df_idnet, model_name=model_name, num_epochs=100) encoder_name = "encoder_" + model_name df1 = pd.read_csv("input_csv/zju_session1_frames_raw.csv", header=None) df2 = pd.read_csv("input_csv/zju_session2_frames_raw.csv", header=None) df1 = normalize_rows(df1, st.NormalizationType.ZSCORE) df2 = normalize_rows(df2, st.NormalizationType.ZSCORE) features1 = get_autoencoder_output_features(df1, encoder_name) features2 = get_autoencoder_output_features(df2, encoder_name) auc1, eer1 = evaluate_authentication(features1, verbose) auc2, eer2 = evaluate_authentication(features2, verbose) auc_cross, eer_cross = evaluate_authentication_cross_day( features1, features2, verbose) # dictionary of lists dict = { 'AUC1': auc1, 'EER1': eer1, 'AUC2': auc2, 'EER2': eer2, 'AUC_cross': auc_cross, 'EER_cross': eer_cross } df = pd.DataFrame(dict) df.to_csv(filename, index=False)
def train_feature_extractor(): df1 = pd.read_csv("input_csv_mouse/sapimouse_" + raw_data_type.value + "_3min.csv") df2 = pd.read_csv("input_csv_mouse/sapimouse_" + raw_data_type.value + "_1min.csv") df1 = normalize_rows(df1, st.NormalizationType.ZSCORE) df2 = normalize_rows(df2, st.NormalizationType.ZSCORE) users_train = [x for x in range(1, 73)] df1_train = df1.loc[df1.iloc[:, -1].isin([x for x in users_train])] df2_train = df2.loc[df2.iloc[:, -1].isin([x for x in users_train])] frames = [df1_train, df2_train] df_train = pd.concat(frames) train_model(df_train, model_name, num_filters, representation_learning=True)
def evaluate_autoencoder_authentication( training=False, fcn_filters=128, augm=False, augm_type=AugmentationType.RND, verbose=False, filename='results/autoencoder_scores.csv'): representation_type = RepresentationType.AE model_name = generate_model_name(representation_type, fcn_filters=fcn_filters, augm=augm, augm_type=augm_type) if training == True: df_idnet = pd.read_csv("input_csv_gait/idnet_raw.csv", header=None) df_idnet = normalize_rows(df_idnet, st.NormalizationType.ZSCORE) if augm == True: df_idnet = get_augmented_dataset(df_idnet, augm_type) train_autoencoder(df_idnet, model_name=model_name, fcn_filters=fcn_filters) encoder_name = "encoder_" + model_name df1 = pd.read_csv("input_csv_gait/zju_session1_frames_raw.csv", header=None) df2 = pd.read_csv("input_csv_gait/zju_session2_frames_raw.csv", header=None) df1 = normalize_rows(df1, st.NormalizationType.ZSCORE) df2 = normalize_rows(df2, st.NormalizationType.ZSCORE) features1 = get_autoencoder_output_features(df1, encoder_name) features2 = get_autoencoder_output_features(df2, encoder_name) roc_data_filename = 'results/roc_session1_' + str( representation_type.value) + '_' + str(data_type.value) + '.csv' auc1, eer1 = evaluate_authentication(features1, data_type, representation_type, verbose=verbose, roc_data=True, roc_data_filename=roc_data_filename) roc_data_filename = 'results/roc_session2_' + str( representation_type.value) + '_' + str(data_type.value) + '.csv' auc2, eer2 = evaluate_authentication(features1, data_type, representation_type, verbose=verbose, roc_data=True, roc_data_filename=roc_data_filename) roc_data_filename = 'results/roc_cross_session_' + str( representation_type.value) + '_' + str(data_type.value) + '.csv' auc_cross, eer_cross = evaluate_authentication_cross_day( features1, features2, data_type, representation_type, verbose=verbose, roc_data=True, roc_data_filename=roc_data_filename) scores_filename = 'results/auc_eer_users_' + str( representation_type.value) + '_' + str(data_type.value) + '.csv' dict = { 'AUC1': auc1, 'EER1': eer1, 'AUC2': auc2, 'EER2': eer2, 'AUC_cross': auc_cross, 'EER_cross': eer_cross } df = pd.DataFrame(dict) df.to_csv(scores_filename, index=False)