(Dec-02-2020, 11:30 AM)321brian Wrote: I don't pass anything into that method to tell it to make that connection, but somehow it knows what Y is. Prior to the method call, I set the column set to a variable called Y. But I don't pass that variable value to the ols method. So how does the code inside the method know what Y is?But you bind name
Y
to column fat['body_fat_percent']
on line 7!It uses
patsy
as language to describe the model. It parse the string 'Y ~ triceps_skinfold_thickness_mm + midarm_circumference_cm + thigh_circumference_cm'
and uses the name Y
you defined as well as the other columns from fat
DataFrame.If you prefer you can drop line 7 and just use
model = sms.ols('body_fat_percent ~ triceps_skinfold_thickness_mm + midarm_circumference_cm + thigh_circumference_cm', data = fat).fit()Here's again the link to patsy package docs: https://patsy.readthedocs.io/en/latest/
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs