Commit 3a64c388 authored by Joaquin Torres's avatar Joaquin Torres

Paths updated model_selection

parent 941fd4ed
......@@ -272,15 +272,14 @@ if __name__ == "__main__":
# Store the fold scores in the dataframe
for metric_name, scores in fold_scores.items():
scores_df.loc[f"{model_name}_{metric_name}"] = np.around(scores, 4)
sheet_name = f"{group}_{method_names[j]}"
scores_sheets[sheet_name] = scores_df
# Adjust layout and save figure
plt.tight_layout()
plt.savefig(f'./output_cv_metrics/curves/{group}_{method_names[j]}.svg', format='svg', dpi=500)
plt.savefig(f'./output/cv_metrics/curves/{group}_{method_names[j]}.svg', format='svg', dpi=500)
plt.close(fig)
# Write results to Excel file
with pd.ExcelWriter('./output_cv_metrics/metrics.xlsx') as writer:
with pd.ExcelWriter('./output./cv_metrics/metrics.xlsx') as writer:
for sheet_name, data in scores_sheets.items():
data.to_excel(writer, sheet_name=sheet_name)
print("Successful cv metric generation for tuned models")
......
......@@ -44,7 +44,7 @@ if __name__ == "__main__":
if metric_name in ['F1', 'PREC', 'REC', 'ACC', 'AUROC', 'AUPRC']:
ax.set_ylim(0, 1)
plt.tight_layout()
fig.savefig(f'./output_cv_metrics/distributions/{group}{method}.svg', format='svg', dpi=600)
fig.savefig(f'./output/cv_metrics/distributions/{group}{method}.svg', format='svg', dpi=600)
plt.close(fig) # Close the figure to free up memory
print("Succesful distribution plots generation")
......
......@@ -159,7 +159,7 @@ if __name__ == "__main__":
sheets_dict[sheet_name] = hyperparam_df
# Write results to Excel file
with pd.ExcelWriter('./output_hyperparam/hyperparamers.xlsx') as writer:
with pd.ExcelWriter('./output/hyperparam/hyperparamers.xlsx') as writer:
for sheet_name, data in sheets_dict.items():
data.to_excel(writer, sheet_name=sheet_name)
......
......@@ -77,7 +77,7 @@ def read_data():
def get_tuned_models(group_str, method_str):
# Read sheet corresponding to group and method with tuned models and their hyperparam
tuned_models_df = pd.read_excel("./output_hyperparam/hyperparamers.xlsx",sheet_name=f"{group_str}_{method_str}")
tuned_models_df = pd.read_excel("./output/hyperparam/hyperparamers.xlsx",sheet_name=f"{group_str}_{method_str}")
# Mapping from model abbreviations to sklearn model classes
model_mapping = {
'DT': DecisionTreeClassifier,
......@@ -274,13 +274,13 @@ if __name__ == "__main__":
# ----------------------------------------------------------
# Adjust layout and save/show figure
plt.tight_layout()
plt.savefig(f'./output_test/plots/{group}_{method_names[j]}.svg', format='svg', dpi=500)
plt.savefig(f'./output/testing/plots/{group}_{method_names[j]}.svg', format='svg', dpi=500)
plt.close(fig)
# Store the DataFrame in the dictionary with a unique key for each sheet
sheet_name = f"{group}_{method_names[j]}"
scores_sheets[sheet_name] = scores_df
# Write results to Excel file
with pd.ExcelWriter('./output_test/testing_tuned_models.xlsx') as writer:
with pd.ExcelWriter('./output/testing/testing_tuned_models.xlsx') as writer:
for sheet_name, data in scores_sheets.items():
data.to_excel(writer, sheet_name=sheet_name)
print("Successful evaluation with test dataset")
......
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