【发布时间】:2019-05-02 21:46:11
【问题描述】:
我正在努力寻找 b1、b2 和 b3 的系数。我的模型有 3 个自变量 x1、x2 和 x3 以及一个因变量 y。
x1,x2,x3,y
89,4,3.84,7
66,1,3.19,5.4
78,3,3.78,6.6
111,6,3.89,7.4
44,1,3.57,4.8
77,3,3.57,6.4
80,3,3.03,7
66,2,3.51,5.6
109,5,3.54,7.3
76,3,3.25,6.4
我想用矩阵法找出 b1、b2 和 b3 的系数。在我遵循的教程中,b1 的值为 0.0141,b2 为 0.383,b3 为 -0.607。
我不确定如何实现上述值,当我尝试对包含 x1、x2、x3 值的矩阵求逆时,出现以下错误。
raise LinAlgError('Last 2 dimensions of the array must be square')
numpy.linalg.linalg.LinAlgError: Last 2 dimensions of the array must be square
请有人帮我解决这个矩阵,以便我可以获得所需的值。
【问题讨论】:
标签: python python-3.x statistics regression linear-regression