Skip to content

Commit

Permalink
Fix an error when rebasing on main
Browse files Browse the repository at this point in the history
  • Loading branch information
pobonomo committed Oct 30, 2023
1 parent 06fa8e7 commit b54ec02
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
26 changes: 14 additions & 12 deletions notebooks/adversarial/adversarial_logistic_regression.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@
"%pip install -U ../../"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%pip install -i https://pypi.anaconda.org/gurobi-machinelearning-wheels-staging/simple gurobi-machinelearning==1.2.0.dev5"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -129,7 +138,7 @@
},
"outputs": [],
"source": [
"ex_prob.shape"
"from gurobi_ml.sklearn.logistic_regression import LogisticRegressionConstr"
]
},
{
Expand All @@ -140,19 +149,17 @@
},
"outputs": [],
"source": [
"from gurobi_ml.sklearn.logistic_regression import LogisticRegressionConstr"
"pwl_attr = LogisticRegressionConstr.default_pwl_attributes()\n",
"pwl_attr"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"metadata": {},
"outputs": [],
"source": [
"pwl_attr = LogisticRegressionConstr.default_pwl_attributes()\n",
"pwl_attr"
"pwl_attr['FuncNonLinear'] = 1"
]
},
{
Expand Down Expand Up @@ -267,11 +274,6 @@
},
"outputs": [],
"source": [
"m.Params.NonConvex = 2\n",
"m.Params.Obbt = 3\n",
"m.Params.PreSos1BigM = 1e6\n",
"m.Params.PreSos2BigM = 1e6\n",
"m.Params.PreSos2Encoding = 3\n",
"m.optimize()"
]
},
Expand Down
5 changes: 3 additions & 2 deletions src/gurobi_ml/sklearn/logistic_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,9 @@ def _multi_class_model(self, **kwargs):
outputvars = self._output
coefs = self.predictor.coef_
intercept = self.predictor.intercept_
self._create_output_vars(self._input, name="affine_trans")
affinevars = self._output
affinevars = self._gp_model.addMVar(
self.output.shape, lb=-gp.GRB.INFINITY, name="affine_trans"
)
self.affinevars = affinevars
self.gp_model.addConstr(
affinevars == self.input @ coefs.T + intercept, name="linreg"
Expand Down

0 comments on commit b54ec02

Please sign in to comment.