I created logistic regression model, however my data is very imbalanced (92% vs 7%) so I created both balanced and imbalanced version using sklearn. For my version on the left, I used:
clf = LogisticRegression()
for my weight-balanced version (on the right) I did:
clf = LogisticRegression(class_weight='balanced')
When trying to calculate their Odds ratio, I encountered a confusing discovery that both of them have coefficient and interecept of 0 (or incredibly close to it compare to other models with similar data) while their Odds ratio is 1. Is there a specific reason?
Edit (MRE for left hand graph):
from sklearn.linear_model import LogisticRegression
from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split
import matplotlib.pyplot as plt
from sklearn.metrics import classification_report
X_train, X_test, y_train, y_test = train_test_split(X, y,
test_size=0.2, random_state=0)
# fit the logistic regression model to the training data
clf = LogisticRegression()
clf.fit(X_train, y_train)
# predict the labels for the test set
y_pred = clf.predict(X_test)
# plot the data points
plt.scatter(X_train, y_train)
# plot the logistic regression line
plt.plot(x_range, y_range, color='red')
plt.ylabel(y_var)
plt.title(x_var)
plt.show()
print(f"\n Coefficient: {clf.coef_[0][0]} Intercept: {clf.intercept_[0]}\n\n Odds Ratio (OR): {np.exp(clf.coef_)[0][0].round(3)}")

