Skip to content

Commit

Permalink
Fix inference for xgboost fitted with early-stopping (#1350)
Browse files Browse the repository at this point in the history
  • Loading branch information
avolkov-intel committed Jul 12, 2023
1 parent 1a6a655 commit 27d3f39
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/gbt_convertors.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ def get_gbt_model_from_xgboost(booster: Any) -> Any:
else:
is_regression = True

n_iterations = int(len(trees_arr) / (n_classes if n_classes > 2 else 1))
n_iterations = booster.best_iteration + 1
trees_arr = trees_arr[: n_iterations * (n_classes if n_classes > 2 else 1)]

# Create + base iteration
if is_regression:
Expand Down

0 comments on commit 27d3f39

Please sign in to comment.