title: Linear Regression with Python numpy
body: <p>I'm trying to make a simple linear regression function but continue to encounter a </p>
  
  <blockquote>
    <p>numpy.linalg.linalg.LinAlgError: Singular matrix error</p>
  </blockquote>
  
  <p>Existing function (with debug prints):</p>
  
  <pre><code>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
      #print term1
      #print term2
      result = np.linalg.solve(term1, term2)
      return result
  </code></pre>
  
  <p>The output to the console with my test data is:</p>
  
  <pre><code>In makeLLS:
      Shape trainInput1: (773, 10)
      Shape trainTargetData: (773, 1)
      Shape term1: (10, 10)
      Shape term2: (10, 1)
  </code></pre>
  
  <p>Then it errors on the linalg.solve line.  This is a textbook linear regression function and I can't seem to figure out why it's failing.  </p>
  
  <p>What is the singular matrix error?</p>