From b048f52fe8191f72409989ca89f65f9b808ea5e3 Mon Sep 17 00:00:00 2001 From: Joaquin Torres Bravo Date: Wed, 5 Jun 2024 17:22:21 +0200 Subject: [PATCH] Deleted old files --- .../fixing_fp_fn/fixing_metrics.py | 40 ------------------- .../fixing_fp_fn/fixing_test_results.py | 30 -------------- 2 files changed, 70 deletions(-) delete mode 100644 model_selection/fixing_fp_fn/fixing_metrics.py delete mode 100644 model_selection/fixing_fp_fn/fixing_test_results.py diff --git a/model_selection/fixing_fp_fn/fixing_metrics.py b/model_selection/fixing_fp_fn/fixing_metrics.py deleted file mode 100644 index 604c964..0000000 --- a/model_selection/fixing_fp_fn/fixing_metrics.py +++ /dev/null @@ -1,40 +0,0 @@ -import pandas as pd - -def swap_fp_fn_rows(excel_path, output_path): - # Load the Excel file - excel_data = pd.ExcelFile(excel_path) - - # Create a Pandas ExcelWriter using the xlsxwriter engine - with pd.ExcelWriter(output_path, engine='xlsxwriter') as writer: - # Iterate through each sheet in the Excel file - for sheet_name in excel_data.sheet_names: - # Read the current sheet into a DataFrame, setting the first column as the index - df = excel_data.parse(sheet_name, index_col=0) - - # Convert index to string if it's not already to handle string operations - df.index = df.index.map(str) - - # Identify all rows containing 'FP' and 'FN' for swapping - fp_rows = df.filter(like='_FP', axis=0) - fn_rows = df.filter(like='_FN', axis=0) - - # Swap values between FP and FN rows for each corresponding pair - for fp_index, fn_index in zip(fp_rows.index, fn_rows.index): - # Temporary store FN row - temp = df.loc[fn_index].copy() - # Swap rows - df.loc[fn_index] = df.loc[fp_index] - df.loc[fp_index] = temp - - # Write the modified DataFrame back to the Excel file without adding an index column - df.to_excel(writer, sheet_name=sheet_name, index=True, index_label=None) - - print(f"Swapped FP and FN rows in '{excel_path}' and saved to '{output_path}'.") - -# Path to your existing Excel file -input_excel_path = '../output_cv_metrics/metrics.xlsx' -# Path where the modified Excel file will be saved -output_excel_path = '../output_cv_metrics/metrics_fixed.xlsx' - -# Call the function -swap_fp_fn_rows(input_excel_path, output_excel_path) diff --git a/model_selection/fixing_fp_fn/fixing_test_results.py b/model_selection/fixing_fp_fn/fixing_test_results.py deleted file mode 100644 index edf945c..0000000 --- a/model_selection/fixing_fp_fn/fixing_test_results.py +++ /dev/null @@ -1,30 +0,0 @@ -import pandas as pd - -def swap_fp_fn(excel_path, output_path): - # Load the Excel file - excel_data = pd.ExcelFile(excel_path) - - # Create a Pandas ExcelWriter using openpyxl engine - with pd.ExcelWriter(output_path, engine='openpyxl') as writer: - # Iterate through each sheet in the Excel file - for sheet_name in excel_data.sheet_names: - # Read the sheet into a DataFrame - df = excel_data.parse(sheet_name) - - # Check if the columns 'FP' and 'FN' exist in the DataFrame - if 'FP' in df.columns and 'FN' in df.columns: - # Swap the 'FP' and 'FN' columns - df['FP'], df['FN'] = df['FN'].copy(), df['FP'].copy() - - # Save the modified DataFrame back to the sheet in the new Excel file - df.to_excel(writer, sheet_name=sheet_name, index=False) - - print(f"Swapped FP and FN columns in '{excel_path}' and saved to '{output_path}'.") - -# Path to your existing Excel file -input_excel_path = '../output_test/testing_tuned_models.xlsx' -# Path where the modified Excel file will be saved (can be the same as input_excel_path) -output_excel_path = '../output_test/testing_tuned_models_fixed.xlsx' - -# Call the function with the file paths -swap_fp_fn(input_excel_path, output_excel_path) \ No newline at end of file -- 2.24.1