Skip to content

Commit a671b61

Browse files
committed
remove deprecated nuisance tuning and parameter setters for plr and pliv
1 parent df6be73 commit a671b61

File tree

3 files changed

+0
-122
lines changed

3 files changed

+0
-122
lines changed

doubleml/double_ml_pliv.py

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -281,17 +281,6 @@ def _check_data(self, obj_dml_data):
281281
'use DoubleMLPLR instead of DoubleMLPLIV.')
282282
return
283283

284-
# To be removed in version 0.6.0
285-
def set_ml_nuisance_params(self, learner, treat_var, params):
286-
if isinstance(self.score, str) & (self.score == 'partialling out') & (learner == 'ml_g'):
287-
warnings.warn(("Learner ml_g was renamed to ml_l. "
288-
"Please adapt the argument learner accordingly. "
289-
"The provided parameters are set for ml_l. "
290-
"The redirection will be removed in a future version."),
291-
DeprecationWarning, stacklevel=2)
292-
learner = 'ml_l'
293-
super(DoubleMLPLIV, self).set_ml_nuisance_params(learner, treat_var, params)
294-
295284
def _nuisance_est(self, smpls, n_jobs_cv, return_models=False):
296285
if self.partialX & (not self.partialZ):
297286
psi_elements, preds = self._nuisance_est_partial_x(smpls, n_jobs_cv, return_models)
@@ -523,41 +512,6 @@ def _nuisance_est_partial_xz(self, smpls, n_jobs_cv, return_models=False):
523512

524513
return psi_elements, preds
525514

526-
# To be removed in version 0.6.0
527-
def tune(self,
528-
param_grids,
529-
tune_on_folds=False,
530-
scoring_methods=None, # if None the estimator's score method is used
531-
n_folds_tune=5,
532-
search_mode='grid_search',
533-
n_iter_randomized_search=100,
534-
n_jobs_cv=None,
535-
set_as_params=True,
536-
return_tune_res=False):
537-
538-
if isinstance(self.score, str) and (self.score == 'partialling out') and (param_grids is not None) and \
539-
('ml_g' in param_grids) and ('ml_l' not in param_grids):
540-
warnings.warn(("Learner ml_g was renamed to ml_l. "
541-
"Please adapt the key of param_grids accordingly. "
542-
"The provided param_grids for ml_g are set for ml_l. "
543-
"The redirection will be removed in a future version."),
544-
DeprecationWarning, stacklevel=2)
545-
param_grids['ml_l'] = param_grids.pop('ml_g')
546-
547-
if isinstance(self.score, str) and (self.score == 'partialling out') and (scoring_methods is not None) and \
548-
('ml_g' in scoring_methods) and ('ml_l' not in scoring_methods):
549-
warnings.warn(("Learner ml_g was renamed to ml_l. "
550-
"Please adapt the key of scoring_methods accordingly. "
551-
"The provided scoring_methods for ml_g are set for ml_l. "
552-
"The redirection will be removed in a future version."),
553-
DeprecationWarning, stacklevel=2)
554-
scoring_methods['ml_l'] = scoring_methods.pop('ml_g')
555-
556-
tune_res = super(DoubleMLPLIV, self).tune(param_grids, tune_on_folds, scoring_methods, n_folds_tune,
557-
search_mode, n_iter_randomized_search, n_jobs_cv, set_as_params,
558-
return_tune_res)
559-
return tune_res
560-
561515
def _nuisance_tuning_partial_x(self, smpls, param_grids, scoring_methods, n_folds_tune, n_jobs_cv,
562516
search_mode, n_iter_randomized_search):
563517
x, y = check_X_y(self._dml_data.x, self._dml_data.y,

doubleml/double_ml_plr.py

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -163,17 +163,6 @@ def _check_data(self, obj_dml_data):
163163
'To fit a partially linear IV regression model use DoubleMLPLIV instead of DoubleMLPLR.')
164164
return
165165

166-
# To be removed in version 0.6.0
167-
def set_ml_nuisance_params(self, learner, treat_var, params):
168-
if isinstance(self.score, str) & (self.score == 'partialling out') & (learner == 'ml_g'):
169-
warnings.warn(("Learner ml_g was renamed to ml_l. "
170-
"Please adapt the argument learner accordingly. "
171-
"The provided parameters are set for ml_l. "
172-
"The redirection will be removed in a future version."),
173-
DeprecationWarning, stacklevel=2)
174-
learner = 'ml_l'
175-
super(DoubleMLPLR, self).set_ml_nuisance_params(learner, treat_var, params)
176-
177166
def _nuisance_est(self, smpls, n_jobs_cv, return_models=False):
178167
x, y = check_X_y(self._dml_data.x, self._dml_data.y,
179168
force_all_finite=False)
@@ -252,40 +241,6 @@ def _score_elements(self, y, d, l_hat, m_hat, g_hat, smpls):
252241

253242
return psi_a, psi_b
254243

