
Explore why a/b testing matters in modern software, bridging frequentist and bayesian approaches, and apply adaptive bayesian methods for online platforms using Python.
Download the course code from the GitHub repository at GitHub.com slash lazy programmer slash machine learning examples, and use the resources link to access the main course folder.
Ask questions via the Q&A to clarify concepts quickly. Follow prerequisites to guide your background review and engage with hands on coding and note taking throughout the course.
Discover real-world applications of A/B testing across medicine, website conversion, flyer design, and hard-drive choices, and learn how to compare two groups to detect meaningful differences.
Explore what Bayesian machine learning is and how it differs from frequentist methods, treating parameters as distributions and everything as a random variable, with A/B testing insights.
Review Bayes rule and joint, marginal, and conditional distributions to warm up for the course. Compare bayesian methods with maximum likelihood estimation to understand their context and use.
Review the basics of probability: joint, marginal, and conditional distributions, and derive Bayes' rule, including discrete and continuous cases with densities and integrals.
Explore calculating probabilities from country-based user counts, derive marginal and conditional probabilities, examine joint distributions, and identify independence and the curse of dimensionality in practical Bayesian analysis.
We examine independence and identically distributed coin tosses on a fair 200-toss experiment. This yields 130 heads and 70 tails, debunking the gambler's fallacy.
Explore the Monty Hall problem and use Bayes' rule to show that switching doors doubles your win probability to two thirds.
Learn maximum likelihood estimation for the Bernoulli distribution, deriving theta_hat as the proportion of heads from iid coin toss data, and distinguish the likelihood from the binomial model.
Explore how click-through rates and conversion rates quantify binary user actions as Bernoulli probabilities, and apply maximum likelihood estimation to impressions and visits to improve these probabilities.
Learn how to apply maximum likelihood estimation to the Gaussian distribution, derive the log-likelihood, and obtain mu hat as the sample mean and sigma hat as the data dispersion.
Derive maximum likelihood estimates for the gaussian mean and variance, using v as sigma squared, and discuss the sample variance and its relation to mu hat.
Explore the cumulative distribution function (CDF) for discrete and continuous variables, its relation to the PDF, and how the inverse CDF (percentiles) guides confidence intervals and hypothesis testing.
Explore generating Gaussian samples, computing the maximum likelihood estimates of the mean and variance, and using CDF, PPF, and survival function to answer percentile questions in Python.
Review Bayes rule and probability distributions (joint, conditional, and marginal) and contrast Bayesian and frequentist approaches, focusing on point estimates, confidence intervals, and A/B testing fundamentals.
Debunks common misconceptions about statistics and machine learning while clarifying how supervised, unsupervised, reinforcement, and online learning fit under a broad model-building framework that updates parameters from data.
Share feedback via a suggestion box to tailor the course and note your background and difficulty. Include concrete examples and topics like convolutional neural networks, transformers, or quantum mechanics.
Builds intuition for confidence intervals by contrasting sample means from clustered data versus spread-out data, showing that tighter samples and larger sample sizes increase confidence in the mean.
Compute confidence intervals with a beginner-friendly plug-and-chug approach, using mu hat, x bar, sigma hat, and n to obtain a 95% interval and relate width to variance and sample size.
Demonstrates that the sample mean of i.i.d. normal data is normal with mean mu and variance sigma squared over n, and that more samples shrink the confidence interval.
Explore how to compute and interpret confidence intervals for mean estimates in A/B testing using the normal distribution, standardization, and the central limit theorem, including 95% intervals and Bernoulli examples.
Implement confidence intervals in Python by generating normal samples with numpy, estimating mu hat and sigma hat, and constructing z and t intervals, then verify 95% coverage through repeated experiments.
Explore hypothesis testing with real-world examples, including drug trials, web page designs, and stock returns. Identify null and alternative hypotheses for one-sample and two-sample, two-sided and one-sided tests.
Explore why statistical significance matters when comparing two groups in A/B testing, using hypothesis testing, samples, variance, and confidence intervals to avoid overinterpreting averages.
Explore the api approach to hypothesis testing by passing one- or two-sample data into z- or t-tests, and interpret the p value against a significance threshold to decide statistical significance.
Shows that hypothesis testing is not binary: you either reject the null or fail to reject it, never accept either hypothesis, with p-values relative to the significance threshold guiding conclusions.
Explore how the API approach to hypothesis testing generalizes beyond means, applying normality and stationarity checks to diverse data, with p-values guiding null versus alternative conclusions.
Explore the z-test theory by deriving the z statistic from mu hat and mu naught, understanding standard normal assumptions, confidence intervals, p values, and two- and one-sided hypotheses.
Explore how to conduct one-sample and two-sample z tests by deriving the z statistic, computing p values, and translating two-sample problems into a one-sample framework using the difference of means.
Explore how to implement and validate a z-test in Python, including one- and two-sample cases, p-values, and comparison with statsmodels, plus interpreting false alarms.
apply a z-test to Titanic fare by survived vs non-survived groups using pandas, seaborn KDE plots, and numpy, concluding with a highly significant p-value.
Perform a hypothesis test for an A/B comparison of click through rates on advertisement clicks, for ads A and B, using a Bernoulli model and a 5% significance threshold.
Compare frequentist A/B testing with Bayesian methods, highlighting contrasting inferences. Explore concepts like confidence intervals, z and t tests, Bonferroni corrections, and Bayesian probabilities of one option outperforming another.
Explore the explore-exploit dilemma and learn four adaptive algorithms: epsilon greedy, optimistic initial values, UCB one, and Thompson sampling, for solving A/B tests with Bayesian statistics.
Explore how the explore-exploit dilemma applies to online advertising, ctr, and conversions through real-world a/b testing. Leverage Bernoulli and Gaussian models to handle binary outcomes and continuous rewards like revenue.
Explore how epsilon-greedy balances exploration and exploitation in bandit problems, using a random action with probability epsilon and selecting the best mean otherwise, with decay schedules.
Learn to compute the sample mean in constant time and space by updating from the previous mean, unifying real-valued and binary rewards including Bernoulli, for epsilon-greedy.
Implement the epsilon-greedy beginner exercise by building a bandit simulation in Python, updating estimates, and plotting win rate over time to select the optimal bandit.
Design and implement bandit algorithms to solve exploration-exploitation problems using a casino-machine simulation, updating model parameters and comparing learned rewards to the true distribution.
Apply epsilon-greedy selection to a three-armed bandit, update estimates from trials, and analyze exploration versus exploitation to approach the optimal win rate and track cumulative performance.
Compare how different epsilon values affect epsilon-greedy performance on Gaussian rewards, analyzing convergence speed, cumulative reward, and suboptimal arm selection across three bandits.
The optimistic initial values method modifies greedy by initializing bandits' means to large finite values, driving exploration as a hyperparameter without epsilon or random exploration.
Introduces the beginner's exercise prompt for optimistic initial values in the bandit script, guiding fill-in-the-blanks on the bandit class, experiment function, and results plotting.
Explore the optimistic initial values method in a bandit setup, initializing p estimates to five and n to one, and observe greedy exploration achieving near-optimal cumulative reward and convergence behavior.
Learn how UCB1 applies the upper confidence bound to balance exploration and exploitation in multi-armed bandits, using sample means and Hoeffding's inequality-based bounds.
Implement the UCB1 algorithm in a beginner exercise by completing the bandit-based experiment: initialize bandits, run experiment loop, pull samples from the true mean, update estimates, and plot results.
Explore a python implementation of ucb1 for bandit problems, detailing the bandit class, ucb function, and experiment loop that uses arg max to maximize cumulative reward.
Explore the bayesian bandits approach and Thompson sampling theory, updating the beta posterior for a Bernoulli arm as new data arrives in an online setting using conjugate priors.
Apply Thompson sampling to Bayesian bandits by drawing from posterior distributions instead of using upper bounds. Observe how updating posteriors shifts exploration toward the best bandits and reduces suboptimal plays.
Implement the Thompson sampling algorithm in code for a multi-armed bandit scenario, using a beta distribution with adjustable A and B priors, updating posteriors and plotting results.
Implement Thompson sampling in python to select bandits, drawing samples from beta posteriors, updating a and b, and exploring efficiently while confirming convergence to the optimal bandit.
Apply Thompson sampling to Gaussian rewards with known precision, using a normal prior for mu and deriving posterior parameters M and lambda; update after each observation.
Implement Thompson sampling for normally distributed rewards by updating a gaussian posterior with one-sample and sum-of-samples logic, then sample and compare bandits to drive exploration in bayesian A/B testing.
Explore a gaussian rewards bayesian bandit exercise: adapt the code from true means 1, 2, 3 to 5, 10, 20, and fix failures by adjusting the bayesian assumptions.
Learn why libraries cannot replace the math and coding for Bayesian bandits. Discover how backend engineering, data stores, and cross-language architectures drive practical implementation beyond a few algorithm lines.
Analyze nonstationary rewards in bandits and show how a constant learning rate yields an exponentially weighted moving average of the sample mean.
Explain that bandit designs should reflect the many-to-many modeling reality, not simplistic 1-to-1 setups, and emphasize naming by mathematical concepts over examples.
Explore the explore-exploit dilemma in bayesian machine learning for A/B testing, comparing slot-machine win rates and conversion rates while balancing data collection costs and optimal design choice.
Explore how a gaussian confidence interval approximation compares with the beta posterior for a click-through rate, illustrating convergence under the central limit theorem.
Explore how the bayesian bandit method operates in real time to optimize ad selection using online learning, client-server interaction, and adaptive click-through rate updates.
Explore how conjugate priors enable closed-form posterior updates in bayesian a/b testing, covering Bernoulli with beta priors, categorical, and Gaussian models for real-time Thompson sampling.
Explore conjugate priors for discrete outcomes by modeling die rolls with a categorical likelihood and a Dirichlet prior, then update to a Dirichlet posterior with alpha updates.
Apply bayesian machine learning in Python to a/b testing using simulated data and synthetic experiments, emphasizing that all data are the same and code remains reusable across datasets.
Clarify the appendix as an optional FAQ section that presents frequently asked questions, explains how to use the Q&A, and guides you toward course success.
Learn that installation lectures are general guidelines emphasizing principles over syntax and focus on Python prerequisites and pip usage, tailoring to practical course needs.
Install data science libraries on Windows with Anaconda, isolating environments; get numpy, scipy, matplotlib, pandas, scikit-learn, TensorFlow, and OpenAI Gym.
Learn to configure a cross-platform Python ML environment by installing numpy, scipy, matplotlib, pandas, IPython, Theano, and TensorFlow. Use virtual machines with Ubuntu on Windows for deep learning setups.
Learn to code machine learning algorithms by yourself, translating pseudocode into Python with fit and predict, using gradient descent, cost plots, and iterative learning.
Apply test driven development by writing tests first to shape the API and its implementation. Embrace independent learning, alternate theory and code, and use external resources to deepen understanding.
Demonstrates that using Jupyter Notebook is functionally identical to not using it. Shows that Python code works the same in notebook and console and highlights the importance of print statements.
Compare Python 2 and Python 3 choices, note differences like print with parentheses, range vs x range, and division rules, and follow git pull to stay updated in the repo.
This course is all about A/B testing.
A/B testing is used everywhere. Marketing, retail, newsfeeds, online advertising, and more.
A/B testing is all about comparing things.
If you’re a data scientist, and you want to tell the rest of the company, “logo A is better than logo B”, well you can’t just say that without proving it using numbers and statistics.
Traditional A/B testing has been around for a long time, and it’s full of approximations and confusing definitions.
In this course, while we will do traditional A/B testing in order to appreciate its complexity, what we will eventually get to is the Bayesian machine learning way of doing things.
First, we’ll see if we can improve on traditional A/B testing with adaptive methods. These all help you solve the explore-exploit dilemma.
You’ll learn about the epsilon-greedy algorithm, which you may have heard about in the context of reinforcement learning.
We’ll improve upon the epsilon-greedy algorithm with a similar algorithm called UCB1.
Finally, we’ll improve on both of those by using a fully Bayesian approach.
Why is the Bayesian method interesting to us in machine learning?
It’s an entirely different way of thinking about probability.
It’s a paradigm shift.
You’ll probably need to come back to this course several times before it fully sinks in.
It’s also powerful, and many machine learning experts often make statements about how they “subscribe to the Bayesian school of thought”.
In sum - it’s going to give us a lot of powerful new tools that we can use in machine learning.
The things you’ll learn in this course are not only applicable to A/B testing, but rather, we’re using A/B testing as a concrete example of how Bayesian techniques can be applied.
You’ll learn these fundamental tools of the Bayesian method - through the example of A/B testing - and then you’ll be able to carry those Bayesian techniques to more advanced machine learning models in the future.
See you in class!
"If you can't implement it, you don't understand it"
Or as the great physicist Richard Feynman said: "What I cannot create, I do not understand".
My courses are the ONLY courses where you will learn how to implement machine learning algorithms from scratch
Other courses will teach you how to plug in your data into a library, but do you really need help with 3 lines of code?
After doing the same thing with 10 datasets, you realize you didn't learn 10 things. You learned 1 thing, and just repeated the same 3 lines of code 10 times...
Suggested Prerequisites:
Probability (joint, marginal, conditional distributions, continuous and discrete random variables, PDF, PMF, CDF)
Python coding: if/else, loops, lists, dicts, sets
Numpy, Scipy, Matplotlib
WHAT ORDER SHOULD I TAKE YOUR COURSES IN?:
Check out the lecture "Machine Learning and AI Prerequisite Roadmap" (available in the FAQ of any of my courses, including the free Numpy course)
UNIQUE FEATURES
Every line of code explained in detail - email me any time if you disagree
No wasted time "typing" on the keyboard like other courses - let's be honest, nobody can really write code worth learning about in just 20 minutes from scratch
Not afraid of university-level math - get important details about algorithms that other courses leave out