python - Linear Regression using Scikit-learn vs Statsmodels -


i wanted check if multiple linear regression problem produced same output when solved using scikit-learn , statsmodels.api. did in 3 sections (in order of mention): statsmodels(without intercept), statsmodels(with intercept) , skl. expected, skl coefficients , r(square) same of statsmodels(with intercept) skl mean square error equivalent of statsmodels(without intercept).

i going share notebook code; it's basic piece of code, since have started machine learning applications. please go through , tell me why happening. also, if share insights on inefficient piece of code, thankful. here's code:

https://github.com/vgoel60/linear-regression-using-sklearn-vs-statsmodel.api/blob/master/linear%20regression%20boston%20housing%20prices%20using%20scikit-learn%20and%20statsmodels.api.ipynb

you made mistake, explains strange results. when make predictions linear model scikit-learn, write:

predictions2 = lm.predict(xtest2) 

notice using lm model, 1 resulting first statsmodels regression. instead, should have written:

predictions2 = lm2.predict(xtest2) 

when this, results expected.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -