Package: gurobi-machinelearning
Gurobi Machine LearningGurobi Machine Learning is anopen-sourcepython package to formulate trained regression models in agurobipymodel to be solved with the Gurobi solver.The package currently supports variousscikit-learnobjects. It has limited support for theKerasAPI ofTensorFlow,PyTorchandXGBoost. Only neural networks with ReLU activation can be used with Keras and PyTorch.DocumentationThe latest user manual is available onreadthedocs.Contact usFor questions related to using Gurobi Machine Learning please useGurobi's Forum.For reporting bugs, issues and feature requests pleaseopen an issue.If you encounter issues with Gurobi orgurobipyplease contactGurobi Support.InstallationDependenciesgurobi-machinelearningrequires the following:Python >= 3.9numpy>= 1.23.0gurobipy>= 10.0scipy>= 1.9.3The current version supports the following ML packages:torchscikit-learntensorflowXGBoostInstalling these packages is only required if the predictor you want to insert uses them
(i.e. to insert a Keras based predictor you need to havetensorflowinstalled).The up to date supported and tested versions of each package for the last release can befound in the documentation.Pip installationThe easiest way to installgurobi-machinelearningis usingpipin a virtual environment:(.venv)pipinstallgurobi-machinelearningThis will also install thenumpy,scipyandgurobipydependencies.Please note thatgurobipyis commercial software and requires a license. When installed via pip or conda,gurobipyships with a free license which is only for testing and can only solve models of limited size.Getting a Gurobi LicenseAlternatively to the bundled limited license, there are licenses that can handle models of all sizes.As a student or staff member of an academic institution you qualify for a free, full product license.
For more information, see:https://www.gurobi.com/academia/academic-program-and-licenses/For a commercial evaluation, you canrequest an evaluation license.Other useful resources to get started:https://www.gurobi.com/documentation/https://support.gurobi.com/hc/en-us/community/topics/DevelopmentWe value any level of experience in using Gurobi Machine Learning and would like to encourage you to
contribute directly to this project. Please see theContributing Guidefor more information.Source codeYou can clone the latest sources with the command:gitclonegit@github.com:Gurobi/gurobi-machinelearning.gitTestingAfter cloning the project, you can run the tests by invokingtox. For this, you will need to create a virtual
environment and activate it:python3.10-mvenv.venv
..venv/bin/activateThen, you can installtox(>= 3.26.0) and run a few basic tests:(.venv)pipinstalltox(.venv)tox-epy310,pre-commit,docstoxwill install, among others, the aforementioned ML packages into a separatevenv. These packages can be quite
large, so this might take a while.Running the full test setIn the above command, we only ran a subset of tests. Running the full set of tests requires having a Gurobi license
installed, and is done by running just thetoxcommand without the-eparameter:(.venv)pipinstalltox(.venv)toxIf you don't have a Gurobi license, you can still run the subset of tests, open a PR, and Github Actions will run the
tests with a full Gurobi license.Submitting a Pull RequestBefore opening a Pull Request, have a look at the fullContributing pageto make sure your code
complies with our guidelines.