pytorch-forecasting icon indicating copy to clipboard operation
pytorch-forecasting copied to clipboard

[ENH] Improve performance of `TimeSeriesDataSet.__getitem__`

Open denix56 opened this issue 3 years ago • 3 comments
trafficstars

Description

Pandas DataFrame is quite slow in comparison to numpy due to additional checks. By replacing it with np.recarray I was able to improve performance by 5-10%. Recarray allows us to have nice attribute access as in pandas, while improving performance. The raw numpy arrays are a bit faster than recarray, however the difference is not as big as between pandas and recarray. I have tested on Demand Forecasting with gpu=1, 0 workers and pin_memory=True.

denix56 avatar Dec 21 '21 18:12 denix56

Codecov Report

Merging #806 (eb706f9) into master (0b5892a) will increase coverage by 0.00%. The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #806   +/-   ##
=======================================
  Coverage   89.05%   89.06%           
=======================================
  Files          24       24           
  Lines        3829     3832    +3     
=======================================
+ Hits         3410     3413    +3     
  Misses        419      419           
Flag Coverage Δ
cpu 89.06% <100.00%> (+<0.01%) :arrow_up:
pytest 89.06% <100.00%> (+<0.01%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pytorch_forecasting/data/timeseries.py 93.12% <100.00%> (+0.02%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 0b5892a...eb706f9. Read the comment docs.

codecov-commenter avatar Dec 28 '21 17:12 codecov-commenter

I am tempted to merge this. Think we should run the example notebooks also because things might change there - even if only visual.

jdb78 avatar Feb 20 '22 00:02 jdb78

any news on this?

jobs-git avatar Jun 07 '25 20:06 jobs-git