Bayesian Methods 

For Hackers














    \







    Cam Davidson-Pilon

    camdp.com




     



    10 second bio:
    I'm an ex-fina nce quant currently
    doing data at  







    Your Highschool Stats != Bayesian Stats 





     


     wtf?




    Stats is actually really cool!



    Stats is taught in a way that turns many people off.


    •  Most were taught frequentists statistics (p-value, Z-scores, tests)
    •  I want to talk about Bayesian statistics

    Bayesian analysis relies  heavily on data-visualizations, instead of confusing p-values and hypothesis testing. 



    Philosophy and Interpretation of

     Bayesian Statistics




                      Prior                            Prior + data         (Prior + data) + data




    We start with prior beliefs, which can be thought of as opinions.






    Examples of Prior beliefs




    1. Beliefs on Google stock price next month
    2. Researcher's prior opinion of experimental outcome
    3. Does my code have a bug in it?
    4. Coin flips: how much information do I have?




    Hence probabilities are subjective!



    Add data...




    Given our prior, we can update our opinion (read: beliefs, probability), and produce a new opinion (read: new beliefs, new probability). 

    This new distribution is called the posterior.







    Iterate 

    if more data is available





                                                     Prior + data                   Prior + data 
                      Prior                            = new Posterior           = new Posterior

                                                   Posterior becomes             
                                                            new Prior



    One more important 

    detail to stress about Bayesian 

    statistics





    Frequentist vs Bayesian programming function


    • Freqntist( "My code passed all X tests; is there a bug in it?") returns:                                                           "No"

    • Bayesian("My code often has bugs. My code pass all X test; is there still a bug in it?")                                                                                                                                         {"No": 0.8, "Yes":0.2}


                            
    Bayesian methods return a distribution over answers, not a single answer.                       




     



    Frequentist methods are still awesome


    1. Least Squares, LASSO, Survival Analysis, etc. are awesome frequentist tools. 

    2. For large amounts of data, the two methods converge to the same answer. 

    3. For small data sizes, the two methods diverge and Bayesian methods should be preferred. 


    When do we have small data sizes?


    "Sample sizes are never large. If N is too small to get a sufficiently-precise estimate, you need to get more data (or make more assumptions).
     But once N is 'large enough,' you can start subdividing the data to learn more (for example, in a public opinion poll, once you have a good estimate for the entire country, you can estimate among men and women, northerners and southerners, different age groups, etc.).
     N is never enough because if it were 'enough' you'd already be on to the next problem for which you need more data."

                                             - Dr. Andrew Gelman



    Glorious A/B Testing


    (Make IPython go now)







    Discovering Changes in User Behaviour

    (make IPython go now)



     

     Bayesian Methods 

    For Hackers











    Future 



    Developments

    \

    Future Developments


    1. pip install bayesian-methods-for-hackers
    2. Meta datasets
    3. Adapting to the new IPython 1.0 and PyMC 3.0
    4. physical copy?








    Thanks!

     =)




    Made with Slides.com