Regression to the mean

Python में statsmodels के साथ Regression परिचय

Maarten Van den Broeck

Content Developer at DataCamp

The concept

  • Response value = fitted value + residual
  • "जो आप समझा पाए" + "जो आप नहीं समझा पाए"
  • रेजिडुअल मॉडल की दिक्कतों और मूलभूत रैंडमनेस से आते हैं
  • अत्यधिक केस अक्सर रैंडमनेस के कारण होते हैं
  • Regression to the mean का मतलब है कि चरम मामले समय के साथ टिकते नहीं
Python में statsmodels के साथ Regression परिचय

पियरसन का पिता-पुत्र डेटासेट

  • 1078 पिता/पुत्र जोड़ियाँ
  • क्या लंबे पिता के बेटे भी लंबे होते हैं?
father_height_cm son_height_cm
165.2 151.8
160.7 160.6
165.0 160.9
167.0 159.5
155.3 163.3
... ...
1 Adapted from https://www.rdocumentation.org/packages/UsingR/topics/father.son
Python में statsmodels के साथ Regression परिचय

स्कैटर प्लॉट

fig = plt.figure()
sns.scatterplot(x="father_height_cm",
                y="son_height_cm",
                data=father_son)
plt.axline(xy1=(150, 150),
           slope=1,
           linewidth=2,
           color="green")
plt.axis("equal")
plt.show()

पुत्रों की लंबाई बनाम पिताओं की लंबाई का स्कैटर प्लॉट, जिसमें वह रेखा है जहाँ पिता और पुत्र समान लंबाई के होंगे। जैसे-जैसे पिता लंबे होते हैं, पुत्र भी लंबे होते हैं.

Python में statsmodels के साथ Regression परिचय

रीग्रेशन लाइन जोड़ना

fig = plt.figure()

sns.regplot(x="father_height_cm",
            y="son_height_cm",
            data=father_son,
            ci = None, 
            line_kws={"color": "black"})

plt.axline(xy1 = (150, 150),
           slope=1,
           linewidth=2,
           color="green")

plt.axis("equal")
plt.show()

पुत्रों की लंबाई बनाम पिताओं की लंबाई का वही स्कैटर प्लॉट, जिसमें एक लीनियर ट्रेंड लाइन अंकित है। ट्रेंड लाइन उस रेखा से कम ढाल वाली है जहाँ पिता और पुत्र समान लंबाई के होते.

Python में statsmodels के साथ Regression परिचय

रीग्रेशन चलाना

mdl_son_vs_father = ols("son_height_cm ~ father_height_cm",
                        data = father_son).fit()
print(mdl_son_vs_father.params)
Intercept           86.071975
father_height_cm     0.514093
dtype: float64
Python में statsmodels के साथ Regression परिचय

प्रेडिक्शन बनाना

really_tall_father = pd.DataFrame(
  {"father_height_cm": [190]})

mdl_son_vs_father.predict(
  really_tall_father)
183.7
really_short_father = pd.DataFrame(
  {"father_height_cm": [150]})

mdl_son_vs_father.predict(
  really_short_father)
163.2
Python में statsmodels के साथ Regression परिचय

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

Python में statsmodels के साथ Regression परिचय

Preparing Video For Download...