拟合模型
某大学向您提供了一份数据,显示学习时长与学生在某次测试中的得分之间存在关系。
您可以通过变量 hours_of_study 和 scores 访问这些数据。请使用线性模型从数据中学习。
本练习是课程的一部分
Python 概率基础
练习说明
- 从
scipy.stats导入linregress()函数。 - 使用变量
hours_of_study和scores中提供的数据来拟合线性模型。 - 打印这些参数。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# 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:', ____)