0
$\begingroup$

I'm using SciKit-Learn's OneHotEncoder to encode some categorical features. However, the time complexity of the function seems to have an exponential dependence on the number of rows passed to it.

I would like to profile my code to figure out what's going on, particularly, I would like to use cumulative time to rank the profiler's output. I'm using Jupyter notebooks to write the code, how can this be achieved?

$\endgroup$

1 Answer 1

1
$\begingroup$

Jupyter has built in "cell magics", one of those cell magics is the prun function.

To use it, you put a call to prun at the top of the cell. For example:

%%prun
YOUR-CODE-BELOW

The %% at the beginning of the command tells Jupyter that this is a Cell Magic, if you don't include this, you'll get a syntax warning. To rank by cumulative time, you use the -s option and pass it "cumulative time":

%%prun -s "cumulative"
YOUR-CODE-BELOW

This will profile the code in your cell and show you the output in a pop-up box on the bottom of your screen.

$\endgroup$

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.