Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature balance #56

Merged
merged 10 commits into from
Feb 13, 2023
Merged

Feature balance #56

merged 10 commits into from
Feb 13, 2023

Conversation

lauritowal
Copy link
Collaborator

No description provided.

Copy link
Member

@norabelrose norabelrose left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost good to go, just two small requests

)
)

return concatenate_datasets(subsets).shuffle()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably support setting the shuffle seed here

self.labels, counts = np.unique(self.dataset[label_column], return_counts=True)
self.label_fracs = counts / counts.sum()

print(f"Class balance '{split}': {[f'{x:.2%}' for x in self.label_fracs]}")
if self.label_fracs[0] != self.label_fracs[1]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't robust in the case where len(self.label_fracs) > 2. You could instead do:

pivot, *rest = self.label_fracs
if not all(x == pivot for x in rest):
    print("Use arg --balance to force class balance")

It's also a little unclear if we want to print this for cases of near class balance, like 51% to 49% or something. But to keep the code simple I'm fine with doing this weird floating point equality thing for now.

Copy link
Member

@norabelrose norabelrose left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants