檢查保存期限的異質變異數
在評估食物保鮮方法時,必須了解某個變數(例如保存期限)的變異是否會隨另一個變數(例如營養保留率)的範圍而改變。辨識這類型的模式(稱為異質變異數)能幫助你了解保鮮效果的一致性。food_preservation 資料集彙整了各種保鮮方法對不同食物類型的影響,特別著重於營養保留與最終保存期限之間的平衡。
food_preservation DataFrame、pandas(作為 pd)、numpy(作為 np)、seaborn(作為 sns)以及 matplotlib.pyplot(作為 plt)都已為你載入。
本練習屬於課程
Python 的實驗設計
練習說明
- 使用合適的圖形來檢查
'NutrientRetention'與'ShelfLife'之間是否存在異質變異數。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Check for heteroscedasticity with a residual plot
sns.____(x='____', y='____',
data=____, lowess=____)
plt.title('Residual Plot of Shelf Life and Nutrient Retention')
plt.xlabel('Nutrient Retention (%)')
plt.ylabel('Residuals')
plt.show()