cog-imperial / OMLT

Represent trained machine learning models as Pyomo optimization formulations
Other
281 stars 59 forks source link

Add tolerance to enforce strict inequalities in linear tree formulations #163

Closed emma58 closed 3 months ago

emma58 commented 3 months ago

This PR adds a tolerance at which to enforce ``strict'' inequalities in linear model trees: That is, the right branch will require that the feature value be greater than or equal to the bound plus this tolerance (epsilon). This means that users can tune epsilon in order to ensure that the MIP solution will match the tree prediction.

Additionally, the PR simplifies the implementation of the hybrid bigm linear tree formulation by using two modern pyomo.gdp transformations. This does mean that the linear tree formulations will rely on pyomo>=6.7.1 though, if that's okay.

Legal Acknowledgement\ By contributing to this software project, I agree my contributions are submitted under the BSD license. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 90.27%. Comparing base (d43643a) to head (d098622). Report is 3 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #163 +/- ## ========================================== - Coverage 90.36% 90.27% -0.09% ========================================== Files 32 32 Lines 2034 2005 -29 Branches 471 460 -11 ========================================== - Hits 1838 1810 -28 Misses 123 123 + Partials 73 72 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.


🚨 Try these New Features:

jalving commented 3 months ago

looks like a few minor ruff errors. you can try using # noqa: PLR0913 for the too many arguments one.

jalving commented 3 months ago

looks good to me. thanks for contributing @emma58!