I kept getting the singular matrix exception from the call to linalg.inv() in standard_errors(). Initially, I got rid of the exception by using linalg.pinv(), but the resulting standard errors were obviously too big and nearly identical regardless of the data set. I eventually found that predict() was called with y_data instead of x_data. Also added a few comments that may help other understand the function.
I kept getting the singular matrix exception from the call to linalg.inv() in standard_errors(). Initially, I got rid of the exception by using linalg.pinv(), but the resulting standard errors were obviously too big and nearly identical regardless of the data set. I eventually found that predict() was called with y_data instead of x_data. Also added a few comments that may help other understand the function.