Git Product home page Git Product logo

decision_boundary_demo's Introduction

Neural network decision boundary visualisation

This is a naive demo of multi-class and multi-label classification. The demo allows you to alter the weights of 3 classifiers, one for each class (blueberries, bananas, strawberries). The weights vectors are visualised using arrows, and the decision boundaries by using lines. Moving the weight vectors around, changes the decision boundaries. It also changes the probability of each input point belonging to one of the three classes, as visualised on the 3d plot on the right.

How to move things

The 3d plot can be moved around and the 2d plot can be zoomed in/out by scrolling. Choose which class you want to change the weight vector for from the radio buttons and click on the left plot to change its weights. You can also alter the bias term for each class by clicking on the bars at the top right.

If sigmoids is chosen, then this is interpreted as a multi-label classification setting and there is an independent binary classifier fit for each class. In this case therefore, there is a separate probability for each class being true, and we can visualise these three probabilities as a (x, y, z) point constrained to be in the unit cube (as seen below on the right).

Decision boundary with intersecting lines and sigmoids

If softmax is chosen, then classes are mutually exclusive (the score for each class is normalized to form a probability distribution over all classes). Therefore, the probability of each class for each input point is constrained to be a (x, y, z) point on the 2-simplex (as seen below). Decision boundary with intersecting lines and softmax

If we also choose circle from the first radio button, we augment the input using basis functions so that we get circular decision boundaries. Decision boundary with intersecting circles and sigmoids

Requirements

  • Python3.7 (should work on older python3)
  • matplotlib
  • numpy

How to run

git clone https://github.com/andreasgrv/decision_boundary_demo
cd decision_boundary_demo
python3.7 -m venv .env && source .env/bin/activate
pip install -r requirements.txt
python main.py

Options

  • Linear or circular decision boundaries
  • Choose weights and biases
  • Sigmoids or softmax

Notes

  • For softmax the decision boundaries are formed by the differences of weight vectors, that is not currently mirrored in the lines but should be mirrored in the colours of the points.

decision_boundary_demo's People

Contributors

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