concurrent.futures to speed up predict
See original GitHub issueprediction 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:
- Created 5 years ago
- Comments:8 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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 parameteruncertainty_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, likem = Prophet(uncertainty_samples=100)
. This would make prediction much faster (~5x?). It will not effect the main forecast estimateyhat
, but will makeyhat_lower
andyhat_upper
a bit noisier.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 thatfuture
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.