Skip to content

Commit fd74658

Browse files
committed
fix problem with GaussianProcessRegressor. Back to ZERO failing tests
1 parent 2fb344a commit fd74658

File tree

2 files changed

+52
-32
lines changed

2 files changed

+52
-32
lines changed

causalpy/tests/test_integration_skl_examples.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from sklearn.gaussian_process.kernels import ExpSineSquared, WhiteKernel
2020

2121
import causalpy as cp
22-
from causalpy.skl_models import LinearRegression
22+
from causalpy.skl_models import LinearRegression, ScikitLearnModel
2323

2424

2525
@pytest.mark.integration
@@ -227,12 +227,18 @@ def test_rd_linear_with_gaussian_process():
227227
1. data is a dataframe
228228
2. skl_experiements.RegressionDiscontinuity returns correct type
229229
"""
230+
231+
# create a custom GaussianProcessRegressor class by subclassing
232+
# GaussianProcessRegressor and adding the ScikitLearnModel mixin
233+
class CustomGaussianProcessRegressor(GaussianProcessRegressor, ScikitLearnModel):
234+
pass
235+
230236
data = cp.load_data("rd")
231237
kernel = 1.0 * ExpSineSquared(1.0, 5.0) + WhiteKernel(1e-1)
232238
result = cp.RegressionDiscontinuity(
233239
data,
234240
formula="y ~ 1 + x + treated",
235-
model=GaussianProcessRegressor(kernel=kernel),
241+
model=CustomGaussianProcessRegressor(kernel=kernel),
236242
treatment_threshold=0.5,
237243
epsilon=0.001,
238244
)

docs/source/notebooks/rd_skl.ipynb

Lines changed: 44 additions & 30 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)