Skip to content

Commit

Permalink
add function to print model group summary
Browse files Browse the repository at this point in the history
  • Loading branch information
KasunAmare committed Dec 21, 2023
1 parent 7b5fb5f commit 35955dd
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/triage/component/postmodeling/report_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ def display_model_groups(self):
print(m)

return all_models

def print_model_summary(self):
''' This is mostly to be used as a key for modeling report plots (just as a model group number to model group mapping)'''
data_dict = []
for mg in self.model_groups:
for train_end_time in self.models[mg]:
model_analyzer = self.models[mg][train_end_time]
data_dict.append([mg, train_end_time, model_analyzer.model_id, model_analyzer.model_type, model_analyzer.hyperparameters])

all_models = pd.DataFrame(data_dict, columns=['model_group_id', 'train_end_time', 'model_id', 'model_type', 'hyperparameters'])
# to_print = all_models.groupby('model_group_id').nth(1)[['model_type', 'hyperparameters']].reset_index().to_dict(orient='records')

for i, model in all_models.groupby('model_group_id').nth(1)[['model_type', 'hyperparameters']].reset_index().iterrows():
print(f"{model['model_group_id']} - {model['model_type']} with ({model['hyperparameters']}) ")

def cohort_summary(self):
q = f"""
Expand Down Expand Up @@ -549,11 +563,13 @@ def _pairwise_list_comparison_single_fold(self, threshold_type, threshold, train
# Initializing three data frames to hold pairwise metrics
for m in metrics:
results[m] = pd.DataFrame(index=sorted(self.model_groups), columns=sorted(self.model_groups))

results[m].values[[np.arange(results[m].shape[0])]*2] = 1

for model_group_pair in pairs:
logging.info(f'Comparing {model_group_pair[0]} and {model_group_pair[1]}')

model_group_pair = sorted(model_group_pair)

df1 = lists[model_group_pair[0]]
df2 = lists[model_group_pair[1]]

Expand Down

0 comments on commit 35955dd

Please sign in to comment.