Sample program to model the data using linear regression, and show the graph.
- Python 2.7.6
- Numpy
- Matplotlib
$ python linear_regression.py
Use the polynomial basis as the basis function.
Then, the function can be expressed as below.
This time, I define the basis function as 4 dimensional. Thence,
Using matrix, these "omega" can be solved by this equation.
Phi is the matrix as following.
- numpy.linalg.solve : Sove a linear matrix equation. ref. http://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.solve.html
- numpy.dot : Scalar product, Inner product ref. http://docs.scipy.org/doc/numpy/reference/generated/numpy.dot.html
(Japanese) http://gihyo.jp/dev/serial/01/machine-learning/0011?page=1