4 ms·
No kidding the Active Set solution in Cython is slow, it barely leverages Cython at all! It uses a Python list which is managed by Python and uses none of Cytho
by Sweyla 13y ago
No kidding the Active Set solution in Cython is slow, it barely leverages Cython at all! It uses a Python list which is managed by Python and uses none of Cython's static typing.
Implement the algorithm inside a "with nogil" and you will see some nice speed-ups. It won't look pretty, but for certain performance-sensitive code it will be worth it.
- ajtulloch 13y agoHi, author here. Yeah, the active set implementation in Cython is relatively slow - see [1] for where I discussed how I benchmarked the existing algorithm and demonstrated the PAVA implementation was faster. Then again, until two days ago the Cython active set algorithm was the production implementation of isotonic regression in scikit-learn, so it's not like it was a strawman example that I made up. [1]: http://tullo.ch/articles/speeding-up-isotonic-regression/ http://tullo.ch/articles/speeding-up-isotonic-regression/
- Sweyla 13y agoTry this implementation for PAVA: https://gist.github.com/gustavla/9499068 https://gist.github.com/gustavla/9499068 Also, how are you timing Python? When I run this on a sample size of 10 using IPython's %timeit, it takes a few microseconds, which is 2 orders of magnitude from what you report.