Пример #1
0
    # Find the mean across channels
    avg_trials = mr.average_trials(pro_trials)

    # concatenates the average trials dataframe with labels
    ml_df = mr.create_ml_df(avg_trials, labels)

    # train models
    X_train, X_test, y_train, y_test = mr.prepare_ml_df(ml_df)

    acc_svc, precision_svc = mr.train_svc_multi(X_train, X_test, y_train,
                                                y_test)

    acc_dtc, precision_dtc = mr.train_dtc_multi(X_train, X_test, y_train,
                                                y_test)

    acc_nb, precision_nb = mr.train_nb_multi(X_train, X_test, y_train, y_test)

    acc_nn, precision_nn = mr.train_nn_multi(64, X_train, X_test, y_train,
                                             y_test)

    # add every participant's precision together
    precision_list = [
        f"{precision_svc:.2f}", f"{precision_dtc:.2f}", f"{precision_nb:.2f}",
        f"{precision_nn:.2f}"
    ]

    df = mr.res_df(df, precision_list, participant)

# generate result .csv file
df.to_csv('case_4_precision.csv')
Пример #2
0
    # Go through each trial, reset the columns, we split from 100-300ms ((308th sample to 513th sample))
    # Increase window by 50ms each try
    pro_trials = mr.process_trials(trials, 250, 550)

    # Find the mean across channels
    avg_trials = mr.average_trials(pro_trials)

    # concatenates the average trials dataframe with labels
    ml_df = mr.create_ml_df(avg_trials, labels)

    # train models
    X_train, X_test, y_train, y_test = mr.prepare_ml_df(ml_df, scale=False)

    acc_svc, precision_svc = mr.train_svc(X_train, X_test, y_train, y_test)

    acc_dtc, precision_dtc = mr.train_dtc(X_train, X_test, y_train, y_test)

    acc_nb, precision_nb = mr.train_nb(X_train, X_test, y_train, y_test)

    acc_nn, precision_nn = mr.train_nn(64, X_train, X_test, y_train, y_test)

    # add every participant's accuracy together
    acc_list = [
        f"{acc_svc:.2f}", f"{acc_dtc:.2f}", f"{acc_nb:.2f}", f"{acc_nn:.2f}"
    ]

    df = mr.res_df(df, acc_list, participant)

# generate result .csv file
df.to_csv('cong_incong_accuracy.csv')