其他分享
首页 > 其他分享> > 学习笔记(待编辑)

学习笔记(待编辑)

作者:互联网

# Specify slopes to consider: a_vals
a_vals = np.linspace(0,0.1,200)

# Initialize sum of square of residuals: rss
rss = np.empty_like(a_vals)

# Compute sum of square of residuals for each value oÏf a_vals
for i, a in enumerate(a_vals):
    rss[i] = np.sum((fertility - a*illiteracy - b)**2)

# Plot the RSS
plt.plot(rss, a_vals, '-')
plt.xlabel('slope (children per woman / percent illiterate)')
plt.ylabel('sum of square of residuals')

plt.show()

 

标签:plt,sum,笔记,学习,编辑,square,residuals,vals,rss
来源: https://blog.csdn.net/xili1342/article/details/112132322