Skip to content

Commit

Permalink
Merge pull request #311 from pobonomo/sklearn1.5
Browse files Browse the repository at this point in the history
Update to scikit learn 1.5
  • Loading branch information
pobonomo authored Jun 13, 2024
2 parents 5d2c623 + 7297ab9 commit de59081
Show file tree
Hide file tree
Showing 97 changed files with 34 additions and 27 deletions.
14 changes: 7 additions & 7 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
gurobipy==11.0.1
gurobipy-pandas==1.1.1
gurobipy-pandas==1.1.2
ipykernel==6.29.4
jupytext==1.16.1
jupytext==1.16.2
matplotlib==3.6.0
matplotlib-inline==0.1.7
sphinxcontrib_bibtex==2.6.2
numpy==1.26.4
numpydoc==1.7.0
pandas==2.2.2
scikit-learn==1.4.1.post1
scikit-learn==1.4.2
seaborn==0.13.2
Sphinx==7.2.6
Sphinx==7.3.7
sphinx-copybutton==0.5.2
sphinx-rtd-theme==2.0.0
nbsphinx==0.9.3
jupytext==1.16.1
sphinx_design==0.5.0
jupytext==1.16.2
sphinx_design==0.6.0
sphinx-pyproject==0.3.0
pydata-sphinx-theme==0.15.2
.
sphinx-gallery==0.15.0
sphinx-gallery==0.16.0
2 changes: 1 addition & 1 deletion requirements.pandas.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pandas==2.2.2
gurobipy-pandas==1.1.1
gurobipy-pandas==1.1.2
2 changes: 1 addition & 1 deletion requirements.sklearn.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
scikit-learn==1.4.1.post1
scikit-learn==1.5.0
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
gurobipy==11.0.1
numpy==1.26.4
pandas==2.2.2
scikit-learn==1.4.1.post1
scikit-learn==1.4.2
seaborn==0.13.2
.
7 changes: 1 addition & 6 deletions src/gurobi_ml/sklearn/pls_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

"""Module for formulating :external+sklearn:py:class:`sklearn.cross_decomposition.PLSRegression` in a gurobipy model."""

import numpy as np

