2

If I perform a linear regression in R, I get a nice summary of the resulting model, $R^2$, p-values for different features, etc.

If I do the same in scikit_learn, I get nothing of this. Are there any ways to print summary of the model there?

Konstantin Solomatov
  • 10,252
  • 8
  • 58
  • 88
  • possible duplicate of http://stackoverflow.com/questions/26319259/sci-kit-and-regression-summary/26326883#26326883 – eickenberg Oct 15 '15 at 14:27
  • 2
    as a general comment: scikit-learn is for machine learning, not for performing classical statistics. It is predictive power of the model that counts, not statistical significance. Totally useless predictive models can be statistically significant. – eickenberg Oct 15 '15 at 14:29

1 Answers1

6

Scikit-learn does not, to my knowledge, have a summary function like R. However, statmodels, another Python package, does. Plus, it's implementation is much more similar to R.

from statsmodels.formula.api  import ols
#you need a Pandas dataframe df with columns labeled Y, X, & X2
est = ols(formula = 'Y ~  X + X2', data = df).fit()
est.summary()
ansonw
  • 1,559
  • 1
  • 16
  • 22