
Explore Bayesian linear regression in Python, learning how priors create distributions over weights and predictions, enabling online updates and better generalization.
Access the code files and notebooks by clicking the resources tab and selecting the code link, and follow the on-page instructions or consult the FAQ for troubleshooting.
Explore the big picture of Bayesian machine learning and how priors, likelihoods, and posteriors shape parameter and output distributions. Learn benefits like uncertainty, regularization, and online updating.
Learn three guidelines to succeed: ask questions via the Q&A, meet prerequisites, and engage by taking handwritten notes for conceptual lectures and coding along with coding exercises.
Explore dog food lectures and how dogfooding your own talks improves clarity, while handwritten notes reinforce bayesian machine learning concepts for slower, clearer review.
the lecture shows that w_hat is normally distributed with mean w and variance sigma^2 over the sum of x_i^2, making it an unbiased estimator whose uncertainty decreases as data grows.
Perform a handwritten derivation of the linear regression estimator w_hat for y = w x + epsilon, and show its mean is w with variance sigma^2 over sum x_i^2.
Relate the squared error minimization to the maximum likelihood estimate by modeling y_i as normal with mean w x_i and variance sigma^2, showing that maximizing likelihood equals minimizing squared error.
Introduce map estimation by placing a normal prior on W and using Bayes rule to maximize the posterior instead of the likelihood, linking to L2 regularization and bias-variance tradeoff.
Explore how least squares equals maximum likelihood under normal errors, and how Bayesian map estimation with a normal prior yields shrinkage and a bias-variance trade-off.
Provide detailed feedback through the suggestion box form, sharing your background, course, difficulty, missing topics, and concrete examples to guide future course improvements.
Explore the bayesian approach to machine learning as a framework for deriving the bayesian version of linear regression, emphasizing fitting via the posterior of w and predictions as distributions.
Review conjugate priors for normal likelihood in Bayesian linear regression. Use a normal prior for w with mean zero and precision lambda to obtain posterior by proportionality, bypassing the denominator.
Derives the posterior for w in bayesian linear regression by combining normal prior and normal likelihood, yielding mu_w and sigma_w^2 with formulas involving sums of x_i^2 and x_i y_i.
Compute the posterior predictive distribution for y hat by integrating over uncertain weights w, instead of using the posterior mean, in bayesian linear regression.
Complete the square to turn a quadratic into a gaussian form, identify precision and mean, and simplify integrals through variable substitutions in Bayesian linear regression.
Show that the posterior for y hat is normal with mean mu_w x_hat and a variance combining model variance and w uncertainty, and that data reduce this variance toward sigma^2.
Derive the posterior of W in Bayesian linear regression using a Gaussian prior and likelihood, yielding a normal with mu_w and sigma_w^2 via precision updates.
This lecture develops the posterior predictive distribution for Bayesian linear regression on dog food, reducing to a normal with mean mu_w x_hat and variance sigma_w^2 x_hat^2 + sigma^2.
Derive the posterior distribution for the multivariate weight vector in bayesian linear regression, using a gaussian likelihood and a vector normal prior, to obtain the posterior mean and covariance.
Derive the posterior predictive distribution for multivariate Bayesian linear regression, yielding a normal with mean mu_w dot x_hat and variance sigma^2 plus x_hat transpose sigma_w x_hat.
Explore the prediction step in multivariate bayesian linear regression by integrating over the weight posterior to obtain the posterior predictive distribution for y hat given x hat and training data.
Explore how ChatGPT derives the posterior predictive distribution for Bayesian linear regression by treating the model as Gaussian and computing its mean and covariance via the law of total variance.
Prepare code for bayesian linear regression on an advertising dataset and learn to estimate unknown variance with least squares, use the precision matrix, and avoid inversion.
Implement Bayesian linear regression in Python, load and explore data, fit the posterior, and predict with mean and variance, comparing to classical methods using TV, radio, and newspaper ad spend.
Learn how to succeed in this course by asking questions in the q&a, verifying prerequisites, and implementing theory in code to connect background knowledge with practice.
Explore a skill-building roadmap that maps machine learning topics and their dependencies. Discover the progression from linear and logistic regression to deep learning, including neural networks, backpropagation, CNNs, and RNNs.
Discover the machine learning prerequisite roadmap from supervised and unsupervised learning to reinforcement learning, recurrent and convolutional networks, word embeddings, and ensemble methods in nlp paths.
Note that the Python notebooks aren’t on GitHub, log in, and use the official code link; turn off VPN to receive verification emails and resolve access issues.
Welcome to Bayesian Linear Regression!
I first started this course series on Bayesian Machine Learning many years ago, with a course on A/B Testing. I had always intended to expand the series (there's a lot to cover!) but kept getting pulled in other directions.
Today, I am happy to announce that the Bayesian Machine Learning series is finally back on track!
In the first course, a lot of students asked, "but where is the 'machine learning'?", since they thought of machine learning from the typical supervised/unsupervised parametric model paradigm. The A/B Testing course was never meant to look at such models, but that is exactly what this course is for.
If you've studied machine learning before, then you know that linear regression is the first model everyone learns about. We will approach Bayesian Machine Learning the same way.
Bayesian Linear Regression has many nice properties (easy transition from non-Bayesian Linear Regression, closed-form solutions, etc.). It is best and most efficient "first step" into the world of Bayesian Machine Learning.
Also, let's not forget that Linear Regression (including the Bayesian variety) is simply very practical in the real-world. Bayesian Machine Learning can get very mathematical, so it's easy to lose sight of the big picture - the real-world applications. By exposing yourself to Bayesian ideas slowly, you won't be overwhelmed by the math. You'll always keep the application in mind.
It should be stated however: Bayesian Machine Learning really is very mathematical. If you're looking for a scikit-learn-like experience, Bayesian Machine Learning is definitely too high-level for you. Most of the "work" involves algebraic manipulation. At the same time, if you can tough it out to the end, you will find the results really satisfying, and you will be awed by its elegance.
Sidenote: If you made it through my Linear Regression and A/B Testing courses, then you'll do just fine.
Suggested Prerequisites:
Python coding: if/else, loops, lists, dicts, sets
Numpy and Pandas coding: matrix and vector operations, loading a CSV file
Basic math: calculus, linear algebra, probability
Linear regression
Bayesian Machine Learning: A/B Testing in Python (know about conjugate priors)