GithubHelp home page GithubHelp logo

linear-regression-fys-stk4155's Introduction

FYS-STK4155 - Project 1

Installation

Use the package manager pip to install requirements

pip install -r requirements.txt

Structure

The repo is divided into two main parts:

  • src : This is where the python code and the data from the input and output is put
  • report : This is where the report and the latex is located

Python code

.
├── config.py - config variables
├── data
│  └── geodata.tif
├── data_generation.py - used for generating franke data and for loading the data from the terrain data
├── lasso.py - for fitting and predicting using lasso regression
├── linear_regression_models.py - an abstract linear regression method housing many of the helper methods and the abstract structure for the other regression files
├── ordinary_least_squares.py - for fitting the ordinary least squares and for calculating confidence intervals
├── output - the output from run.py
│  ├── ...
├── plotter.py - a helper method for plotting different data
├── ridge.py - for fitting ridge regression and for calculating the confidence intervals
└── run.py - generating the plots and testing the code

Usage

To run the "main" program which generates the plots, and for general code examples for using different methods, look at run.py

cd src
python run.py

The code is written to be pretty general, meaning that it should be easy to use some of the code in another project. If one for instance wanted to use the ordinary least squares method, it can be done using the following code:

from data_generation import FrankeData
from plotter import surface_plot_raveled
from ordinary_least_squares import OrdinaryLeastSquares

data = FrankeData(30)

ols = OrdinaryLeastSquares(5)
ols.fit(data.x, data.y, data.z)

plotting_data = FrankeData(20)
z_tilde = ols.predict(plotting_data.x, plotting_data.y)

surface_plot_raveled(
    "Ordinary least squares",
    plotting_data.x,
    plotting_data.y,
    [[plotting_data.z, z_tilde]],
    [["z_test", "z-tilde"]],
    plotting_data.dimensions,
)

linear-regression-fys-stk4155's People

Contributors

hermabr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.