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

class_weight of type log produces 0.0 weight on most frequent class #181

Closed
Guillermogsjc opened this issue Oct 30, 2018 · 2 comments
Closed

Comments

@Guillermogsjc
Copy link
Contributor

Guillermogsjc commented Oct 30, 2018

This makes that training ignores the most frequent class.

Reproduce example:

`import numpy
import pandas
from finetune.imbalance import compute_class_weights

np.random.seed(0)
y = pd.Series(np.random.choice(a=[0, 1, 2], size=1000, p=[0.3, 0.6, 0.1]))
print(y.value_counts(normalize=True))
print(compute_class_weights('log', y))`

@madisonmay
Copy link
Contributor

Good catch, will have to think of a proper way to resolve this. Simply adding one may be sufficient as this is a relatively simple heuristic, but need to give it a bit of thought.

@madisonmay
Copy link
Contributor

I've opted to go for the adding 1 option in PR #183 -- I was just looking for a relatively soft re-weighting option when I added this in, and that should satisfy that requirement. Will be in the development shortly and available as part of the next release (0.5.12). Thanks again for the bug report @Guillermogsjc

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

No branches or pull requests

2 participants