The current LMDD model implements the original paper method naively. Some easy optimizations are possible:
- "if var_max > res_[j] and if var_max > 0" can be collapsed into a single if statement because res_ is initialized as zeroes.
- var_max = self.dis_measure_(X[:i + 1]) - self.dis_measure_(X[:i]), because j = i, var_max is also equal to self.dis_measure_(X[:j + 1]) - self.dis_measure_(X[:j]), meaning we can replace these terms by var_max in the calculation of dk_diff.
- dk_diff >= var_max can be replaced by dk_diff - var_max >= 0
- We only need to add var_max into dk_diff if we actually assign it to res_[k], so the if statement can be further simplified.
This PR implements these changes in the most basic manner, leading to a small speed increase.
All Submissions Basics:
-
Have you followed the guidelines in our Contributing document? -
Have you checked to ensure there aren't other open Pull Requests for the same update/change? -
Have you checked all Issues to tie the PR to a specific one?
All Submissions Cores:
-
Have you added an explanation of what your changes do and why you'd like us to include them? -
Have you written new tests for your core changes, as applicable? -
Have you successfully ran tests with your changes locally? -
Does your submission pass tests, including CircleCI, Travis CI, and AppVeyor? -
Does your submission have appropriate code coverage? The cutoff threshold is 95% by Coversall.