Skip to content

Commit

Permalink
Order datasets by num classes
Browse files Browse the repository at this point in the history
  • Loading branch information
mariya committed Nov 12, 2024
1 parent b1fd715 commit 712759d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/conformist/prediction_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,10 @@ def visualize_class_counts_by_dataset(self):
if num_datasets == 1:
axs = [axs]

# Group by the first level of the index (dataset) and sum the values
grouped_ccs = ccs.groupby(level=0).sum()
# Group by the first level of the index (dataset) and count the number of unique classes
grouped_ccs = ccs.groupby(level=0).apply(lambda x: x.index.get_level_values(1).nunique())

# Order datasets by number of items
# Order datasets by number of unique classes
ordered_datasets = grouped_ccs.sort_values(ascending=False).index

# For each dataset, create a bar chart
Expand Down Expand Up @@ -244,6 +244,7 @@ def visualize_class_counts_by_dataset(self):

# Remove x-axis labels
axs[i].set_xticklabels([])
axs[i].set_xticks([])

# Add legend
if i == 0:
Expand Down

0 comments on commit 712759d

Please sign in to comment.