255-
# To be removed in version 0.6.0
256-
def tune(self,
257-
param_grids,
258-
tune_on_folds=False,
259-
scoring_methods=None, # if None the estimator's score method is used
260-
n_folds_tune=5,
261-
search_mode='grid_search',
262-
n_iter_randomized_search=100,
263-
n_jobs_cv=None,
264-
set_as_params=True,
265-
return_tune_res=False):
266-
267-
if isinstance(self.score, str) and (self.score == 'partialling out') and (param_grids is not None) and \
268-
('ml_g' in param_grids) and ('ml_l' not in param_grids):
269-
warnings.warn(("Learner ml_g was renamed to ml_l. "
270-
"Please adapt the key of param_grids accordingly. "
271-
"The provided param_grids for ml_g are set for ml_l. "
272-
"The redirection will be removed in a future version."),
273-
DeprecationWarning, stacklevel=2)
274-
param_grids['ml_l'] = param_grids.pop('ml_g')
275-
276-
if isinstance(self.score, str) and (self.score == 'partialling out') and (scoring_methods is not None) and \
277-
('ml_g' in scoring_methods) and ('ml_l' not in scoring_methods):
278-
warnings.warn(("Learner ml_g was renamed to ml_l. "
279-
"Please adapt the key of scoring_methods accordingly. "
280-
"The provided scoring_methods for ml_g are set for ml_l. "
281-
"The redirection will be removed in a future version."),
282-
DeprecationWarning, stacklevel=2)
283-
scoring_methods['ml_l'] = scoring_methods.pop('ml_g')
284-
285-
tune_res = super(DoubleMLPLR, self).tune(param_grids, tune_on_folds, scoring_methods, n_folds_tune, search_mode,
286-
n_iter_randomized_search, n_jobs_cv, set_as_params, return_tune_res)
287-
return tune_res
288-
289244
def _nuisance_tuning(self, smpls, param_grids, scoring_methods, n_folds_tune, n_jobs_cv,
290245
search_mode, n_iter_randomized_search):
291246
x, y = check_X_y(self._dml_data.x, self._dml_data.y,

doubleml/tests/test_doubleml_exceptions.py

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -726,29 +726,6 @@ def test_doubleml_exception_tune():
726726
dml_plr_iv_type.tune({'ml_g': {'alpha': [0.05, 0.5]},
727727
'ml_m': {'alpha': [0.05, 0.5]}})
728728

729-
msg = 'Learner ml_g was renamed to ml_l. '
730-
with pytest.warns(DeprecationWarning, match=msg):
731-
dml_plr.tune({'ml_g': {'alpha': [0.05, 0.5]},
732-
'ml_m': {'alpha': [0.05, 0.5]}})
733-
with pytest.warns(DeprecationWarning, match=msg):
734-
dml_plr.tune({'ml_l': {'alpha': [0.05, 0.5]},
735-
'ml_m': {'alpha': [0.05, 0.5]}},
736-
scoring_methods={'ml_g': 'explained_variance',
737-
'ml_m': 'explained_variance'})
738-
739-
msg = 'Learner ml_g was renamed to ml_l. '
740-
with pytest.warns(DeprecationWarning, match=msg):
741-
dml_pliv.tune({'ml_g': {'alpha': [0.05, 0.5]},
742-
'ml_m': {'alpha': [0.05, 0.5]},
743-
'ml_r': {'alpha': [0.05, 0.5]}})
744-
with pytest.warns(DeprecationWarning, match=msg):
745-
dml_pliv.tune({'ml_l': {'alpha': [0.05, 0.5]},
746-
'ml_m': {'alpha': [0.05, 0.5]},
747-
'ml_r': {'alpha': [0.05, 0.5]}},
748-
scoring_methods={'ml_g': 'explained_variance',
749-
'ml_m': 'explained_variance',
750-
'ml_r': 'explained_variance'})
751-
752729
param_grids = {'ml_l': {'alpha': [0.05, 0.5]}, 'ml_m': {'alpha': [0.05, 0.5]}}
753730
msg = ('Invalid scoring_methods neg_mean_absolute_error. '
754731
'scoring_methods must be a dictionary. '
@@ -939,14 +916,6 @@ def test_doubleml_exception_learner():
939916
dml_iivm_hidden_classifier.set_ml_nuisance_params('ml_g0', 'd', {'max_iter': 314})
940917
dml_iivm_hidden_classifier.fit()
941918

942-
msg = 'Learner ml_g was renamed to ml_l. '
943-
with pytest.warns(DeprecationWarning, match=msg):
944-
dml_plr.set_ml_nuisance_params('ml_g', 'd', {'max_iter': 314})
945-
946-
msg = 'Learner ml_g was renamed to ml_l. '
947-
with pytest.warns(DeprecationWarning, match=msg):
948-
dml_pliv.set_ml_nuisance_params('ml_g', 'd', {'max_iter': 314})
949-
950919

951920
@pytest.mark.ci
952921
@pytest.mark.filterwarnings("ignore:Learner provided for")

0 commit comments

Comments
 (0)