Commit df047659 authored by Joaquin Torres's avatar Joaquin Torres

tuning PRE over

parent a2af199b
......@@ -143,17 +143,17 @@ if __name__ == "__main__":
# Store each df as a sheet in an excel file
sheets_dict = {}
for i, group in enumerate(['pre']):
for j, method in enumerate(['']): #['', '', 'over_', 'under_']
for j, method in enumerate(['over_']): #['', '', 'over_', 'under_']
# Get dataset based on group and method
X = data_dic['X_train_' + method + group]
y = data_dic['y_train_' + method + group]
# Use group of models with class weight if needed
# models = models_CS if j == 2 else models_simple
models = models_CS
models = models_simple
# 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(f"{group}-{method_names[1]}-{model_name}")
print(f"{group}-{method_names[2]}-{model_name}")
# Find optimal hyperparams for curr model
params = hyperparameters[model_name]
search = RandomizedSearchCV(model, param_distributions=params, cv=cv, n_jobs=8, scoring='precision')
......@@ -166,7 +166,7 @@ if __name__ == "__main__":
sheets_dict[sheet_name] = hyperparam_df
# Write results to Excel file
with pd.ExcelWriter('./output/hyperparam_pre_CS.xlsx') as writer:
with pd.ExcelWriter('./output/hyperparam_pre_OVER.xlsx') as writer:
for sheet_name, data in sheets_dict.items():
data.to_excel(writer, sheet_name=sheet_name)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment