The 365 Data Science team is proud to invite you to our own community forum. A very well built system to support your queries, questions and give the chance to show your knowledge and help others in their path of becoming Data Science specialists.
Ask
Anybody can ask a question
Answer
Anybody can answer
Vote
The best answers are voted up and moderated by our team

Properly including p values with sklearn using real estate data produces unexpected results

Properly including p values with sklearn using real estate data produces unexpected results

Super Learner
0
Votes
1
Answer

Hello,
I am doing the multiple linear regression exercise in the Machine Learning with Python module 
https://365datascience.teachable.com/courses/362812/lectures/10601392
This exercise uses the Real Estate dataset provided which contains price, size and year variables and the sklearn package.  As well as the univariate p values, I thought I would also calculate the p values properly with sklearn copying the example given earlier in the course (which used the SATS dataset):
https://365datascience.teachable.com/courses/362812/lectures/10601332
Unfortunately, the “proper” p values come out as zero while the univariate ones come out as I would expect:
reg_with_pvalues.p. gives.

array([0., 0.])

but the univariate p values come out as
p_values.round(3)
array([0.   , 0.357])
The other "proper" regression values (Intercept, coefficients and R squared) come out as expected and match the solution given but the p values do not.  

Could you give me some advice on troubleshooting this issue?

Thanks!

1 Answer

365 Team
0
Votes

Hi Simon,
Thanks for reaching out.
In fact, there is no way to go around “this issue”. Univariate p-values by default would give different results than the multivariate ones. 
Note that multivariate p-values are preferable in all situations. If you are dealing with a simple linear regression though, univariate will be equal to the multivariate (as there is a single variable).
Best,
The 365 Team

×
Online Data Science Training
SAVE 60%