@@ -259,14 +259,14 @@ def test_predict_output_shape(
259259 assert y_pis .shape == (X .shape [0 ], 2 , n_alpha )
260260
261261
262- @pytest .mark .parametrize ("delta" , [0.5 , 0.6 , 0.7 , 0.8 ])
263- @pytest .mark .parametrize ("n_calib" , [10 , 15 , 20 , 25 , 50 , 100 , 1000 ])
262+ @pytest .mark .parametrize ("delta" , [0.6 , 0.8 ])
263+ @pytest .mark .parametrize ("n_calib" , [10 + i for i in range ( 11 )] + [ 50 , 100 ])
264264def test_coverage_validity (delta : float , n_calib : int ) -> None :
265265 """
266266 Test that the prefit method provides valid coverage
267267 for different calibration data sizes and coverage targets.
268268 """
269- n_split , n_train , n_test = 1000 , 100 , 1000
269+ n_split , n_train , n_test = 100 , 100 , 1000
270270 n_all = n_train + n_calib + n_test
271271 X , y = make_regression (n_all , random_state = random_state )
272272
@@ -276,7 +276,7 @@ def test_coverage_validity(delta: float, n_calib: int) -> None:
276276 model = LinearRegression ()
277277 model .fit (X_train , y_train )
278278
279- coverage_list = []
279+ cov_list = []
280280 for _ in range (n_split ):
281281 mapie_reg = MapieRegressor (estimator = model , method = "base" , cv = "prefit" )
282282 X_cal , X_test , y_cal , y_test = \
@@ -285,14 +285,17 @@ def test_coverage_validity(delta: float, n_calib: int) -> None:
285285 _ , y_pis = mapie_reg .predict (X_test , alpha = 1 - delta )
286286 coverage = \
287287 regression_coverage_score (y_test , y_pis [:, 0 , 0 ], y_pis [:, 1 , 0 ])
288- coverage_list .append (coverage )
288+ cov_list .append (coverage )
289289
290290 # Here we are testing whether the average coverage is statistically
291291 # less than the target coverage.
292292 from scipy .stats import ttest_1samp
293- _ , pval = ttest_1samp (coverage_list , popmean = delta , alternative = 'less' )
293+ mean_low , mean_up = delta , delta + 1 / (n_calib + 1 )
294+ _ , pval_low = ttest_1samp (cov_list , popmean = mean_low , alternative = 'less' )
295+ _ , pval_up = ttest_1samp (cov_list , popmean = mean_up , alternative = 'greater' )
294296
295- np .testing .assert_array_less (0.01 , pval )
297+ np .testing .assert_array_less (0.01 , pval_low )
298+ np .testing .assert_array_less (0.01 , pval_up )
296299
297300
298301def test_same_results_prefit_split () -> None :
0 commit comments