I am trying to make a simple linear regression function, but continue to run into
numpy.linalg.linalg.LinAlgError: singular matrix error
Existing function (with debugging prints):
def makeLLS(inputData, targetData): print "In makeLLS:" print " Shape inputData:",inputData.shape print " Shape targetData:",targetData.shape term1 = np.dot(inputData.T, inputData) term2 = np.dot(inputData.T, targetData) print " Shape term1:",term1.shape print " Shape term2:",term2.shape
Exit to the console with my test data:
In makeLLS: Shape trainInput1: (773, 10) Shape trainTargetData: (773, 1) Shape term1: (10, 10) Shape term2: (10, 1)
Then these are the errors on the linalg.solve line. This is a linear regression function of the textbook, and I cannot understand why it fails.
What is the error of the singular matrix?
python numpy linear-regression
Jonathan
source share