Skip to content

Instantly share code, notes, and snippets.

@VincentTatan
Created May 9, 2020 12:50
Show Gist options
  • Save VincentTatan/2b1ea04a1e23e2500da5cd19803cb1ec to your computer and use it in GitHub Desktop.
Save VincentTatan/2b1ea04a1e23e2500da5cd19803cb1ec to your computer and use it in GitHub Desktop.
def create_logistic_regressions(X_train,y_train,figsize=(10,10)):
logreg = LogisticRegression(solver='lbfgs')
logreg.fit(X_train, y_train)
coefficients = logreg.coef_
intercept = logreg.intercept_
df_logreg = pd.DataFrame({'Feature':X_train.columns,'Coef':logreg.coef_[0]})
fig, ax = plt.subplots(figsize=figsize)
sns.barplot(x="Coef", y="Feature", data=df_logreg, ax=ax)
return logreg, df_logreg.set_index('Feature')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment