Skip to content

Instantly share code, notes, and snippets.

@MattLowrieDS
Created January 6, 2021 03:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MattLowrieDS/421498d8b93d677fc93c97c09366e07c to your computer and use it in GitHub Desktop.
Save MattLowrieDS/421498d8b93d677fc93c97c09366e07c to your computer and use it in GitHub Desktop.
lbl_vc = feature_label_df['labels'].value_counts()
total = lbl_vc.sum()
mu = 3.0
class_weights = {}
for i, k in enumerate(lbl_vc.keys()):
w = np.log(mu * total / float(lbl_vc[k]))
class_weights[i] = w if w > 1 else 1
print(class_weights)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment