Skip to content

Commit b0b9f56

Browse files
authored
Merge pull request #196 from DoubleML/s-inc-dev
Remove changed api decorators
2 parents 0979638 + 548eef8 commit b0b9f56

File tree

8 files changed

+11
-54
lines changed

8 files changed

+11
-54
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ The R package is also available on [GitHub](https://github.com/DoubleML/doubleml
2020
Documentation and website: [https://docs.doubleml.org/](https://docs.doubleml.org/)
2121

2222
**DoubleML** is currently maintained by
23-
[@MalteKurz](https://github.com/MalteKurz) and
24-
[@PhilippBach](https://github.com/PhilippBach).
23+
[@MalteKurz](https://github.com/MalteKurz), [@PhilippBach](https://github.com/PhilippBach) and [@SvenKlaassen](https://github.com/SvenKlaassen).
2524

2625
Bugs can be reported to the issue tracker at
2726
[https://github.com/DoubleML/doubleml-for-py/issues](https://github.com/DoubleML/doubleml-for-py/issues).

doubleml/double_ml_blp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
class DoubleMLBLP:
10-
"""Best linear predictor (BLP) for DoubleML with orthogonal signals.
10+
"""Best linear predictor (BLP) for DoubleML with orthogonal signals. Mainly used for CATE and GATE estimation for IRM models.
1111
1212
Parameters
1313
----------
@@ -110,7 +110,7 @@ def summary(self):
110110

111111
def fit(self):
112112
"""
113-
Estimate DoubleML models.
113+
Estimate DoubleMLBLP models.
114114
115115
Returns
116116
-------

doubleml/double_ml_cvar.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,16 @@ class DoubleMLCVAR(LinearScoreMixin, DoubleML):
7979
>>> import numpy as np
8080
>>> import doubleml as dml
8181
>>> from doubleml.datasets import make_irm_data
82-
>>> from sklearn.ensemble import RandomForestClassifier
82+
>>> from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor
8383
>>> np.random.seed(3141)
84-
>>> ml_g = RandomForestClassifier(n_estimators=100, max_features=20, max_depth=10, min_samples_leaf=2)
84+
>>> ml_g = RandomForestRegressor(n_estimators=100, max_features=20, max_depth=10, min_samples_leaf=2)
8585
>>> ml_m = RandomForestClassifier(n_estimators=100, max_features=20, max_depth=10, min_samples_leaf=2)
8686
>>> data = make_irm_data(theta=0.5, n_obs=500, dim_x=20, return_type='DataFrame')
8787
>>> obj_dml_data = dml.DoubleMLData(data, 'y', 'd')
8888
>>> dml_cvar_obj = dml.DoubleMLCVAR(obj_dml_data, ml_g, ml_m, treatment=1, quantile=0.5)
8989
>>> dml_cvar_obj.fit().summary
90-
coef std err t P>|t| 2.5 % 97.5 %
91-
d 1.462533 0.075714 19.316536 3.899567e-83 1.314136 1.61093
90+
coef std err t P>|t| 2.5 % 97.5 %
91+
d 1.591441 0.095781 16.615498 5.382582e-62 1.403715 1.779167
9292
"""
9393

9494
def __init__(self,

doubleml/double_ml_irm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ def gate(self, groups):
402402
groups : :class:`pandas.DataFrame`
403403
The group indicator for estimating the best linear predictor.
404404
Has to be dummy coded with shape ``(n_obs, d)``, where ``n_obs`` is the number of observations
405-
and ``d`` is the number of groups or ``(n_obs, 1)`` and contain the corresponding groups.
405+
and ``d`` is the number of groups or ``(n_obs, 1)`` and contain the corresponding groups (as str).
406406
407407
Returns
408408
-------

doubleml/double_ml_pliv.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,13 @@
66
from sklearn.dummy import DummyRegressor
77

88
import warnings
9-
from functools import wraps
109

1110
from .double_ml import DoubleML
1211
from .double_ml_data import DoubleMLData
1312
from .double_ml_score_mixins import LinearScoreMixin
1413
from ._utils import _dml_cv_predict, _dml_tune, _check_finite_predictions
1514

1615

17-
# To be removed in version 0.6.0
18-
def changed_api_decorator(f):
19-
@wraps(f)
20-
def wrapper(*args, **kwds):
21-
ml_l_missing = (len(set(kwds).intersection({'obj_dml_data', 'ml_l', 'ml_m', 'ml_r'})) + len(args)) < 5
22-
if ml_l_missing & ('ml_g' in kwds):
23-
warnings.warn(("The required positional argument ml_g was renamed to ml_l. "
24-
"Please adapt the argument name accordingly. "
25-
"ml_g is redirected to ml_l. "
26-
"The redirection will be removed in a future version."),
27-
DeprecationWarning, stacklevel=2)
28-
kwds['ml_l'] = kwds.pop('ml_g')
29-
return f(*args, **kwds)
30-
return wrapper
31-
32-
3316
class DoubleMLPLIV(LinearScoreMixin, DoubleML):
3417
"""Double machine learning for partially linear IV regression models
3518
@@ -117,7 +100,7 @@ class DoubleMLPLIV(LinearScoreMixin, DoubleML):
117100
:math:`X = (X_1, \\ldots, X_p)` consists of other confounding covariates, and :math:`\\zeta` and
118101
:math:`V` are stochastic errors.
119102
"""
120-
@changed_api_decorator
103+
121104
def __init__(self,
122105
obj_dml_data,
123106
ml_l,

doubleml/double_ml_plr.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,13 @@
44
from sklearn.base import clone
55

66
import warnings
7-
from functools import wraps
87

98
from .double_ml import DoubleML
109
from .double_ml_data import DoubleMLData
1110
from .double_ml_score_mixins import LinearScoreMixin
1211
from ._utils import _dml_cv_predict, _dml_tune, _check_finite_predictions, _check_is_propensity
1312

1413

15-
# To be removed in version 0.6.0
16-
def changed_api_decorator(f):
17-
@wraps(f)
18-
def wrapper(*args, **kwds):
19-
ml_l_missing = (len(set(kwds).intersection({'obj_dml_data', 'ml_l', 'ml_m'})) + len(args)) < 4
20-
if ml_l_missing & ('ml_g' in kwds):
21-
warnings.warn(("The required positional argument ml_g was renamed to ml_l. "
22-
"Please adapt the argument name accordingly. "
23-
"ml_g is redirected to ml_l. "
24-
"The redirection will be removed in a future version."),
25-
DeprecationWarning, stacklevel=2)
26-
kwds['ml_l'] = kwds.pop('ml_g')
27-
return f(*args, **kwds)
28-
return wrapper
29-
30-
3114
class DoubleMLPLR(LinearScoreMixin, DoubleML):
3215
"""Double machine learning for partially linear regression models
3316
@@ -110,7 +93,7 @@ class DoubleMLPLR(LinearScoreMixin, DoubleML):
11093
The high-dimensional vector :math:`X = (X_1, \\ldots, X_p)` consists of other confounding covariates,
11194
and :math:`\\zeta` and :math:`V` are stochastic errors.
11295
"""
113-
@changed_api_decorator
96+
11497
def __init__(self,
11598
obj_dml_data,
11699
ml_l,

doubleml/double_ml_pq.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class DoubleMLPQ(NonLinearScoreMixin, DoubleML):
2424
ml_g : classifier implementing ``fit()`` and ``predict()``
2525
A machine learner implementing ``fit()`` and ``predict_proba()`` methods (e.g.
2626
:py:class:`sklearn.ensemble.RandomForestClassifier`) for the nuisance function
27-
:math:`g_0(X) = E[Y <= \\theta | X, D=d]` .
27+
:math:`g_0(X) = E[Y <= \\theta | X, D=d]` .
2828
2929
ml_m : classifier implementing ``fit()`` and ``predict_proba()``
3030
A machine learner implementing ``fit()`` and ``predict_proba()`` methods (e.g.

doubleml/tests/test_doubleml_exceptions.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -715,10 +715,6 @@ def test_doubleml_exception_learner():
715715
with pytest.raises(ValueError, match=msg):
716716
_ = DoubleMLPLR(dml_data, Lasso(), LogisticRegression())
717717

718-
msg = 'ml_g was renamed to ml_l'
719-
with pytest.warns(DeprecationWarning, match=msg):
720-
_ = DoubleMLPLR(dml_data, ml_g=Lasso(), ml_m=ml_m) # pylint: disable=no-value-for-parameter
721-
722718
msg = r"For score = 'IV-type', learners ml_l and ml_g should be specified. Set ml_g = clone\(ml_l\)."
723719
with pytest.warns(UserWarning, match=msg):
724720
_ = DoubleMLPLR(dml_data, ml_l=Lasso(), ml_m=ml_m, score='IV-type')
@@ -727,10 +723,6 @@ def test_doubleml_exception_learner():
727723
with pytest.warns(UserWarning, match=msg):
728724
_ = DoubleMLPLR(dml_data, ml_l=Lasso(), ml_m=Lasso(), ml_g=Lasso(), score='partialling out')
729725

730-
msg = 'ml_g was renamed to ml_l'
731-
with pytest.warns(DeprecationWarning, match=msg):
732-
_ = DoubleMLPLIV(dml_data_pliv, ml_g=Lasso(), ml_m=ml_m, ml_r=ml_r) # pylint: disable=no-value-for-parameter
733-
734726
msg = "For score = 'IV-type', learners ml_l, ml_m, ml_r and ml_g need to be specified."
735727
with pytest.raises(ValueError, match=msg):
736728
_ = DoubleMLPLIV(dml_data_pliv, ml_l=ml_l, ml_m=ml_m, ml_r=ml_r,

0 commit comments

Comments
 (0)