Skip to content

Commit

Permalink
Update lambdamart.py
Browse files Browse the repository at this point in the history
Solve the overflow caused by  very small sumd.
  • Loading branch information
forin-xyz authored Jul 21, 2017
1 parent 98addcb commit 7edc56e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pyltr/models/lambdamart.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def _update_terminal_regions(self, tree, X, y, lambdas, deltas, y_pred,
terminal_region = np.where(masked_terminal_regions == leaf)
suml = np.sum(lambdas[terminal_region])
sumd = np.sum(deltas[terminal_region])
tree.value[leaf, 0, 0] = 0.0 if sumd == 0.0 else (suml / sumd)
tree.value[leaf, 0, 0] = 0.0 if abs(sumd) < 1e-300 else (suml / sumd)

y_pred += tree.value[terminal_regions, 0, 0] * self.learning_rate

Expand Down

0 comments on commit 7edc56e

Please sign in to comment.