Bayesian Inference Tools in Python

Overview

BayesPy

Bayesian Inference Tools in Python

Our goal is, given the discrete outcomes of events, estimate the distribution of categories. Using gradient descent we can estimate the parameters of a dirchlet prior from past data that can be combined as a conjugate prior with the multinomial distribution to better estimate the likelihood of seeing an event of a given type in the future.

Conjugate Prior Tools: The main file is ./findDirichletPrior - you pipe in your counts (given in test.csv as an example) and the maximum-likelihood dirichlet comes out.

Some things to try on your terminal: cat test.csv | ./findDirichletPrior.py -- This will find the priors for a test file

./flipCoins .7 1.2 | ./findDirichletPrior.py -- This will generate a data set on the fly using dirichlet parameters .7 1.2 (feel free to change those) -- findDirichletPrior should come up with a good estimate of those numbers using only the coin flips

cat oneDoublesided.csv | ./findDirichletPrior.py -- This is a sample of a case where findDirichletPrior won't give you a great result. This is because every -- coin in the input is fair except two coins: one is double sided heads, and the other tails. -- Dirichlet distributions cannot handle this trimodal data very well, but it'll end up giving a compromise solution

#Using the priors You can test the strength of your prior using the H parameter. Higher values for Beta will give lower probabilities.

python findDirichletPrior.py -H1,4,5 < /dev/null

gammaDistTools is not used. These functions will be used for a future gamma distribution estimations.

You might also like...
Python Environment for Bayesian Learning

Pebl is a python library and command line application for learning the structure of a Bayesian network given prior knowledge and observations. Pebl in

Python package for Bayesian Machine Learning with scikit-learn API
Python package for Bayesian Machine Learning with scikit-learn API

Python package for Bayesian Machine Learning with scikit-learn API Installing & Upgrading package pip install https://github.com/AmazaspShumik/sklearn

MCMC samplers for Bayesian estimation in Python, including Metropolis-Hastings, NUTS, and Slice

Sampyl May 29, 2018: version 0.3 Sampyl is a package for sampling from probability distributions using MCMC methods. Similar to PyMC3 using theano to

Spearmint Bayesian optimization codebase

Spearmint Spearmint is a software package to perform Bayesian optimization. The Software is designed to automatically run experiments (thus the code n

Simple, but essential Bayesian optimization package

BayesO: A Bayesian optimization framework in Python Simple, but essential Bayesian optimization package. http://bayeso.org Online documentation Instal

Bayesian dessert for Lasagne
Bayesian dessert for Lasagne

Gelato Bayesian dessert for Lasagne Recent results in Bayesian statistics for constructing robust neural networks have proved that it is one of the be

A bare-bones TensorFlow framework for Bayesian deep learning and Gaussian process approximation

Aboleth A bare-bones TensorFlow framework for Bayesian deep learning and Gaussian process approximation [1] with stochastic gradient variational Bayes

Bayesian optimization in PyTorch

BoTorch is a library for Bayesian Optimization built on PyTorch. BoTorch is currently in beta and under active development! Why BoTorch ? BoTorch Prov

Safe Bayesian Optimization
Safe Bayesian Optimization

SafeOpt - Safe Bayesian Optimization This code implements an adapted version of the safe, Bayesian optimization algorithm, SafeOpt [1], [2]. It also p

Comments
  • Fixed some bugs?

    Fixed some bugs?

    I set the Beta and W to None when it's not passed in. That didn't seem to have an effect but mine as well make use of the if statements

    I found a few instances were the index variables felt wrong to me. I didn't review the math but they seemed off.

    Please review

    Thanks Adam

    opened by adamilardi 5
  • Add docs, iteration param and bug fix

    Add docs, iteration param and bug fix

    K should be K-1 since that will be last last element of the array. It only noticed it go wrong when you pass in bad input like [0] I added iterations to test out some of the -H param values

    opened by adamilardi 3
  • Logging changes

    Logging changes

    I used the logging module to print debug messages to stderr so you can pipe the final results to a file without parsing

    If you want I can remove the verbose flag also if you like this style.

    opened by adamilardi 0
  • Divide by 0 error

    Divide by 0 error

    I haven't looked into the root cause yet but here is the data that causes it. It would appear to be the columns with all 0s.

    0 0 0 0 1 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0

    python findDirichletPrior.py -K 6

    Loading data all data loaded into memory time to load memory: 0.000438928604126 1 Loss: 4.75135269617 , Priors: [0.6, 0.0, 0.2, 0.0, 0.2, 0.0] , Gradient Size: 75.0 Traceback (most recent call last): File "findDirichletPrior.py", line 94, in priors = DME.findDirichletPriors(uMatrix, vVector, priors, verbose) File "/BayesPy/ConjugatePriorTools/dirichletMultinomialEstimation.py", line 155, in findDirichletPriors trialStep = predictStepUsingHessian(gradient, priors, uMatrix, vVector) File "/BayesPy/ConjugatePriorTools/dirichletMultinomialEstimation.py", line 111, in predictStepUsingHessian return getPredictedStep(totalHConst, totalHDiag, gradient) File "/BayesPy/ConjugatePriorTools/dirichletMultinomialEstimation.py", line 69, in getPredictedStep numSum += gradient[i] / hDiag[i] ZeroDivisionError: float division by zero

    opened by adamilardi 8
Owner
Max Sklar
Machine Learning Enthusiast, Foursquare Engineer, Former Talk Radio Host, Marsbot's Mechanic. @marsbot, @swarmingnow
Max Sklar
LBK 20 Dec 2, 2022
aka "Bayesian Methods for Hackers": An introduction to Bayesian methods + probabilistic programming with a computation/understanding-first, mathematics-second point of view. All in pure Python ;)

