Added NULL handling in Linear Regression

* Moved all SQL code into Python
* NULL handling