Using sklearn Linear and Logistic regression with numba

Hi folks,
I’m trying to call Linear and Logistic regressions from sklearn as a subroutine, but this results in an error
“Untyped global name ‘LogisticRegression’: cannot determine Numba type of <class ‘type’>”.

Is there a way to use these sklearn helpers in a @jit-ed numba function?
If not, what’s the best way to get the numba speedup while using sklearn?
Thanks!

Hi @kaiwenw

thank you for asking about this. I am not yet aware of any Numba <-> sklearn integration at this time.

The Numba supported Python and Numpy features (i.e. what Numba can compile) are listed here:

https://numba.readthedocs.io/en/stable/reference/pysupported.html

Best,

esc

hi @kaiwenw , Numba will compile your code, but it will not compile the libraries that you call. For that, the library author should apply Numba to their functions, in this case logistic regression.

In any case, logistic regression is probably already written in C, so there isn’t much speed up that you can get. If you still want to call logistic regression from jit code (for integration, not for speed), you can use objmode Callback into the Python Interpreter from within JIT’ed code — Numba 0.52.0-py3.7-linux-x86_64.egg documentation

cheers,
Luk