Mth3007 Lecture 3
- Least squares regression - expanding to any general polynomial.
The worksheet covered more than this, but it was too much effort at the time of writing, whoops.
How Could You Implement General Polynomial Regression?
First of all, our imports…
Python
Output
As well as a function we programmed in mth3007 lecture 2.
Python
Output
Then the main function, explained in its docstring:
Python
Output
Then that’s it! However, we have no way of seeing if it actually works. Hence, we’ll make a few generic functions for plotting our results…
Python
Output
Then a quick function to generate test data:
Python
Output
Finally, the tests:
Python
Output
All done! At least, hopefully…