Implements a Python executable file called linear_regression.py that uses linear regression to fit a polynomial function to the data.
-
The first argument, <training_file>, is the path name of the training file, where the training data is stored. The path name can specify any file stored on the local computer.
-
The second argument, <degree> is an integer between 1 and 10. We will not test your code with any other values. The degree specifies what function φ you should use.
Suppose that you have an input vector x = (x1, x2, ..., xD)T
- If the degree is 1, then φ(x) = (1, x1, x2, ..., xD)T.
- If the degree is 2, then φ(x) = (1, x1, (x1)2, x2, (x2)2..., xD, (xD)2)T.
- If the degree is 3, then φ(x) = (1, x1, (x1)2, (x1)3, x2, (x2)2, (x2)3, ..., xD, (xD)2, (xD)3)T.
-
The third argument, <λ>, is a non-negative real number (it can be zero or greater than zero). This is the value of λ that you should use for regularization. If λ = 0, then no regularization is used.
-
The fourth argument, <test_file>, is the path name of the test file, where the test data is stored. The path name can specify any file stored on the local computer.
- Degree = 1 and λ = 0
- Degree = 1 and λ = 1
- Degree = 2 and λ = 0
- Degree = 2 and λ = 1