Bayesian Methods for Hackers Using Python and PyMC The Bayesian method is the natural approach to inference, yet it is hidden from readers behind chap

Cameron Davidson-Pilon 25.1k Jan 2, 2023
Python Library for learning (Structure and Parameter) and inference (Statistical and Causal) in Bayesian Networks.

pgmpy pgmpy is a python library for working with Probabilistic Graphical Models. Documentation and list of algorithms supported is at our official sit

pgmpy 2.2k Jan 3, 2023
Python package facilitating the use of Bayesian Deep Learning methods with Variational Inference for PyTorch

PyVarInf PyVarInf provides facilities to easily train your PyTorch neural network models using variational inference. Bayesian Deep Learning with Vari

null 342 Dec 2, 2022
Data-depth-inference - Data depth inference with python

Welcome! This readme will guide you through the use of the code in this reposito

Marco 3 Feb 8, 2022
Torchserve server using a YoloV5 model running on docker with GPU and static batch inference to perform production ready inference.

Yolov5 running on TorchServe (GPU compatible) ! This is a dockerfile to run TorchServe for Yolo v5 object detection model. (TorchServe (PyTorch librar

null 82 Nov 29, 2022
Monocular 3D pose estimation. OpenVINO. CPU inference or iGPU (OpenCL) inference.

human-pose-estimation-3d-python-cpp RealSenseD435 (RGB) 480x640 + CPU Corei9 45 FPS (Depth is not used) 1. Run 1-1. RealSenseD435 (RGB) 480x640 + CPU

Katsuya Hyodo 8 Oct 3, 2022
PyTorch-LIT is the Lite Inference Toolkit (LIT) for PyTorch which focuses on easy and fast inference of large models on end-devices.

PyTorch-LIT PyTorch-LIT is the Lite Inference Toolkit (LIT) for PyTorch which focuses on easy and fast inference of large models on end-devices. With

Amin Rezaei 157 Dec 11, 2022
🏎️ Accelerate training and inference of 🤗 Transformers with easy to use hardware optimization tools

Hugging Face Optimum ?? Optimum is an extension of ?? Transformers, providing a set of performance optimization tools enabling maximum efficiency to t

Hugging Face 842 Dec 30, 2022
Core ML tools contain supporting tools for Core ML model conversion, editing, and validation.

Core ML Tools Use coremltools to convert machine learning models from third-party libraries to the Core ML format. The Python package contains the sup

Apple 3k Jan 8, 2023