开始使用免费开始使用

检查保质期中的异方差性

在评估食物保鲜方法时,了解某个变量(如保质期)的方差如何随另一个变量(如营养保留率)的范围而变化至关重要。识别此类模式(称为异方差性)有助于洞察保鲜效果的一致性。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()
编辑并运行代码