开始使用免费开始使用

拟合模型

某大学向您提供了一份数据,显示学习时长与学生在某次测试中的得分之间存在关系。

您可以通过变量 hours_of_studyscores 访问这些数据。请使用线性模型从数据中学习。

本练习是课程的一部分

Python 概率基础

查看课程

练习说明

  • scipy.stats 导入 linregress() 函数。
  • 使用变量 hours_of_studyscores 中提供的数据来拟合线性模型。
  • 打印这些参数。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Import the linregress() function
from scipy.stats import ____

# Get the model parameters
slope, intercept, r_value, p_value, std_err = ____(____, ____)

# Print the linear model parameters
print('slope:', ____)
print('intercept:', ____)
编辑并运行代码