Skip to content

Instantly share code, notes, and snippets.

@liannewriting
Created October 13, 2021 17:25
Show Gist options
  • Save liannewriting/0caab873a06531a229bb301226138cca to your computer and use it in GitHub Desktop.
Save liannewriting/0caab873a06531a229bb301226138cca to your computer and use it in GitHub Desktop.
python imbalanced data machine learning classification
from sklearn.linear_model import LogisticRegression
clf_weighted = LogisticRegression(class_weight='balanced', random_state=888)
clf_weighted.fit(df_train[features], df_train['Class'])
y_pred = clf_weighted.predict_proba(df_test[features])[:, 1]
from sklearn.metrics import roc_auc_score
roc_auc_score(df_test['Class'], y_pred)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment