clf = commons.best_model # Run deep vs light unconsciousness print(f"Bootstrap: Graph {graph} at eml5_vs_emf5_step_{s}") bootstrap_filename = commons.OUTPUT_DIR + f"bootstrap/bootstrap_10000_Final_model_{graph}_eml5_vs_emf5_step_{s}.csv" boot_data = pd.DataFrame(np.zeros((1, 6))) names = ['epoch', 'graph', 'Acc_Dist Mean', 'Acc_Dist Std', 'acc_interval_low', 'acc_interval_high'] boot_data.columns = names c = 0 if graph != "both": print(f"MODE {graph}") print(f"FINAL Model Graph {graph} at emf5 vs eml5") X, y, group = filter_dataframe(graph, 'emf5', 'eml5', s) if graph == "both": print(f"MODE {graph}") print(f"FINAL Model Graph {graph} at emf5 vs eml5") X_pli, y_pli, group_pli = filter_dataframe('pli', 'emf5', 'eml5', s) X_aec, y_aec, group_aec = filter_dataframe('aec', 'emf5', 'eml5', s) X = np.hstack((X_aec, X_pli)) if np.array_equal(y_aec, y_pli): print("Y-values equal") y = y_aec if np.array_equal(group_aec, group_pli): print("group-values equal") group = group_aec #build pipeline with best model
# This will be given by the srun in the bash file # Get the argument EPOCHS = {"ind","emf5","eml5","ec8"} # to compare against baseline GRAPHS = ["aec", "pli", "both"] Steps = ['01', '10'] clf = commons.best_model for s in Steps: for graph in GRAPHS: for epoch in EPOCHS: final_acc_filename = commons.OUTPUT_DIR + f"final_models/FINAL_MODEL_{graph}_ec1_vs_{epoch}_step_{s}.pickle" if graph != "both": print(f"MODE {graph}") print(f"FINAL Model Graph {graph} at ec1 vs {epoch}") X, y, group = filter_dataframe(graph, 'ec1', epoch, s) if graph == "both": print(f"MODE {graph}") print(f"FINAL Model Graph {graph} at ec1 vs {epoch}") X_pli, y_pli, group_pli = filter_dataframe('pli', 'ec1', epoch, s) X_aec, y_aec, group_aec = filter_dataframe('aec', 'ec1', epoch, s) X = np.hstack((X_aec, X_pli)) if np.array_equal(y_aec, y_pli): print("Y-values equal") y = y_aec if np.array_equal(group_aec, group_pli): print("group-values equal") group = group_aec #build pipeline with best model
import commons from commons import load_pickle, find_best_model from commons import classify_loso_model_selection from commons import DummyEstimator, print_summary, filter_dataframe, search_space # Get the argument analysis_param = sys.argv[1] best_clf_filename = commons.OUTPUT_DIR + f'best_clf_{analysis_param}.pickle' # Parse the parameters (graph, epoch, feature_group) = analysis_param.split("_") print(f"Graph {graph} at ec1 vs {epoch} with feature {feature_group}") X, y, group = filter_dataframe(graph, epoch, feature_group) # Create a pipeline pipe = Pipeline([('imputer', SimpleImputer(missing_values=np.nan, strategy='mean')), ('scaler', StandardScaler()), ('clf', DummyEstimator())]) # Placeholder Estimator # We will use as many processor as possible for the gridsearch gs = GridSearchCV(pipe, search_space, cv=LeaveOneGroupOut(), n_jobs=-1) accuracies, f1s, cms, best_params = classify_loso_model_selection( X, y, group, gs) # Saving the performance metrics clf_data = {