Going NUTS with ADVI: Exploring various Bayesian Inference techniques with Facebook Prophet
This paper presents a complete reimplementation of Facebook Prophet in PyMC to overcome the limitations of its default inference methods, enabling a detailed comparison of various Bayesian techniques—including MCMS, MAP, and Variational Inference—on time-series forecasting problems.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
The Big Picture: Trying to Predict the Future
Imagine you are trying to predict how many people will visit a specific Wikipedia page tomorrow. You have a tool called Facebook Prophet that is very good at this. It looks at the past data and tries to guess the future by breaking the problem down into three parts:
- The Trend: Is the page getting more popular over time? (Like a slowly rising hill).
- The Seasons: Do people visit more on weekends or during the holidays? (Like the tides going in and out).
- The Noise: Random, unpredictable bumps in the data.
The authors of this paper wanted to use this tool to test different ways of "solving" the math behind the prediction. They found that the original tool was a bit too rigid, so they rebuilt it from scratch using a new toolkit called PyMC.
The Three Ways to Solve the Puzzle
The paper compares three different "detectives" (inference methods) trying to solve the mystery of the future data. Think of them as three different ways to find the best route through a foggy mountain.
1. The "Best Guess" Detective (MAP Estimation)
- The Analogy: Imagine you are looking for the highest peak in a mountain range. This detective looks at the map, finds the single highest point, and says, "The answer is right here."
- What the paper says: This method is very fast. It gives you one specific number for the answer. However, it ignores the fact that there might be other high peaks nearby or that the ground might be shaky. It tells you where the answer is, but not how sure it is.
- Result: It was fast and gave good predictions, but it didn't tell the whole story about uncertainty.
2. The "Exhaustive Hiker" (Full MCMC / NUTS)
- The Analogy: This detective doesn't just pick one spot. They send out a whole team of hikers to walk every single path in the mountain range, taking thousands of steps to map out the entire terrain. They want to know the shape of the whole mountain, not just the top.
- What the paper says: This is the most accurate method. It explores the "posterior distribution" (the full shape of the possible answers). The authors tested three types of hikers:
- Metropolis-Hastings (MH): A hiker who takes random, slow steps. They got lost and didn't explore the mountain well.
- DMZ: A hiker who tries to copy the steps of others. They also struggled to cover the ground efficiently.
- NUTS (No-U-Turn Sampler): A super-smart hiker who uses a map and a compass (gradients) to walk efficiently. This was the winner. It found the best path quickly and mapped the mountain perfectly without wasting time.
- Result: NUTS was the most reliable, but it took longer to run than the "Best Guess" detective.
3. The "Fast Approximator" (Variational Inference / VI)
- The Analogy: Instead of walking the whole mountain, this detective looks at the mountain from a helicopter and draws a simple, smooth oval shape that looks like the mountain. It's a shortcut.
- What the paper says: This method tries to fit a simple shape (like a bell curve) to the complex data. It is much faster than the "Exhaustive Hiker."
- ADVI: Drew a simple oval. It was fast but got a bit too confident (the oval was too narrow).
- FullRank ADVI: Drew a more complex, stretched oval. It was also fast but got a bit too unsure (the oval was too wide).
- Result: It was the fastest method, but the "shape" of the answer wasn't perfectly accurate compared to the Exhaustive Hiker.
The Race Results
The authors put these detectives to the test using data about a famous football player's Wikipedia page. Here is how they compared:
- Speed: The "Fast Approximator" (VI) was the quickest. The "Best Guess" (MAP) was also very fast. The "Exhaustive Hiker" (NUTS) was slower but still manageable. The other hikers (MH and DMZ) were so slow and inefficient they didn't finish the job well.
- Accuracy: The "Exhaustive Hiker" (NUTS) gave the most trustworthy map of the future. The "Fast Approximator" was close but had some flaws in how it measured uncertainty. The "Best Guess" was good for a quick answer but missed the details.
- The Winner: For this specific problem, NUTS was the best overall choice. It wasn't the fastest, but it was the only one that successfully mapped the whole mountain without getting lost or making bad guesses.
The New Tool (The Rebuilt API)
The authors also mentioned that the original Facebook Prophet tool was like a pre-packaged meal: you could eat it, but you couldn't easily change the ingredients.
They rebuilt the tool in PyMC to be like a modular Lego set. Now, instead of just following a recipe, you can snap different pieces together (like "Linear Trend" + "Yearly Seasonality") to build exactly the model you want. This new "intuitive" way of building models makes it much easier to experiment with different ideas.
Summary
The paper is essentially a race to see how to best predict the future using a specific mathematical model.
- If you need speed and a single answer, use the Best Guess (MAP).
- If you need a quick approximation of uncertainty, use the Fast Approximator (VI).
- If you need the most accurate, reliable picture of the future and its uncertainties, the Exhaustive Hiker (NUTS) is the best choice, even if it takes a little more time.
The authors concluded that while the fast methods are tempting, the smart, thorough method (NUTS) provided the best balance of accuracy and reliability for their time-series forecasting problem.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.