def linear_regression(x_vals, y_vals):
'''
least-squares regression of scipy
'''
a_value, b_value, r_value, p_value, std_err = linregress(x_vals, y_vals)
est_yvals = a_value * x_vals + b_value
k = 1 / a_value
plot.plot(x_vals, est_yvals, label='Least-squares fit, k = ' +
str(round(k)) + ", RSquare = " + str(r_value**2))
评论列表
文章目录