File tree Expand file tree Collapse file tree 2 files changed +52
-32
lines changed Expand file tree Collapse file tree 2 files changed +52
-32
lines changed Original file line number Diff line number Diff line change 19
19
from sklearn .gaussian_process .kernels import ExpSineSquared , WhiteKernel
20
20
21
21
import causalpy as cp
22
- from causalpy .skl_models import LinearRegression
22
+ from causalpy .skl_models import LinearRegression , ScikitLearnModel
23
23
24
24
25
25
@pytest .mark .integration
@@ -227,12 +227,18 @@ def test_rd_linear_with_gaussian_process():
227
227
1. data is a dataframe
228
228
2. skl_experiements.RegressionDiscontinuity returns correct type
229
229
"""
230
+
231
+ # create a custom GaussianProcessRegressor class by subclassing
232
+ # GaussianProcessRegressor and adding the ScikitLearnModel mixin
233
+ class CustomGaussianProcessRegressor (GaussianProcessRegressor , ScikitLearnModel ):
234
+ pass
235
+
230
236
data = cp .load_data ("rd" )
231
237
kernel = 1.0 * ExpSineSquared (1.0 , 5.0 ) + WhiteKernel (1e-1 )
232
238
result = cp .RegressionDiscontinuity (
233
239
data ,
234
240
formula = "y ~ 1 + x + treated" ,
235
- model = GaussianProcessRegressor (kernel = kernel ),
241
+ model = CustomGaussianProcessRegressor (kernel = kernel ),
236
242
treatment_threshold = 0.5 ,
237
243
epsilon = 0.001 ,
238
244
)
Load Diff Large diffs are not rendered by default.
You can’t perform that action at this time.
0 commit comments