Skip to content

Commit

Permalink
opxrd/analyis: Fixed label_fractions table
Browse files Browse the repository at this point in the history
  • Loading branch information
Somerandomguy10111 committed Dec 23, 2024
1 parent b021334 commit 0667596
Show file tree
Hide file tree
Showing 2 changed files with 295 additions and 90 deletions.
6 changes: 2 additions & 4 deletions opxrd/analysis/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,14 @@ def show_label_fractions(self):
print_text(f'---> Overview of label fractions per contribution')
table_data = []
for d in self.databases:
table_data.append(len(d.patterns))

label_counts = {l: 0 for l in LabelType}
patterns = d.patterns
for l in LabelType:
for p in patterns:
if p.has_label(label_type=l):
label_counts[l] += 1
db_percentages = [label_counts[l] / len(patterns) for l in LabelType]
table_data.append(db_percentages)
row = [len(d.patterns)] + [label_counts[l] / len(patterns) for l in LabelType]
table_data.append(row)

col_headers = ['No. patterns'] + [label.name for label in LabelType]
row_headers = [db.name for db in self.databases]
Expand Down
379 changes: 293 additions & 86 deletions opxrd/plots.ipynb

Large diffs are not rendered by default.

0 comments on commit 0667596

Please sign in to comment.