From bb7d817767c34127021885a3582d77548c663c32 Mon Sep 17 00:00:00 2001 From: Joaquin Torres Bravo Date: Wed, 8 May 2024 13:29:32 +0200 Subject: [PATCH] waiting for details to launch, preparing for shap --- models/hyperparam_tuning.py | 4 +--- models/shap.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 models/shap.py diff --git a/models/hyperparam_tuning.py b/models/hyperparam_tuning.py index e3e6238..311a718 100644 --- a/models/hyperparam_tuning.py +++ b/models/hyperparam_tuning.py @@ -152,9 +152,7 @@ if __name__ == "__main__": # Store each df as a sheet in an excel file sheets_dict = {} for i, group in enumerate(['pre', 'post']): - print(group, end = ' ') for j, method in enumerate(['', '', 'over_', 'under_']): - print(method, end = ' ') # Get dataset based on group and method X = data_dic['X_train_' + method + group] y = data_dic['y_train_' + method + group] @@ -163,7 +161,7 @@ if __name__ == "__main__": # Save results: params and best score for each of the mdodels of this method and group hyperparam_df = pd.DataFrame(index=list(models.keys()), columns=['Parameters','Score']) for model_name, model in models.items(): - print(model_name + "\n\n") + print(f"{group}-{method}-{model_name} \n\n") # Find optimal hyperparams for curr model params = hyperparameters[model_name] search = RandomizedSearchCV(model, param_distributions=params, cv=cv, n_jobs=1, scoring='precision') diff --git a/models/shap.py b/models/shap.py new file mode 100644 index 0000000..afca58d --- /dev/null +++ b/models/shap.py @@ -0,0 +1,10 @@ +# Libraries +# -------------------------------------------------------------------------------------------------------- +import shap +import numpy as np +# -------------------------------------------------------------------------------------------------------- + +# Load test data +X_test_pre = np.load('../gen_train_data/data/output/pre/X_test_pre.npy', allow_pickle=True) + +print(list(X_test_pre.columns.values)) \ No newline at end of file -- 2.24.1