Skip to content

Commit f43c190

Browse files
suppress warnings, loosen tolerance, edit whats new
1 parent ba3d6b8 commit f43c190

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

doc/changes/0.5.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
Version 0.5 (in progress)
44
-------------------------
55
- Add support for fitting an intercept in :ref:`SqrtLasso <skglm.experimental.sqrt_lasso.SqrtLasso>` (PR: :gh:`298`)
6+
- Add experimental QuantileHuber and SmoothQuantileRegressor for quantile regression, and an example script (PR: :gh:`312`).

skglm/experimental/tests/test_quantile_huber.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from sklearn.linear_model import QuantileRegressor
55
from sklearn.datasets import make_regression
66
from skglm.experimental.quantile_huber import SmoothQuantileRegressor
7+
import warnings
78

89

910
@pytest.mark.parametrize('quantile', [0.3, 0.5, 0.7])
@@ -13,23 +14,25 @@ def test_quantile_huber_matches_sklearn(quantile, fit_intercept):
1314
QuantileRegressor."""
1415
X, y = make_regression(n_samples=1000, n_features=10, noise=0.1, random_state=42)
1516

16-
sk_est = QuantileRegressor(quantile=quantile, alpha=0.1,
17-
solver='highs', fit_intercept=fit_intercept).fit(X, y)
18-
smooth_est = SmoothQuantileRegressor(
19-
quantile=quantile,
20-
alpha=0.1,
21-
delta_init=0.5,
22-
delta_final=0.00001,
23-
n_deltas=15,
24-
verbose=False,
25-
fit_intercept=fit_intercept,
26-
).fit(X, y)
17+
with warnings.catch_warnings():
18+
warnings.filterwarnings("ignore", category=RuntimeWarning)
19+
sk_est = QuantileRegressor(quantile=quantile, alpha=0.1, solver='highs',
20+
fit_intercept=fit_intercept).fit(X, y)
21+
smooth_est = SmoothQuantileRegressor(
22+
quantile=quantile,
23+
alpha=0.1,
24+
delta_init=0.5,
25+
delta_final=0.00001,
26+
n_deltas=15,
27+
verbose=False,
28+
fit_intercept=fit_intercept,
29+
).fit(X, y)
2730

2831
assert not np.allclose(sk_est.coef_, 0, atol=1e-8), (
2932
"All coefficients in sk_est are (near) zero: alpha may be too high.")
3033
assert not np.allclose(smooth_est.coef_, 0, atol=1e-8), (
3134
"All coefficients in smooth_est are (near) zero: alpha may be too high.")
3235

33-
assert_allclose(smooth_est.coef_, sk_est.coef_, atol=1e-3)
36+
assert_allclose(smooth_est.coef_, sk_est.coef_, atol=2e-3)
3437
if fit_intercept:
35-
assert_allclose(smooth_est.intercept_, sk_est.intercept_, atol=1e-3)
38+
assert_allclose(smooth_est.intercept_, sk_est.intercept_, atol=2e-3)

0 commit comments

Comments
 (0)