Skip to content

Enhance ROC Curve Display Tests for Improved Clarity and Maintainability #31254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
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
25 changes: 12 additions & 13 deletions sklearn/metrics/_plot/tests/test_roc_curve_display.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import numpy as np
import pytest
from numpy.testing import assert_allclose
from scipy.integrate import trapezoid
from scipy.integrate import trapz as trapezoid

from sklearn import clone
from sklearn.compose import make_column_transformer
from sklearn.datasets import load_breast_cancer, load_iris
from sklearn.datasets import load_breast_cancer, make_classification
from sklearn.exceptions import NotFittedError
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import RocCurveDisplay, auc, roc_curve
Expand All @@ -16,20 +16,19 @@


@pytest.fixture(scope="module")
def data():
X, y = load_iris(return_X_y=True)
# Avoid introducing test dependencies by mistake.
X.flags.writeable = False
y.flags.writeable = False
def data_binary():
X, y = make_classification(
n_samples=200,
n_features=20,
n_informative=5,
Comment on lines +22 to +23
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we need that many features (and so many uninformative ones), but I will leave to another maintainer to determine.

n_redundant=2,
flip_y=0.1,
class_sep=0.8,
random_state=42,
)
return X, y


@pytest.fixture(scope="module")
def data_binary(data):
X, y = data
return X[y < 2], y[y < 2]


@pytest.mark.parametrize("response_method", ["predict_proba", "decision_function"])
@pytest.mark.parametrize("with_sample_weight", [True, False])
@pytest.mark.parametrize("drop_intermediate", [True, False])
Expand Down
Loading