9
model = LogisticRegression(random_state=0)
model.fit(X2, Y2)
Y2_prob=model.predict_proba(X2)[:,1]

I've built a logistic regression model on my training dataset X2 and Y2. Now is it possible for me to obtain the coefficients and p values from here? Because:

model.summary()

gives me:

AttributeError: 'LogisticRegression' object has no attribute 'summary'

Or can somebody help me suggest an alternative to obtain the important and significant features from this model? Any help will be appreciated. Thanks.

IndigoChild
  • 842
  • 3
  • 11
  • 29
  • Possible duplicate of [Find p-value (significance) in scikit-learn LinearRegression](https://stackoverflow.com/questions/27928275/find-p-value-significance-in-scikit-learn-linearregression) – Vivek Kumar Feb 16 '18 at 11:14

3 Answers3

6

No. Its not possible to get the p-values from here. You can get the coefficients however by using model.coef_. If you need the p-values you'll have to use the statsmodels package. See this if you want to modify the sklearn class to get the p-values

Clock Slave
  • 7,627
  • 15
  • 68
  • 109
0

You seem to be using an older model of LogisticRegression. model.summary2() should do the trick.

  • When I try this, I get `AttributeError: 'LogisticRegression' object has no attribute 'summary2'`. Can you clarify what version of sklearn you're using? – Rylan Schaeffer Dec 19 '20 at 18:59
  • summary2() method is available for LogitResults class in statsmodels.discrete.discrete_model module not for sklearn.linear_model.LogisticRegression. – Loochie May 05 '21 at 13:28
0

You can use the following statements to fix this problem. It worked in my case.

from scipy import stats stats.chisqprob = lambda chisq, df:stats.chi2.sf(chisq, df)