cog-imperial / OMLT

Represent trained machine learning models as Pyomo optimization formulations
Other
257 stars 56 forks source link

Linear Tree Implementation #108

Closed bammari closed 9 months ago

bammari commented 1 year ago

This PR now allows users to embed linear model decision trees (trained with the linear-tree package https://github.com/cerlymarco/linear-tree) within OMLT. We include several univariate and bivariate tests to ensure the several implemented formulations are functional. Furthermore, this PR includes a preliminary Jupyter notebook that shows how to embed these linear model decision trees. using OMLT

In addition to this implementation, this PR also rewrites the way scaled_input_bounds are defined within the _setup_scaled_inputs_and_outputs function in formulation.py. Specifically, we pass a dictionary of tuples containing lower and upper bounds rather than constructing a bounds rule. test_maxpool_FullSpaceNNFormulation was failing without this change.

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 1 year ago

Codecov Report

Patch coverage: 98.94% and project coverage change: +0.54% :tada:

Comparison is base (dcca13c) 95.40% compared to head (349dfa0) 95.95%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #108 +/- ## ========================================== + Coverage 95.40% 95.95% +0.54% ========================================== Files 26 29 +3 Lines 1371 1656 +285 Branches 192 254 +62 ========================================== + Hits 1308 1589 +281 - Misses 34 35 +1 - Partials 29 32 +3 ``` | [Files Changed](https://app.codecov.io/gh/cog-imperial/OMLT/pull/108?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cog-imperial) | Coverage Δ | | |---|---|---| | [src/omlt/linear\_tree/lt\_definition.py](https://app.codecov.io/gh/cog-imperial/OMLT/pull/108?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cog-imperial#diff-c3JjL29tbHQvbGluZWFyX3RyZWUvbHRfZGVmaW5pdGlvbi5weQ==) | `98.69% <98.69%> (ø)` | | | [src/omlt/linear\_tree/lt\_formulation.py](https://app.codecov.io/gh/cog-imperial/OMLT/pull/108?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cog-imperial#diff-c3JjL29tbHQvbGluZWFyX3RyZWUvbHRfZm9ybXVsYXRpb24ucHk=) | `99.22% <99.22%> (ø)` | | | [src/omlt/dependencies.py](https://app.codecov.io/gh/cog-imperial/OMLT/pull/108?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cog-imperial#diff-c3JjL29tbHQvZGVwZW5kZW5jaWVzLnB5) | `100.00% <100.00%> (ø)` | | | [src/omlt/linear\_tree/\_\_init\_\_.py](https://app.codecov.io/gh/cog-imperial/OMLT/pull/108?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cog-imperial#diff-c3JjL29tbHQvbGluZWFyX3RyZWUvX19pbml0X18ucHk=) | `100.00% <100.00%> (ø)` | | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/cog-imperial/OMLT/pull/108/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cog-imperial)

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

rmisener commented 10 months ago

Please also add a description of the new Jupyter notebook in docs/notebooks.rst

rmisener commented 10 months ago

Going through minor things and want to make sure @bammari gets credit for this work. Would you please also add to this PR:

In README.rst

In the new notebook, please add the C&CE paper as a reference. As an example of how to do this, see bo_with_trees.ipynb

bammari commented 10 months ago

Going through minor things and want to make sure @bammari gets credit for this work. Would you please also add to this PR:

In README.rst

  • Please add a reference to the Computers & Chemical Engineering paper. State that if anyone uses the linear tree implementation, they should cite the C&CE paper.
  • Please add @bammari to the list of contributors at the bottom and state his funding.

In the new notebook, please add the C&CE paper as a reference. As an example of how to do this, see bo_with_trees.ipynb

Added reference to CACE paper in both the notebook and Readme.rst. I also updated the OMLT paper reference from Arxiv to Journal of ML Research in README.rst. In addition, added contribution statement - Bashar