Supported ML Models
The package currently supports various Scikit-Learn objects. It can also embed gradient boosting regression models from XGBoost, and LightGBM. Finally, it supports Sequential Neural Networks from PyTorch and Keras. In Mixed Integer Formulations, we briefly outline the MIP formulations used for the various ML models.
Scikit-learn
The following table lists the name of the models supported, the name of the corresponding object in the Python framework, and the function that can be used to insert it in a SCIP model.
Machine Learning Model |
Scikit-learn object |
Functions to insert |
|---|---|---|
Ordinary Least Square |
||
Partial Least Square |
||
Logistic Regression |
||
Neural-network |
||
Decision tree |
|
|
Gradient boosting |
|
|
Random Forest |
|
|
Support Vector Machines |
|
|
Centroid Clustering |
||
Pipeline |
||
MultiOutput |
|
PyTorch
In PyTorch, only torch.nn.Sequential objects are
supported.
They can be embedded in a SCIP model with the function
pyscipopt_ml.torch.add_sequential_constr().
Currently, only five types of layers are supported:
In the case of the final layer being an activation function used for classification, e.g.
Softmax, simply set
output_type==”classification” when inserting the predictor constraint.
The result is that the class with highest value
is assigned value 1 and all other classes are assigned value 0. Essentially, explicitly modelling
the final activation function for classification purposes is unnecessary from a MIP perspective as
the maximum value is preserved after the function is applied.
Keras
For Keras, only keras.Model and keras.Sequential are supported.
They can be embedded in a SCIP model with the function
pyscipopt_ml.keras.add_keras_constr().
The supported layer types and activation functions are the same as in torch (see above). This support holds for the classification case when the final layer is an unsupported activation function, e.g. softmax. Please read the above explanation in the PyTorch section, and in such use cases set output_type=”classification” when inserting the predictor constraint.
ONNX
For ONNX we also support standard feed forward neural networks. These must be provided in the ModelProto format.
They can be embedded in a SCIP model with the function
pyscipopt_ml.onnx.add_onnx_constr().
The supported layer types and activation functions are the same as in torch and keras (see above). The classification trick for the final layer is not done for ONNX models, so be warned that there will be a performance difference for imported classification models.
XGBoost
Models for XGBoost’s Scikit-Learn interface can be embedded in a SCIP model. The following table lists the name of the models supported, the name of the corresponding object in the Python framework, and the function that can be used to insert it in a SCIP model.
XGBoost object |
Function to insert |
|---|---|
Currently only “gbtree” boosters are supported.
LightGBM
Models for LightGBM’s Scikit-Learn interface can be embedded in a SCIP model. The following table lists the name of the models supported, the name of the corresponding object in the Python framework, and the function that can be used to insert it in a SCIP model.
LightGBM object |
Function to insert |
|---|---|
Currently “gbdt” and “rf” boosters are supported.