Git Product home page Git Product logo

overfit's Introduction

Overfit

Perfectly fits a polynomial hypersurface to any dataset. A fairly straightforward mathematical exercise, this gave me a fun problem to work on during covid.

Theory

This algorithm is a multivariable generalization of polynomial interopolation, which is generally not the best strategy for multivariate interpolation, but it does serve as a demonstration for polynomial completeness.

Running

This program is run from the command line by running the file overfit.py. It takes an input dataset as a csv file containing m rows (datapoints) of n columns each. The first n-1 elements in each row represent that datapoint's coordinates, and the nth element is the value at that point. The next arguments can be either a set of coordinates to interpolate or a command to plot the polynomial with a given window.

Example

This repository includes some (very) small example data. I built this less than a year into college before I understood portability, but this doesn't use any particularly specialized packages. I'm able to run on an intel-based Macbook running MacOS Ventura with Python 3.9.6, matplotlib 3.7.2 and numpy 1.25.2 with the following commands. Since numpy is a matplotlib prereq, only installing matplotlib should suffice.

python -m venv venv
source venv/bin/activate
pip install matplotlib
git clone https://github.com/cooper6558/Overfit.git
cd Overfit
python overfit.py planar_data.csv plot 0 4 0 4
python overfit.py planar_data.csv 2.5
> Prediction: 2.367188
python overfit.py data.csv 1 2 3
> Prediction: 5.687369

A note on code quality

If you think this code looks like it was written by a college freshman, that's because it was. I was revisiting this repository three years later and decided I might as well keep it up, so I wrote this quick readme and fixed some things to make the code run without crashing, but I won't be spending any more time on this project.

overfit's People

Contributors

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