Skip to content

NBPub/probability_distribution_viz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SciPy Probability Distributions Visualizer

Visualize probability distributions from SciPy using Plotly-Dash. I made this to review and better understand various probability distributions, and to serve as a handy tool to use alongside scikit-learn's RandomizedSearchCV when tuning machine learning models.

Demo

Freely hosted here, availability not guaranteed.


Contents

Code Notes

Overview

  • app.py
    • load distributions from SciPy, setup dash application, handle callbacks
  • distributions.py
    • functions to
      • update info text and parameter inputs on page with distribution choice
      • generate histogram and violin plots from given distribution and parameters
        • five thousand points generated: <distribution>.rvs(<shape_parameters>,<loc>,<scale>,5000)

For Me

  • Python
    • class inspection to extract distributions and their information from SciPy
  • SciPy
    • experience with probability distributions, code, documentation
  • Dash, Plotly
    • graphs with custom hover data, colors, titles
      • only use Go figures, so plotly-express and pandas are not required packages
    • advanced callback usage. | works, imperfectly
      • distribution selection from dropdown determines parameters (and info text) which determine graphs
      • graphs updated by sliders or text inputs
      • sliders and text boxes update if their corresponding partner is changed
        • circular callback warning, causes graphs to update twice each time
    • simple single page application, easy deployment
    • minimal CSS styling, no CSS/JSS toolkits like Bootstrap
      • could use something to display LaTeX, SciPy docs utilize sphinx which uses MathJax?

Installation

  • Requirements File lists all packages frozen in my development environment
  • install dash and SciPy in a Python environment to run the applcation

The code can be run from a virtual environment on your local machine. Download the code to a new directory, your-directory

Only the python files .py and assets (your-directory/assets) directory are necessary to run the application.

# Adapt for your operating system

cd your-directory
python -m venv venv
venv\scripts\activate
python -m pip install --upgrade pip

# install packages via requirements.txt
pip install -r requirements.txt 
# OR install packages separately
pip install dash scipy

# ensure server settings are ok before running
python -m app

The application will be available on the default port, 8050, at http://127.0.0.1:8050/. Change DEBUG settings or adapt deployment for WSGI by modying the run command.

WSGI

  • comment out run command
  • import app from app.py into your WSGI of choice
    • I think PythonAnywhere uses uWSGI with NGINX

About

Visualize probability distributions (scipy.stats) with a simple plotly-dash application

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published