from ..modeling import AbstractPredictorConstr
from .skgetter import SKgetter
Expand Down Expand Up @@ -87,14 +86,10 @@ def __init__(
def _add_regression_constr(self):
"""Add the prediction constraints to Gurobi."""
x_mean = self.predictor._x_mean
x_std = self.predictor._x_std
coefs = self.predictor.coef_.T
intercept = self.predictor.intercept_
self.gp_model.addConstr(
self.output
== self.input @ (coefs / x_std[:, np.newaxis])
- x_mean / x_std @ coefs
+ intercept,
self.output == self.input @ coefs - x_mean @ coefs + intercept,
name="plsreg",
)

Expand Down
2 changes: 1 addition & 1 deletion tests/fixed_formulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class FixedRegressionModel(unittest.TestCase):
Gurobi is identical to what the predict function would return."""

def setUp(self) -> None:
self.rng = np.random.default_rng(2)
self.rng = np.random.default_rng(4)

def additional_test(self, predictor, pred_constr):
"""Define this to do additional tests"""
Expand Down
Binary file modified tests/predictors/circle__decisiontreeregressor.joblib
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified tests/predictors/circle__randomforestregressor.joblib
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/predictors/circle_sklearn_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.1.post1
1.5.0
Binary file modified tests/predictors/diabetes__decisiontreeregressor.joblib
Binary file not shown.
Binary file modified tests/predictors/diabetes__gradientboostingregressor.joblib
Binary file not shown.
Binary file modified tests/predictors/diabetes__lasso.joblib
Binary file not shown.
Binary file modified tests/predictors/diabetes__linearregression.joblib
Binary file not shown.
Binary file modified tests/predictors/diabetes__mlpregressor_20x20.joblib
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified tests/predictors/diabetes__pipeline_standardscaler_lasso.joblib
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified tests/predictors/diabetes__pipeline_standardscaler_ridge.joblib
Binary file not shown.
Binary file modified tests/predictors/diabetes__plscanonical.joblib
Binary file not shown.
Binary file modified tests/predictors/diabetes__plsregression.joblib
Binary file not shown.
Binary file modified tests/predictors/diabetes__randomforestregressor.joblib
Binary file not shown.
Binary file modified tests/predictors/diabetes__ridge.joblib
Binary file not shown.
Binary file modified tests/predictors/diabetes_pandas__decisiontreeregressor.joblib
Binary file not shown.
Binary file modified tests/predictors/diabetes_pandas__gradientboostingregressor.joblib
Binary file not shown.
Binary file modified tests/predictors/diabetes_pandas__lasso.joblib
Binary file not shown.
Binary file modified tests/predictors/diabetes_pandas__linearregression.joblib
Binary file not shown.
Binary file modified tests/predictors/diabetes_pandas__mlpregressor_20x20.joblib
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified tests/predictors/diabetes_pandas__plscanonical.joblib
Binary file not shown.
Binary file modified tests/predictors/diabetes_pandas__plsregression.joblib
Binary file not shown.
Binary file modified tests/predictors/diabetes_pandas__randomforestregressor.joblib
Binary file not shown.
Binary file modified tests/predictors/diabetes_pandas__ridge.joblib
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/predictors/diabetes_pandas_sklearn_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.1.post1
1.5.0
2 changes: 1 addition & 1 deletion tests/predictors/diabetes_sklearn_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.1.post1
1.5.0
Binary file modified tests/predictors/iris__logisticregression.joblib
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/predictors/iris_sklearn_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.1.post1
1.5.0
Binary file modified tests/predictors/mnist__mlpclassifier.joblib
Binary file not shown.
Binary file modified tests/predictors/mnist__pipeline_mlpclassifier.joblib
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/predictors/mnist_sklearn_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.1.post1
1.5.0
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/predictors/wages_sklearn_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.1.post1
1.5.0
10 changes: 7 additions & 3 deletions tests/test_sklearn/test_sklearn_formulations.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,13 @@ def test_diabetes_sklearn(self):

for regressor in cases:
onecase = cases.get_case(regressor)
self.do_one_case(onecase, X, 5, "all", float_type=np.float32)
self.do_one_case(onecase, X, 6, "pairs", float_type=np.float32)
self.do_one_case(onecase, X, 5, "all", float_type=np.float32, no_debug=True)
self.do_one_case(onecase, X, 5, "all", float_type=np.float32, epsilon=1e-5)
self.do_one_case(
onecase, X, 6, "pairs", float_type=np.float32, epsilon=1e-5
)
self.do_one_case(
onecase, X, 5, "all", float_type=np.float32, no_debug=True, epsilon=1e-5
)
self.do_one_case(
onecase, X, 6, "pairs", float_type=np.float32, no_debug=True
)
Expand Down
10 changes: 9 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# and then run "tox" from this directory.

[tox]
envlist = {py39,py310,py311,py312}-{lightgbm,keras,pytorch,sklearn,xgboost,no_deps,all_deps}-{gurobi10,gurobi11},pre-commit,docs,examples-{gurobi10,gurobi11}
envlist = {py39,py310,py311,py312}-{lightgbm,keras,pandas,pytorch,sklearn,xgboost,no_deps,all_deps}-{gurobi10,gurobi11},pre-commit,docs,examples-{gurobi10,gurobi11}
isolated_build = True

[gh-actions]
Expand Down Expand Up @@ -118,6 +118,14 @@ deps =
commands =
pytest tests/test_no_deps

[testenv:{py39,py310,py311,py312}-pandas-{gurobi10,gurobi11}]
deps =
{[base]deps}
-r{toxinidir}/requirements.pandas.txt
-r{toxinidir}/requirements.sklearn.txt
commands =
pytest tests/test_pandas

[testenv:{py39,py310,py311,py312}-all_deps-{gurobi10,gurobi11}]
deps =
{[base]deps}
Expand Down

0 comments on commit de59081

Please sign in to comment.