What is an extremely quick resource to learn how to implement bayesian models in Python?
-
I have recently came across a number of generative bayesian models that are implemented in Python. Now, I understand bayesian models as-is. I have spent a number of years working with matlab for machine learning. I have a very solid programming background. Alas, I have never worked with Python before. What I need is some sort of a 1-day crash course on Python implementation of bayesian models so that I can understand and tweak the implementations I got. I am not looking to become a Python fluent or to start writing code on my own. It would be nice if the source would also explain in details how the bayesian models are usually fit.
-
Answer:
http://camdavidsonpilon.github.io/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/ is a fine introduction to Bayesian methods in Python. http://www.greenteapress.com/thinkbayes/ is an introduction to Bayesian reasoning using Python. http://bastibe.de/2013-01-20-a-python-primer-for-matlab-users.html might also come in handy. I hope you can combine all of these to what you need.
Yuval Feinstein at Quora Visit the source
Other answers
You mentioned that you know how to implement machine learning models in Matlab. This implies that you how machine learning algorithms are constructed. My feeling is that you are only finding it difficult because either you have not implemented Bayesian generative models or Generative models or you think there is something special about Python (actually there is none). I would start with how to implement generative models. When I did my first implementation, I was so scared. I searched a lot and I stumbled upon chapter 2 of Markov chain Monte Carlo in practice, all my confusions were dispelled. You must write equations with your hand, on the paper. Do it twice or thrice and you will just "get it". Personally what I felt that every thing is in my mind. I hope this will help you to battle through first critical step "instilling confidence in yourself" and rest is all easy. Now it means you have equations with you. Since we are talking about generative models either you have some data or you want to generate some "dummy data". If you have data good, if you don't, you need to generate data using you generative process. Remember generative process is the assumption that you know how data came, and all you want is to learn the parameters. There are many ways to go for it. Free all the parameters while generating data, or few of them so that you can pinpoint mistakes of your code. I could discuss more about, but for now, this should be enough. Decide upon prior, I generally tend to start with non informative prior, loosely means you want to play safe and assume that uniform probability (here I would like the experts to comment). Write functions for each model parameters. Now you have parameters, prior, data. You want to add few more utility stuffs like logging, something which takes backup of model after lets say 1 hour etc. All I mean to say, at times model run for long time, sometimes you might want to stop, check something etc. Also you want to have some way to decide when to stop. This is really difficult question, what I personally do is plat the variable and see if they are converging to some value, Smart guy like you would probably write a script or thread which would analyze dumped model parameters and may send a signal when to stop. Some folks suggest using Rao-Blackwill theorem to decide when to stop, but I have never tried. Please let me know if you do so. So you have every thing needed to run the code. Aha, I didn't talk about sampling. I tend to use Gibbs sampler and rejection sampler. Do the standard stuffs like computations in log-space, caching/smart updates, drop the constant part. Also do understand under optimization library. If the problem is with python. Then learn about random number generators (normal, gamma etc...), optimization library (may be pyGSL), read/write data (many people would suggest Panda), matplotlib to plot convergence. I think this is all you need. 3. Most important thing is first step. If you take you take your first step, every thing just happen magically. Only the courage to take first step holds us back. ATB
Rahul Kumar
You can try PySTAN (https://pystan.readthedocs.org/en/latest/) which allows to easily define complex hierarchical bayesian models using many different types of Monte Carlo estimations including fancy Hamiltonean MC.
Alejandro Sifrim
Related Q & A:
- What is more important: human resource management and marketing management?Best solution by Yahoo! Answers
- What is the best way to learn how to build websites and web applications with Python?Best solution by Quora
- What are some extremely good study tips?Best solution by Yahoo! Answers
- What are some extremely good study tips that are not used by a lot of people?Best solution by Yahoo! Answers
- What is a good website to learn how to draw?Best solution by wiki.answers.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.