From eeda7e736f61c1021e2b3f4a5b7c54a97556ff7c Mon Sep 17 00:00:00 2001 From: kasun Date: Mon, 8 Jan 2024 19:58:28 +0000 Subject: [PATCH] handle the case of list sizes not being equal in list comparison --- src/triage/component/postmodeling/report_generator.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/triage/component/postmodeling/report_generator.py b/src/triage/component/postmodeling/report_generator.py index 5adab4bed..cf4805109 100644 --- a/src/triage/component/postmodeling/report_generator.py +++ b/src/triage/component/postmodeling/report_generator.py @@ -592,7 +592,10 @@ def _pairwise_list_comparison_single_fold(self, threshold_type, threshold, train df2.sort_values('score', ascending=False, inplace=True) # only returning the corr coefficient, not the p-value - results['rank_corr'].loc[model_group_pair[0], model_group_pair[1]] = spearmanr(df1.entity_id.iloc[:], df2.entity_id.iloc[:])[0] + if len(df1) == len(df2): + results['rank_corr'].loc[model_group_pair[0], model_group_pair[1]] = spearmanr(df1.entity_id.iloc[:], df2.entity_id.iloc[:])[0] + else: + logging.warning(f'Not calculating rank correlation. List sizes are not equal ({len(df1)}, {len(df2)})') if plot: fig, axes = plt.subplots(1, len(metrics), figsize=(10, 3))