""" Plotting the distribution of the metrics obtained from cv via boxplots."""# Libraries# --------------------------------------------------------------------------------------------------------importpandasaspdimportmatplotlib.pyplotasplt# Corrected import# --------------------------------------------------------------------------------------------------------if__name__=="__main__":metric_names=['F1','PREC','REC','ACC','NREC','TN','FN','FP','TP','AUROC','AUPRC']model_names_simple=['DT','RF','Bagging','AB','XGB','LR','SVM','MLP']model_names_cs=['DT','RF','Bagging','AB','LR','SVM']# Distribution of cv metrics# --------------------------------------------------------------------------------------------------------forgroupin['pre','post']:formethodin['_ORIG','_ORIG_CW','_OVER','_UNDER']:# Read current sheet as dfdf=pd.read_excel('./output_cv_metrics/metrics.xlsx',sheet_name=group+method)# Model names based on cost-senstive training or notifmethod=='_ORIG_CW':model_names=model_names_cselse:model_names=model_names_simple# Create figure for current sheet, one row per metricfig,axes=plt.subplots(len(metric_names),1,figsize=(15,8*len(metric_names)))formetric_id,metric_nameinenumerate(metric_names):# Get the axis for the current metricax=axes[metric_id]formodel_nameinmodel_names:row_name=f'{model_name}_{metric_name}'# Collect data for the current model's metricmetric_row=df.loc[df['Unnamed: 0']==row_name].iloc[0,1:].valuesifgroup=='pre'andmethod=='_ORIG'andmetric_id==0andmodel_name=='DT':print(metric_row)# --------------------------------------------------------------------------------------------------------