question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

concurrent.futures to speed up predict

See original GitHub issue

prediction code into Stan centainly will have a huge speedup!

I make a predict() which takes about 5s, and these 3 sub-function takes about:

predict_trend() # less than 1 s
predict_seasonal_components() # about 2s
predict_uncertainty()   # about 3s

Since predict_seasonal_components() takes about 40% time, parallel execuing will sppedup about 40% comparing with in order executing whatever prediction code into Stan or not~

With Python3’s concurrent.futures module, writing parallel executing code seems very easy-- just a few lines?

_Originally posted by @leafonsword in https://github.com/facebook/prophet/issues/479#issuecomment-380656086_

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

13reactions
blethamcommented, Nov 15, 2018

Forecast time will depend directly on two things: the number of points for which you are making forecasts (that is, the number of rows in the future dataframe), and the parameter uncertainty_samples.

For the first, make sure that you are only making forecasts at points that you actually need forecasts for. For instance, by default the make_future_dataframe function will include all of the points in the history. If you don’t need predictions at all of the points in the history, then you can leave them out and there will be fewer predictions that need to be made.

The parameter uncertainty_samples determines the number of Monte Carlo simulations done to estimate future trend uncertainty. It is by default 1000, to estimate a 80% interval. If you are willing to have a bit more variance in your estimates of the uncertainty, you could reduce that to 100 when you instantiate the Prophet model, like m = Prophet(uncertainty_samples=100). This would make prediction much faster (~5x?). It will not effect the main forecast estimate yhat, but will make yhat_lower and yhat_upper a bit noisier.

2reactions
blethamcommented, Feb 28, 2020

How many rows are in future?

If you don’t need uncertainty estimation, then you can now disable that with uncertainty_samples=0 which makes things much faster. The latest version (v0.6) also includes #1311 which speeds up predict. Also be sure that future includes only the dates you actually care about (i.e. you may not need forecasts for every point in the history).

Otherwise, you could get the yhat forecast using uncertainty_samples=0 and then compute uncertainty intervals by making repeated calls to https://github.com/facebook/prophet/blob/46e56119835f851714d22b285d2e4081853b9fb1/python/fbprophet/forecaster.py#L1357-L1369 to get samples of yhat (the quantiles of which provide uncertainty intervals), and these calls could be parallelized.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Understanding concepts with concurrent futures to speed up ...
In my actual code, it's scraping thousands of websites, so I'm trying to speed it up, but make sure each iterable is ran...
Read more >
Speed Up Your Python Program With Concurrency
There's only one train of thought running through it, so you can predict what the next step is and how it will behave....
Read more >
Benchmarking Performances and Scaling of Time Series ...
Benchmarking Performances and Scaling of Time Series Forecast with Ray, Spark, Multiprocessing, and Concurrent futures ; 10–30x faster than ...
Read more >
Parallelising Python on Spark: Options for concurrency with ...
I've recently been working on an internal project to predict future disk space usage for our customers across thousands of disks.
Read more >
concurrent.futures — Launching parallel tasks — Python 3.11 ...
The concurrent.futures module provides a high-level interface for asynchronously executing callables. The asynchronous execution can be performed with threads, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found