自助法迴歸(Bootstrapped regressions)
你在長灘市公園與遊憩部門研究 NO2 與 SO2 的關係時,注意到一群可能的離群值,你懷疑它們可能影響了相關性。

請用自助法(bootstrap)重抽樣來檢視相關性的不確定性,看看擬合結果是否穩定。為了方便起見,已經完成重抽樣並提供為 no2_so2_boot,未重抽樣的資料則為 no2_so2。
本練習屬於課程
用 Python 改善你的資料視覺化
練習說明
- 告訴
sns.lmplot()需要為每個自助法sample繪製一條獨立的迴歸線。 - 將所有迴歸線設為
'steelblue',並將透明度設為 20%。 - 關閉 Seaborn 預設在迴歸線周圍繪製的信賴帶。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
sns.lmplot('NO2', 'SO2', data = no2_so2_boot,
# Tell seaborn to a regression line for each sample
____ = 'sample',
# Make lines blue and transparent
line_kws = {'____': 'steelblue', '____': 0.2},
# Disable built-in confidence intervals
ci = ____, legend = False, scatter = False)
# Draw scatter of all points
plt.scatter('NO2', 'SO2', data = no2_so2)
plt.show()