Finding best-fit lines with linear regression
the symbol ^
on top of the
w
tells that this the best solution we can come up with for
When 2D array, see the code below!
def standRegres(xArr, yArr):
xMat = mat(xArr); yMat = mat(yArr).T
xTx = xMat.T * xMat
if linalg.det(xTx) == 0.0:
print "This matrix is singular, can not inverse"
return
ws = xTx.I * (xMat.T * yMat)
return ws