stanfordmlgroup / ngboost

Natural Gradient Boosting for Probabilistic Prediction

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Off-by-one error

juliangilbey opened this issue · comments

It seems that at this point:

ngboost/ngboost/ngboost.py

Lines 424 to 425 in 3a064b4

if max_iter and i == max_iter:
break

the code breaks out of the loop once there are max_iter+1 predictors rather than max_iter, as the enumeration starts from 0. One easy way to fix this is to add start=1 to the enumerate call; another is to test for i >= max_iter + 1.

I think that makes sense, feel free to submit a PR!

I've just submitted a PR for this; I also realise that I got one of my suggested fixes wrong - it should have been i >= max_iter - 1!

Thanks you for the PR, this will be published in the next release!