Skip to content

Instantly share code, notes, and snippets.

@liannewriting
Created October 13, 2021 17:24
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 liannewriting/09aae60b251b8623e02db6c6e87a7426 to your computer and use it in GitHub Desktop.
Save liannewriting/09aae60b251b8623e02db6c6e87a7426 to your computer and use it in GitHub Desktop.
python imbalanced data machine learning classification
from sklearn.utils import compute_class_weight
weights = compute_class_weight('balanced', classes=df_train['Class'].unique(), y=df_train['Class'])
weights
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment