用excel中数据分析功能做线性回归练习
分别选取20、200、2000(或20000)组数据,进行练习。记录回归方程式、R2
20:
200:
2000:
用jupyter编程(不借助第三方库),用最小二乘法
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
points = np.genfromtxt("weights_heights.csv",delimiter=",")
#将wh.csv文件中的数据赋值给points
#将points中的数据分别赋给x,y,求回归方程y=ax+b
x=points[1:21,2];
y=points[1:21,1];
#根据自己需要使用数据的个数更改[]中的值
pccs = np.corrcoef(x, y)
c,d=pccs
e,f=c
x_mean