Skip to content
Merged

Mnt #481

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ jobs:
ci-sklearn14,
ci-sklearn15,
ci-sklearn16,
ci-sklearn17
ci-sklearn17,
ci-sklearn-nightly
]

# Timeout: https://stackoverflow.com/a/59076067/4521646
Expand Down
18,435 changes: 9,459 additions & 8,976 deletions pixi.lock

Large diffs are not rendered by default.

29 changes: 18 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -194,17 +194,23 @@ python = "~=3.12.0"
quantile-forest = "~=1.3.11"

[tool.pixi.feature.sklearn16.dependencies]
scikit-learn = "*"
scikit-learn = "~=1.6.0"
fairlearn = "~=0.11.0"
pandas = "~=2.2.0"
numpy = "~=2.1.0"
scipy = "~=1.14.0"
# add when catboost supports 3.13
# https://github.com/catboost/catboost/issues/2748
# catboost = ">=1.0"
# add quantile-forest when it's released
# https://github.com/zillow/quantile-forest/issues/103
# quantile-forest = "~=1.4.0"
catboost = ">=1.0"
quantile-forest = "~=1.4.0"
python = "~=3.13.0"

[tool.pixi.feature.sklearn17.dependencies]
scikit-learn = "~=1.7.0"
fairlearn = "~=0.12.0"
pandas = "~=2.3.0"
numpy = "~=2.3.0"
scipy = "~=1.16.0"
catboost = ">=1.0"
quantile-forest = "~=1.4.0"
python = "~=3.13.0"


Expand All @@ -216,13 +222,13 @@ python = "~=3.13.0"
# ]


[tool.pixi.feature.sklearn17.pypi-options]
[tool.pixi.feature.sklearn-nightly.pypi-options]
# This is for the nightly channel to test the dev version of scikit-learn.
extra-index-urls = ["https://pypi.anaconda.org/scientific-python-nightly-wheels/simple"]

