0
$\begingroup$

Recently, I get to know about the hummingbird library for Python. I trained a RandomForest on a 10M-sized dataset with 2 labels. With sklearn it was taking 450 ms for inference. But after converting the same model to PyTorch, now it takes 128ms on CPU inference.

If both are running on the CPU, then why hummingbird's Pytorch model is faster than sklean model?

I am not getting what hummingbird does to my sklearn model to increases speed.

$\endgroup$
  • $\begingroup$ This question is off-topic here. Please, read our on-topic page: ai.stackexchange.com/help/on-topic. $\endgroup$ – nbro Jun 23 at 9:49
  • $\begingroup$ Are you using all cores? $\endgroup$ – Aditya Jun 23 at 13:46
0
$\begingroup$

It is difficult to answer your question without the access to your code. The best way to understand the difference is to profile the code and see where the bottlenecks are for your specific problem.

For this, you can use different profiling modules in python:

  1. cProfile
  2. python line profiler
| improve this answer | |
$\endgroup$
  • $\begingroup$ The code for both is the same just changed model . X=45 . for Sklearn Base model random_forest_model.predict(X). and the same model converted to PyTorch using using hummingbird humming_model.predict(X). $\endgroup$ – Hiren Namera Jun 23 at 8:09
  • $\begingroup$ Profiler also shows difference in .predict of PyTorch and sklearn. $\endgroup$ – Hiren Namera Jun 23 at 8:12
  • $\begingroup$ The idea is to use the profiler to dig around and isolate the bottlenecks deeper in the call graph of your program than the .profile method. $\endgroup$ – tmaric Jun 23 at 8:17
  • 1
    $\begingroup$ Sorry, not .profile, I meant .predict. $\endgroup$ – tmaric Jun 23 at 8:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.