Random Forest Constraint

Module for formulating a sklearn.ensemble.RandomForestRegressor or sklearn.ensemble.RandomForestClassifier into a PySCIPOpt Model.

pyscipopt_ml.sklearn.add_random_forest_regressor_constr(scip_model, random_forest_regressor, input_vars, output_vars=None, unique_naming_prefix='', **kwargs)

Formulate random_forest_regressor in scip_model.

The formulation predicts the values of output_vars using input_vars according to random_forest_regressor.

Parameters:
  • scip_model (PySCIPOpt Model) – The SCIP model where the predictor should be inserted.

  • random_forest_regressor (sklearn.ensemble.RandomForestRegressor) – The random forest regressor to insert as predictor.

  • input_vars (list or np.ndarray) – Decision variables used as input for random forest in model.

  • output_vars (list or np.ndarray, optional) – Decision variables used as output for random forest in model.

  • unique_naming_prefix (str, optional) – A unique naming prefix that is used before all variable and constraint names. This parameter is important if the SCIP model is later printed to file and many predictors are added to the same SCIP model.

Returns:

Object containing information about what was added to scip_model to formulate random_forest_regressor.

Return type:

RandomForestConstr

Note

See add_predictor_constr for acceptable values for input_vars and output_vars

pyscipopt_ml.sklearn.add_random_forest_classifier_constr(scip_model, random_forest_classifier, input_vars, output_vars=None, unique_naming_prefix='', **kwargs)

Formulate random_forest_classifier in scip_model.

The formulation predicts the values of output_vars using input_vars according to random_forest_classifier.

Parameters:
  • scip_model (PySCIPOpt Model) – The SCIP model where the predictor should be inserted.

  • random_forest_classifier (sklearn.ensemble.RandomForestClassifier) – The random forest classifier to insert as predictor.

  • input_vars (list or np.ndarray) – Decision variables used as input for random forest in model.

  • output_vars (list or np.ndarray, optional) – Decision variables used as output for random forest in model.

  • unique_naming_prefix (str, optional) – A unique naming prefix that is used before all variable and constraint names. This parameter is important if the SCIP model is later printed to file and many predictors are added to the same SCIP model.

Returns:

Object containing information about what was added to scip_model to formulate random_forest_classifier.

Return type:

RandomForestConstr

Note

See add_predictor_constr for acceptable values for input_vars and output_vars

class pyscipopt_ml.sklearn.random_forest.RandomForestConstr(scip_model, predictor, input_vars, output_vars, unique_naming_prefix, classification, **kwargs)

Class to model trained sklearn.ensemble.RandomForestRegressor or sklearn.ensemble.RandomForestClassifier with SCIP

Stores the changes to the SCIP Model for representing an instance into it. Inherits from AbstractPredictorConstr..