Giter Site home page Giter Site logo

flatironinstitute / least_absolute_regression Goto Github PK

View Code? Open in Web Editor NEW
6.0 5.0 5.0 509 KB

Least absolute error regression implemented using Linear Programming, primarily to illustrate repository structure conventions.

Python 3.63% Jupyter Notebook 96.37%

least_absolute_regression's Introduction

Build Status codecov Binder

least_absolute_regression

Least absolute error regression implemented using Linear Programming.

Below is an example using 5 samples with 2 independent variables that do not fit a plane. The mapping of independent variables to the dependent variable is

(1,1) --> 0
(1,-1) --> -2
(-1,-1) --> -4
(-1,1) --> -2
(0,0) --> -1.3

All but the last mapping fit the plane x + y - 2 = z.

from lae_regression import l1_fit
U = ([1, 1], [1, -1], [-1, -1], [-1, 1], [0, 0])
v = (0, -2, -4, -2, -1.3)
result = l1_fit(U, v)
result["m"], result["k"], result["residuals"], result["samples"], result["dimensions"]

The value of the last line gives:

(array([ 1.,  1.]),
 -2.000,
 array([ -4.441e-16,  -1.332e-15,  -4.441e-16,   4.441e-16,   7.000e-01]),
 5,
 2)

Here with m = (1,1) and k = -2 the regression finds the plane 1*x + 1*y - 2 = z and essentially rejects the last mapping as an outlier.

Background

Historically this code was set up to illustrate techniques for developing and publishing computational methods using methodologies associated with Jupyter notebooks.

Please see the ./presentation folder for detailed discussion of the methods used (as jupyter notebooks).

In particular the ./presentation/Notebooks as Notes.ipynb notebook introduces concepts of least absolute error regression and the ./presentation/1.1_Method Derivation.ipynb notebook discusses the derivation of the calculation.

least_absolute_regression's People

Contributors

aaronwatters avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  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.