[tool.pixi.feature.sklearn17.pypi-dependencies]
[tool.pixi.feature.sklearn-nightly.pypi-dependencies]
# The version value here needs to be exact, hence == instead of ~=
scikit-learn = "==1.7.dev0"
scikit-learn = "==1.8.dev0"
fairlearn = "*"
pandas = "*"
numpy = "*"
Expand All @@ -235,7 +241,7 @@ lint = { cmd = "pre-commit install && pre-commit run -v --all-files --show-diff-
tests = { cmd = "pytest -vsl --cov=skops --cov-report=xml --cov-report=term-missing -m \"not inference\" skops" }

[tool.pixi.environments]
default = ["docs", "tests", "lint", "rich", "dev", "sklearn17"]
default = ["docs", "tests", "lint", "rich", "dev", "sklearn-nightly"]
lint = ["lint"]
docs = ["docs"]
ci-sklearn12 = ["rich", "tests", "lint", "sklearn12"]
Expand All @@ -244,3 +250,4 @@ ci-sklearn14 = ["rich", "tests", "lint", "sklearn14"]
ci-sklearn15 = ["rich", "tests", "lint", "sklearn15"]
ci-sklearn16 = ["rich", "tests", "lint", "sklearn16"]
ci-sklearn17 = ["rich", "tests", "lint", "sklearn17"]
ci-sklearn-nightly = ["rich", "tests", "lint", "sklearn-nightly"]
6 changes: 3 additions & 3 deletions skops/card/_model_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ class Card:
>>> from sklearn.linear_model import LogisticRegression
>>> from skops.card import Card
>>> X, y = load_iris(return_X_y=True)
>>> model = LogisticRegression(solver="liblinear", random_state=0).fit(X, y)
>>> model = LogisticRegression(solver="saga", random_state=0).fit(X, y)
>>> model_card = Card(model)
>>> y_pred = model.predict(X)
>>> model_card.add_metrics(**{
Expand Down Expand Up @@ -364,7 +364,7 @@ class Card:
>>> # add new subsection to an existing section by using "/"
>>> model_card.add(**{"Model description/Model name": "This model is called Bob"})
Card(
model=LogisticRegression(random_state=0, solver='liblinear'),
model=LogisticRegression(random_state=0, solver='saga'),
...
)
>>> # save the card to a README.md file
Expand Down Expand Up @@ -1022,7 +1022,7 @@ def add_permutation_importances(
ax,
x=permutation_importances.importances[sorted_importances_idx].T,
tick_labels=columns[sorted_importances_idx],
vert=False,
vert="horizontal",
)
ax.set_title(plot_name)
ax.set_xlabel("Decrease in Score")
Expand Down
10 changes: 6 additions & 4 deletions skops/card/tests/test_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ def expected_lines(self):
Card(
model=MyRegressor(param_1=10),
Model description/Training Procedure/Hyperparameters=TableSection(3x2),
Model description/Training Procedure/Model Plot=<style>#sk-co...v></div></div>,
Model description/Training Procedure/Model Plot=__anything__,
Model Card Authors=Jane Doe,
Figures/ROC=PlotSection(ROC.png),
Figures/Confusion matrix=PlotSection(confusion_matrix.jpg),
Expand All @@ -1077,14 +1077,16 @@ def expected_lines(self):
)
""" # noqa: E501
expected = textwrap.dedent(card_repr).strip()
expected = re.escape(expected)
expected = expected.replace("__anything__", ".*")
lines = expected.split("\n")
return lines

@pytest.mark.parametrize("meth", [repr, str])
def test_card_repr(self, card: Card, meth, expected_lines):
result = meth(card)
expected = "\n".join(expected_lines)
assert reprs_equal(expected, result)
assert re.match(expected, result)

@pytest.mark.parametrize("meth", [repr, str])
def test_card_repr_empty_card(self, meth):
Expand Down Expand Up @@ -1112,7 +1114,7 @@ def test_very_long_lines_are_shortened(self, card: Card, meth, expected_lines):
expected = "\n".join(expected_lines)

result = meth(card)
assert reprs_equal(expected, result)
assert re.match(expected, result)

@pytest.mark.parametrize("meth", [repr, str])
def test_without_model_attribute(self, card: Card, meth, expected_lines):
Expand All @@ -1123,7 +1125,7 @@ def test_without_model_attribute(self, card: Card, meth, expected_lines):
expected = "\n".join(expected_lines)

result = meth(card)
assert reprs_equal(expected, result)
assert re.match(expected, result)


class TestCardModelAttributeIsPath:
Expand Down
4 changes: 2 additions & 2 deletions skops/io/tests/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ def _assert_vals_equal(val1, val2, path=""):
elif isinstance(val1, (np.ndarray, np.generic)):
if len(val1.dtype) == 0:
# for arrays with at least 2 dimensions, check that contiguity is
# preserved
if val1.squeeze().ndim > 1:
# preserved, but only if the array is not a view
if val1.squeeze().ndim > 1 and val1.flags["OWNDATA"]:
assert (
val1.flags["C_CONTIGUOUS"] is val2.flags["C_CONTIGUOUS"]
), f"Path: {path}.flags"
Expand Down
2 changes: 1 addition & 1 deletion skops/io/tests/test_persist.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ def test_disk_and_memory_are_identical(tmp_path):
("scale", MinMaxScaler()),
])),
])),
("clf", LogisticRegression(random_state=0, solver="liblinear")),
("clf", LogisticRegression(random_state=0, solver="saga")),
]).fit([[0, 1], [2, 3], [4, 5]], [0, 1, 2])
# fmt: on

Expand Down
2 changes: 1 addition & 1 deletion skops/io/tests/test_visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def unsafe_function(x):
("scale", MinMaxScaler()),
])),
])),
("clf", LogisticRegression(random_state=0, solver="liblinear")),
("clf", LogisticRegression(random_state=0, solver="saga")),
]).fit([[0, 1], [2, 3], [4, 5]], [0, 1, 2])
# fmt: on
return pipeline
Expand Down
Loading