इंटरैक्शन के साथ एक मॉडल

इंटरमीडिएट Regression with statsmodels in Python

Maarten Van den Broeck

Content Developer at DataCamp

इंटरैक्शन क्या है?

फिश डेटासेट में

  • अलग-अलग मछली प्रजातियों में mass से length का अनुपात अलग होता है.
  • length का expected mass पर असर, प्रजाति के अनुसार बदलता है.

 

सामान्य रूप से

एक explanatory वैरिएबल का expected response पर प्रभाव, दूसरे explanatory वैरिएबल के मान पर निर्भर करके बदलता है.

इंटरमीडिएट Regression with statsmodels in Python

इंटरैक्शन बताने के तरीके

बिना इंटरैक्शन

response ~ explntry1 + explntry2

इंटरैक्शन के साथ (implicit)

response_var ~ explntry1 * explntry2

इंटरैक्शन के साथ (explicit)

response ~ explntry1 + explntry2 + explntry1:explntry2

बिना इंटरैक्शन

mass_g ~ length_cm + species

इंटरैक्शन के साथ (implicit)

mass_g ~ length_cm * species

इंटरैक्शन के साथ (explicit)

mass_g ~ length_cm + species + length_cm:species
इंटरमीडिएट Regression with statsmodels in Python

मॉडल चलाना

mdl_mass_vs_both = ols("mass_g ~ length_cm * species", data=fish).fit()

print(mdl_mass_vs_both.params)
Intercept                    -1035.3476
species[T.Perch]               416.1725
species[T.Pike]               -505.4767
species[T.Roach]               705.9714
length_cm                       54.5500
length_cm:species[T.Perch]     -15.6385
length_cm:species[T.Pike]       -1.3551
length_cm:species[T.Roach]     -31.2307
इंटरमीडिएट Regression with statsmodels in Python

समझने में आसान कोएफ़िशिएंट्स

mdl_mass_vs_both_inter = ols("mass_g ~ species + species:length_cm + 0", data=fish).fit()

print(mdl_mass_vs_both_inter.params)
species[Bream]             -1035.3476
species[Perch]              -619.1751
species[Pike]              -1540.8243
species[Roach]              -329.3762
species[Bream]:length_cm      54.5500
species[Perch]:length_cm      38.9115
species[Pike]:length_cm       53.1949
species[Roach]:length_cm      23.3193
इंटरमीडिएट Regression with statsmodels in Python

पहचाने हुए नंबर

print(mdl_mass_vs_both_inter.params)
species[Bream]             -1035.3476
species[Perch]              -619.1751
species[Pike]              -1540.8243
species[Roach]              -329.3762
species[Bream]:length_cm      54.5500
species[Perch]:length_cm      38.9115
species[Pike]:length_cm       53.1949
species[Roach]:length_cm      23.3193
print(mdl_bream.params)
Intercept   -1035.3476
length_cm      54.5500
इंटरमीडिएट Regression with statsmodels in Python

अभ्यास करते हैं!

इंटरमीडिएट Regression with statsmodels in Python

Preparing Video For Download...