Skip to content

Commit

Permalink
test: Reproduce issue
Browse files Browse the repository at this point in the history
  • Loading branch information
auguste-probabl committed Jan 10, 2025
1 parent 1a4151a commit 4c819ec
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions skore/tests/unit/sklearn/test_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,3 +925,28 @@ def test_estimator_report_get_X_y_and_data_source_hash(data_source):
assert X is X_test
assert y is y_test
assert data_source_hash == joblib.hash((X_test, y_test))


def test_estimator_has_side_effects():
"""Re-fitting the estimator outside the EstimatorReport
should not have an effect on the EstimatorReport's internal estimator"""
X, y = make_classification(n_classes=2, random_state=42)
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)
X_train2, _, y_train2, _ = train_test_split(X, y, random_state=420)

estimator = LogisticRegression().fit(X_train, y_train)
report = EstimatorReport(
estimator,
X_train=X_train,
X_test=X_test,
y_train=y_train,
y_test=y_test,
)

predictions_before = report.estimator.predict_proba(X_test)

estimator.fit(X_train2, y_train2)

predictions_after = report.estimator.predict_proba(X_test)

np.testing.assert_array_equal(predictions_before, predictions_after)

0 comments on commit 4c819ec

Please sign in to comment.