Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
Add vectorized implementation to the SSPD distance calculations: refrain from python for loops and take advantage of NumPy vectorized operations on ND-arrays to enhance performance.
NumPy functions work on numpy arrays and is tremendously faster due to the benefits of vectorization.
As can be seen in benchmark_sspd.csv, the Cython implementation (not changed) is ~20 times faster than the Python implementation. However, the new vectorized Python implementation is more than 11 times faster than the non-vectorized existing implementation.
So, this implementation is beneficial for those who'd rather use Python (and not Cython).
Files structure:
new files added under /traj_dist/pydist/:
basic_spherical_vectorized.py (vectorized version of basic_spherical.py)
sspd_spherical_vectorized.py (vectorized version of the spherical calculations in sspd.py)
Besides vectorized code version, some new functions (e.g s_pt_to_traj_dist) were added, due to our software needs (*can be removed, according to your preference)
Tests:
Added new test file /tests/sspd_tests.py, used to ensure code correctness by comparing to results recorded before any code changes were applied.
Recorded previous results can be found here: /data/benchmark_spherical_sspd_results.csv
Benchmark:
Updated the code and benchmark.csv results to include both the Cython and Python implementations (included solely the Cython benchmark before). Ran on computer: apple M1 pro, 16GB memory, macOS Monterey (12.6.1)
About myself and the project I'm working on:
This code extension was done as part of of my role @ Attenti
https://www.attentigroup.com/ now part of AlliedUniversal
The project I've been working on, was human movement (trajectory) prediction. The prediction model is a statistical one, and aimed to be used in Domestic Violence (DV) programs for early warning.
You are welcome to visit my linkedin page:
https://www.linkedin.com/in/gali-wohlstadter-6a101819/