Skip to content

Commit

Permalink
Set bounds on output variables of decision trees
Browse files Browse the repository at this point in the history
  • Loading branch information
pobonomo committed Jan 8, 2025
1 parent da47d0d commit 1b79941
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/gurobi_ml/modeling/decision_tree/decision_tree_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ def _leaf_formulation(

if verbose:
timer.timing(f"Added {nex} linear constraints")
output.LB = np.maximum(output.LB, np.min(tree["value"]))
output.UB = np.minimum(output.UB, np.max(tree["value"]))


def _paths_formulation(gp_model, _input, output, tree, epsilon, _name_var):
Expand Down Expand Up @@ -207,8 +209,8 @@ def _paths_formulation(gp_model, _input, output, tree, epsilon, _name_var):
for i in range(outdim)
)

output.LB = np.min(tree.value)
output.UB = np.max(tree.value)
output.LB = np.maximum(output.LB, np.min(tree["value"]))
output.UB = np.minimum(output.UB, np.max(tree["value"]))


class AbstractTreeEstimator(AbstractPredictorConstr):
Expand Down

0 comments on commit 1b79941

Please sign in to comment.