Skip to content

Remove _hmmc.pyx; rewrite functions from this file as python+numpy #1825

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

kmike
Copy link
Contributor

@kmike kmike commented Apr 2, 2013

On my tests, this makes .fit (with 100 states) 3x faster, .eval (with 1000 states) 20% faster, .decode_viterbi (with 1000 states) 7x faster.

It might be possible to write a better Cython extension, so I didn't inline functions extracted from _hmmc.pyx to _BaseHMM methods.

…nctions.

On my tests, this makes .fit (with 100 states) 3x faster, .eval (with 1000 states) 20% faster, .decode_viterbi (with 1000 states) 7x faster.
@kmike kmike mentioned this pull request Apr 2, 2013
@larsmans
Copy link
Member

larsmans commented Apr 2, 2013

Wow. +1.

@amueller
Copy link
Member

amueller commented Apr 2, 2013

It would be nice to see how much could be gained by replacing the ndarray in the function definition by typed memory views.

@GaelVaroquaux
Copy link
Member

Very nice indeed! Thanks a lot.

It would be nice to see how much could be gained by replacing the ndarray in
the function definition by typed memory views.

Yup, but I don't think that this suggestion should delay merging this
contribution.

@kmike
Copy link
Contributor Author

kmike commented Apr 2, 2013

I'll take a look at possible speed gains in Cython extension in a couple of hours.

@kmike
Copy link
Contributor Author

kmike commented Apr 2, 2013

_forward, _backward and _compute_lneta had Python calls because _logsum was not cdef'ed (typed memoryviews has nothing to do with this - they could make code faster, but I didn't try them now because the main issue was not with ndarray).

This version: kmike@ab8b8a2 is 10-20% faster than in this pull request regarding .fit() and .eval() with 100 and 1000 states; with 2 states .fit and .eval are 5x faster with Cython than with vectorized numpy; _viterbi is still slow there (we could bring it on par just by copying python+numpy version).

@larsmans
Copy link
Member

With #1828 merged, this one can be closed, right? Feel free to reopen if I'm wrong.

@larsmans larsmans closed this Apr 16, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants