Repository for the first project in FYS-STK 3155 the main code is located in code/Linear_regression.py note that the plots in visuals may differ from those in report
We consider three types of linear regression, ordinary least squares method (OLS), Ridge regression and Lasso regression and look at generated data with Franke's function and a terrain data set. With python, using our own implementations as well as functionality from sci-kit Learn, we minimised the cost function for these three methods. The Franke dataset consists of
- install pipenv on your system
- clone the repository
- in correct folder, type:
install pipenv
- enter shell:
pipenv shell
- run code file as normal
To run examples with Franke data, run the individual files. to run examples with terrain data, use terrainmap.py
MSE and R2 score, as well as beta variance for OLS
use OLS and bootstrap to produce Training error, Test error plot and Bias Variance plot.
compare bootstrap with kfold for OLS
plotting heatmap for bootstrap and kfold, and bias variance with ridge
plot bootsrap error, kfold error bias and variance for Lasso
to test the function write
pytest -v
or run the program normally. this also serves as benchmarks to check that each part of the code is running as expected.