DEV Community

Nilotpal Choudhury
Nilotpal Choudhury

Posted on

Answer: Finding coefficients for logistic regression in python

The statsmodels library would give you a breakdown of the coefficient results, as well as the associated p-values to determine their significance.

Using an example of x1 and y1 variables:

x1_train, x1_test, y1_train, y1_test = train_test_split(x1, y1, random_state=0)

logreg = LogisticRegression().fit(x1_train,y1_train)
logreg

print("Training set score: {:.3f}".format(logreg.score(x1_train,y1_train)))
print("Test set score: {:.3f}".format(logreg.score(x1_test,y1_test)))

Top comments (0)