44from sklearn .linear_model import QuantileRegressor
55
66from skglm import GeneralizedLinearEstimator
7- from skglm .experimental .smooth_quantile_regressor import SmoothQuantileRegressor
7+ from skglm .experimental .smooth_quantile_regressor import (
8+ SmoothQuantileRegressor ,
9+ )
810from skglm .experimental .pdcd_ws import PDCD_WS
911from skglm .experimental .quantile_regression import Pinball
1012from skglm .penalties import L1
@@ -38,10 +40,13 @@ def test_issue276_regression():
3840 n_samples_small , n_samples_large = 100 , 1000
3941 n_features = 10
4042
41- # Create two datasets - small should work with PDCD_WS, large exhibits the issue
42- X_small , y_small = make_regression (n_samples = n_samples_small , n_features = n_features ,
43+ # Create two datasets, small should work with PDCD_WS,
44+ # large exhibits the issue
45+ X_small , y_small = make_regression (n_samples = n_samples_small ,
46+ n_features = n_features ,
4347 noise = 0.1 , random_state = 42 )
44- X_large , y_large = make_regression (n_samples = n_samples_large , n_features = n_features ,
48+ X_large , y_large = make_regression (n_samples = n_samples_large ,
49+ n_features = n_features ,
4550 noise = 0.1 , random_state = 42 )
4651
4752 X_small = StandardScaler ().fit_transform (X_small )
@@ -58,7 +63,8 @@ def test_issue276_regression():
5863 solver = "highs" ).fit (X_large , y_large )
5964
6065 # Verify PDCD_WS works fine on small dataset
61- pdcd_solver = PDCD_WS (max_iter = 500 , max_epochs = 500 , tol = 1e-4 , verbose = False )
66+ pdcd_solver = PDCD_WS (max_iter = 500 , max_epochs = 500 , tol = 1e-4 ,
67+ verbose = False )
6268 pdcd_solver .fit_intercept = True
6369
6470 estimator_small = GeneralizedLinearEstimator (
@@ -71,7 +77,8 @@ def test_issue276_regression():
7177 pdcd_small_loss = pinball_loss (y_small , y_pred_pdcd_small , tau = tau )
7278
7379 # Apply PDCD_WS to large dataset (should exhibit issue #276)
74- pdcd_solver = PDCD_WS (max_iter = 500 , max_epochs = 200 , tol = 1e-4 , verbose = False )
80+ pdcd_solver = PDCD_WS (max_iter = 500 , max_epochs = 200 , tol = 1e-4 ,
81+ verbose = False )
7582 pdcd_solver .fit_intercept = True
7683 estimator_large = GeneralizedLinearEstimator (
7784 datafit = Pinball (tau ),
@@ -122,8 +129,6 @@ def test_issue276_regression():
122129 assert len (sqr .stage_results_ ) > 0 , "Missing stage results" \
123130 "in SmoothQuantileRegressor"
124131
125- return rel_gap_pdcd_small , rel_gap_pdcd_large , rel_gap_sqr_large
126-
127132
128133def test_smooth_quantile_regressor_non_median ():
129134 """
@@ -135,7 +140,8 @@ def test_smooth_quantile_regressor_non_median():
135140 """
136141 np .random .seed (42 )
137142
138- X , y = make_regression (n_samples = 1000 , n_features = 10 , noise = 0.1 , random_state = 42 )
143+ X , y = make_regression (n_samples = 1000 , n_features = 10 , noise = 0.1 ,
144+ random_state = 42 )
139145 X = StandardScaler ().fit_transform (X )
140146
141147 tau = 0.8
@@ -149,7 +155,8 @@ def test_smooth_quantile_regressor_non_median():
149155
150156 # SmoothQuantileRegressor solution
151157 sqr = SmoothQuantileRegressor (
152- smoothing_sequence = [1.0 , 0.5 , 0.2 , 0.1 , 0.05 , 0.02 , 0.01 , 0.005 , 0.001 ],
158+ smoothing_sequence = [1.0 , 0.5 , 0.2 , 0.1 , 0.05 ,
159+ 0.02 , 0.01 , 0.005 , 0.001 ],
153160 quantile = tau ,
154161 alpha = alpha ,
155162 verbose = False ,
@@ -170,5 +177,3 @@ def test_smooth_quantile_regressor_non_median():
170177 n_neg = np .sum (residuals < 0 )
171178 assert abs (n_pos / (n_pos + n_neg ) - tau ) < 0.1 , \
172179 f"Residual distribution doesn't match target quantile { tau } "
173-
174- return rel_gap
0 commit comments