diff --git a/econml/_ortho_learner.py b/econml/_ortho_learner.py index a40f2cb8a..bead066e9 100644 --- a/econml/_ortho_learner.py +++ b/econml/_ortho_learner.py @@ -543,10 +543,8 @@ def _prefit(self, Y, T, *args, only_final=False, **kwargs): super()._prefit(Y, T, *args, **kwargs) - @_deprecate_positional("X, W, and Z should be passed by keyword only. In a future release " - "we will disallow passing X, W, and Z by position.", ['X', 'W', 'Z']) @BaseCateEstimator._wrap_fit - def fit(self, Y, T, X=None, W=None, Z=None, *, sample_weight=None, freq_weight=None, sample_var=None, groups=None, + def fit(self, Y, T, *, X=None, W=None, Z=None, sample_weight=None, freq_weight=None, sample_var=None, groups=None, cache_values=False, inference=None, only_final=False, check_input=True): """ Estimate the counterfactual model from data, i.e. estimates function :math:`\\theta(\\cdot)`. diff --git a/econml/dml/_rlearner.py b/econml/dml/_rlearner.py index 7ac9b75f6..9bb904628 100644 --- a/econml/dml/_rlearner.py +++ b/econml/dml/_rlearner.py @@ -326,9 +326,7 @@ def _gen_ortho_learner_model_nuisance(self): def _gen_ortho_learner_model_final(self): return _ModelFinal(self._gen_rlearner_model_final()) - @_deprecate_positional("X, and should be passed by keyword only. In a future release " - "we will disallow passing X and W by position.", ['X', 'W']) - def fit(self, Y, T, X=None, W=None, *, sample_weight=None, freq_weight=None, sample_var=None, groups=None, + def fit(self, Y, T, *, X=None, W=None, sample_weight=None, freq_weight=None, sample_var=None, groups=None, cache_values=False, inference=None): """ Estimate the counterfactual model from data, i.e. estimates function :math:`\\theta(\\cdot)`. diff --git a/econml/dml/causal_forest.py b/econml/dml/causal_forest.py index b305b4a68..e62558e70 100644 --- a/econml/dml/causal_forest.py +++ b/econml/dml/causal_forest.py @@ -704,10 +704,7 @@ def tune(self, Y, T, *, X=None, W=None, return self # override only so that we can update the docstring to indicate support for `blb` - - @_deprecate_positional("X and W should be passed by keyword only. In a future release " - "we will disallow passing X and W by position.", ['X', 'W']) - def fit(self, Y, T, X=None, W=None, *, sample_weight=None, groups=None, + def fit(self, Y, T, *, X=None, W=None, sample_weight=None, groups=None, cache_values=False, inference='auto'): """ Estimate the counterfactual model from data, i.e. estimates functions τ(·,·,·), ∂τ(·,·). diff --git a/econml/dml/dml.py b/econml/dml/dml.py index d26f7143b..b35bb0b7e 100644 --- a/econml/dml/dml.py +++ b/econml/dml/dml.py @@ -461,9 +461,7 @@ def _gen_rlearner_model_final(self): return _FinalWrapper(self._gen_model_final(), self.fit_cate_intercept, self._gen_featurizer(), False) # override only so that we can update the docstring to indicate support for `LinearModelFinalInference` - @_deprecate_positional("X and W should be passed by keyword only. In a future release " - "we will disallow passing X and W by position.", ['X', 'W']) - def fit(self, Y, T, X=None, W=None, *, sample_weight=None, freq_weight=None, sample_var=None, groups=None, + def fit(self, Y, T, *, X=None, W=None, sample_weight=None, freq_weight=None, sample_var=None, groups=None, cache_values=False, inference='auto'): """ Estimate the counterfactual model from data, i.e. estimates functions τ(·,·,·), ∂τ(·,·). @@ -615,9 +613,7 @@ def _gen_model_final(self): return StatsModelsLinearRegression(fit_intercept=False) # override only so that we can update the docstring to indicate support for `StatsModelsInference` - @_deprecate_positional("X and W should be passed by keyword only. In a future release " - "we will disallow passing X and W by position.", ['X', 'W']) - def fit(self, Y, T, X=None, W=None, *, sample_weight=None, freq_weight=None, sample_var=None, groups=None, + def fit(self, Y, T, *, X=None, W=None, sample_weight=None, freq_weight=None, sample_var=None, groups=None, cache_values=False, inference='auto'): """ Estimate the counterfactual model from data, i.e. estimates functions τ(·,·,·), ∂τ(·,·). @@ -826,9 +822,7 @@ def _gen_model_final(self): n_jobs=self.n_jobs, random_state=self.random_state) - @_deprecate_positional("X and W should be passed by keyword only. In a future release " - "we will disallow passing X and W by position.", ['X', 'W']) - def fit(self, Y, T, X=None, W=None, *, sample_weight=None, groups=None, + def fit(self, Y, T, *, X=None, W=None, sample_weight=None, groups=None, cache_values=False, inference='auto'): """ Estimate the counterfactual model from data, i.e. estimates functions τ(·,·,·), ∂τ(·,·). @@ -1157,9 +1151,7 @@ def _gen_rlearner_model_final(self): # override only so that we can update the docstring to indicate # support for `GenericSingleTreatmentModelFinalInference` - @_deprecate_positional("X and W should be passed by keyword only. In a future release " - "we will disallow passing X and W by position.", ['X', 'W']) - def fit(self, Y, T, X=None, W=None, *, sample_weight=None, freq_weight=None, sample_var=None, groups=None, + def fit(self, Y, T, *, X=None, W=None, sample_weight=None, freq_weight=None, sample_var=None, groups=None, cache_values=False, inference='auto'): """ Estimate the counterfactual model from data, i.e. estimates functions τ(·,·,·), ∂τ(·,·). diff --git a/econml/dr/_drlearner.py b/econml/dr/_drlearner.py index 47a0833e6..1cc88eda8 100644 --- a/econml/dr/_drlearner.py +++ b/econml/dr/_drlearner.py @@ -455,9 +455,7 @@ def _gen_model_final(self): def _gen_ortho_learner_model_final(self): return _ModelFinal(self._gen_model_final(), self._gen_featurizer(), self.multitask_model_final) - @_deprecate_positional("X and W should be passed by keyword only. In a future release " - "we will disallow passing X and W by position.", ['X', 'W']) - def fit(self, Y, T, X=None, W=None, *, sample_weight=None, freq_weight=None, sample_var=None, groups=None, + def fit(self, Y, T, *, X=None, W=None, sample_weight=None, freq_weight=None, sample_var=None, groups=None, cache_values=False, inference='auto'): """ Estimate the counterfactual model from data, i.e. estimates function :math:`\\theta(\\cdot)`. @@ -849,9 +847,7 @@ def _gen_model_final(self): def _gen_ortho_learner_model_final(self): return _ModelFinal(self._gen_model_final(), self._gen_featurizer(), False) - @_deprecate_positional("X and W should be passed by keyword only. In a future release " - "we will disallow passing X and W by position.", ['X', 'W']) - def fit(self, Y, T, X=None, W=None, *, sample_weight=None, freq_weight=None, sample_var=None, groups=None, + def fit(self, Y, T, *, X=None, W=None, sample_weight=None, freq_weight=None, sample_var=None, groups=None, cache_values=False, inference='auto'): """ Estimate the counterfactual model from data, i.e. estimates function :math:`\\theta(\\cdot)`. @@ -1144,9 +1140,7 @@ def _gen_model_final(self): def _gen_ortho_learner_model_final(self): return _ModelFinal(self._gen_model_final(), self._gen_featurizer(), False) - @_deprecate_positional("X and W should be passed by keyword only. In a future release " - "we will disallow passing X and W by position.", ['X', 'W']) - def fit(self, Y, T, X=None, W=None, *, sample_weight=None, groups=None, + def fit(self, Y, T, *, X=None, W=None, sample_weight=None, groups=None, cache_values=False, inference='auto'): """ Estimate the counterfactual model from data, i.e. estimates function :math:`\\theta(\\cdot)`. @@ -1440,9 +1434,7 @@ def _gen_model_final(self): def _gen_ortho_learner_model_final(self): return _ModelFinal(self._gen_model_final(), self._gen_featurizer(), False) - @_deprecate_positional("X and W should be passed by keyword only. In a future release " - "we will disallow passing X and W by position.", ['X', 'W']) - def fit(self, Y, T, X=None, W=None, *, sample_weight=None, groups=None, + def fit(self, Y, T, *, X=None, W=None, sample_weight=None, groups=None, cache_values=False, inference='auto'): """ Estimate the counterfactual model from data, i.e. estimates functions τ(·,·,·), ∂τ(·,·). diff --git a/econml/dynamic/dml/_dml.py b/econml/dynamic/dml/_dml.py index 159ed9f16..94605fd10 100644 --- a/econml/dynamic/dml/_dml.py +++ b/econml/dynamic/dml/_dml.py @@ -540,9 +540,7 @@ def _strata(self, Y, T, X=None, W=None, Z=None, # Required for bootstrap inference return groups - @_deprecate_positional("X, and should be passed by keyword only. In a future release " - "we will disallow passing X and W by position.", ['X', 'W']) - def fit(self, Y, T, X=None, W=None, *, sample_weight=None, sample_var=None, groups, + def fit(self, Y, T, *, X=None, W=None, sample_weight=None, sample_var=None, groups, cache_values=False, inference='auto'): """Estimate the counterfactual model from data, i.e. estimates function :math:`\\theta(\\cdot)`. diff --git a/econml/iv/nnet/_deepiv.py b/econml/iv/nnet/_deepiv.py index 18123b0d7..32a5390ac 100644 --- a/econml/iv/nnet/_deepiv.py +++ b/econml/iv/nnet/_deepiv.py @@ -296,10 +296,8 @@ def __init__(self, *, self._second_stage_options = second_stage_options super().__init__() - @_deprecate_positional("X and Z should be passed by keyword only. In a future release " - "we will disallow passing X and Z by position.", ['X', 'Z']) @BaseCateEstimator._wrap_fit - def fit(self, Y, T, X, Z, *, inference=None): + def fit(self, Y, T, *, X, Z, inference=None): """Estimate the counterfactual model from data. That is, estimate functions τ(·, ·, ·), ∂τ(·, ·). diff --git a/econml/iv/sieve/_tsls.py b/econml/iv/sieve/_tsls.py index 242e416d1..213a9a306 100644 --- a/econml/iv/sieve/_tsls.py +++ b/econml/iv/sieve/_tsls.py @@ -208,10 +208,8 @@ def __init__(self, *, self._model_Y = LinearRegression(fit_intercept=False) super().__init__() - @_deprecate_positional("X, W, and Z should be passed by keyword only. In a future release " - "we will disallow passing X, W, and Z by position.", ['X', 'W', 'Z']) @BaseCateEstimator._wrap_fit - def fit(self, Y, T, Z, X=None, W=None, *, inference=None): + def fit(self, Y, T, *, Z, X=None, W=None, inference=None): """ Estimate the counterfactual model from data, i.e. estimates functions τ(·, ·, ·), ∂τ(·, ·). diff --git a/econml/metalearners/_metalearners.py b/econml/metalearners/_metalearners.py index fcc0ebba9..8fe13f19d 100644 --- a/econml/metalearners/_metalearners.py +++ b/econml/metalearners/_metalearners.py @@ -42,10 +42,8 @@ def __init__(self, *, self.categories = categories super().__init__() - @_deprecate_positional("X should be passed by keyword only. In a future release " - "we will disallow passing X by position.", ['X']) @BaseCateEstimator._wrap_fit - def fit(self, Y, T, X, *, inference=None): + def fit(self, Y, T, *, X, inference=None): """Build an instance of TLearner. Parameters @@ -131,10 +129,8 @@ def __init__(self, *, self.categories = categories super().__init__() - @_deprecate_positional("X should be passed by keyword only. In a future release " - "we will disallow passing X by position.", ['X']) @BaseCateEstimator._wrap_fit - def fit(self, Y, T, X=None, *, inference=None): + def fit(self, Y, T, *, X=None, inference=None): """Build an instance of SLearner. Parameters @@ -240,10 +236,8 @@ def __init__(self, *, self.categories = categories super().__init__() - @_deprecate_positional("X should be passed by keyword only. In a future release " - "we will disallow passing X by position.", ['X']) @BaseCateEstimator._wrap_fit - def fit(self, Y, T, X, *, inference=None): + def fit(self, Y, T, *, X, inference=None): """Build an instance of XLearner. Parameters @@ -367,10 +361,8 @@ def __init__(self, *, self.categories = categories super().__init__() - @_deprecate_positional("X should be passed by keyword only. In a future release " - "we will disallow passing X by position.", ['X']) @BaseCateEstimator._wrap_fit - def fit(self, Y, T, X, *, inference=None): + def fit(self, Y, T, *, X, inference=None): """Build an instance of DomainAdaptationLearner. Parameters diff --git a/econml/orf/_ortho_forest.py b/econml/orf/_ortho_forest.py index 24f6fa3a5..9f8109fb6 100644 --- a/econml/orf/_ortho_forest.py +++ b/econml/orf/_ortho_forest.py @@ -250,10 +250,8 @@ def __init__(self, self.categories = categories super().__init__() - @_deprecate_positional("X and W should be passed by keyword only. In a future release " - "we will disallow passing X and W by position.", ['X', 'W']) @BaseCateEstimator._wrap_fit - def fit(self, Y, T, X, W=None, *, inference='auto'): + def fit(self, Y, T, *, X, W=None, inference='auto'): """Build an orthogonal random forest from a training set (Y, T, X, W). Parameters @@ -610,9 +608,7 @@ def _combine(self, X, W): # Need to redefine fit here for auto inference to work due to a quirk in how # wrap_fit is defined - @_deprecate_positional("X and W should be passed by keyword only. In a future release " - "we will disallow passing X and W by position.", ['X', 'W']) - def fit(self, Y, T, X, W=None, *, inference='auto'): + def fit(self, Y, T, *, X, W=None, inference='auto'): """Build an orthogonal random forest from a training set (Y, T, X, W). Parameters @@ -949,9 +945,7 @@ def __init__(self, *, batch_size=batch_size, random_state=self.random_state) - @_deprecate_positional("X and W should be passed by keyword only. In a future release " - "we will disallow passing X and W by position.", ['X', 'W']) - def fit(self, Y, T, X, W=None, *, inference='auto'): + def fit(self, Y, T, *, X, W=None, inference='auto'): """Build an orthogonal random forest from a training set (Y, T, X, W). Parameters diff --git a/econml/tests/test_inference.py b/econml/tests/test_inference.py index d977ec1c1..ae5439d62 100644 --- a/econml/tests/test_inference.py +++ b/econml/tests/test_inference.py @@ -44,8 +44,8 @@ def test_summary(self): cate_est.fit( TestInference.Y, TestInference.T, - TestInference.X, - TestInference.W, + X=TestInference.X, + W=TestInference.W, inference=inference ) summary_results = cate_est.summary() @@ -64,8 +64,8 @@ def test_summary(self): cate_est.fit( TestInference.Y, TestInference.T, - TestInference.X, - TestInference.W, + X=TestInference.X, + W=TestInference.W, inference=inference ) fnames = ['Q' + str(i) for i in range(TestInference.d_x)] @@ -78,8 +78,8 @@ def test_summary(self): cate_est.fit( TestInference.Y, TestInference.T, - TestInference.X, - TestInference.W, + X=TestInference.X, + W=TestInference.W, inference=inference ) summary_results = cate_est.summary() @@ -90,8 +90,8 @@ def test_summary(self): cate_est.fit( TestInference.Y, TestInference.T, - TestInference.X, - TestInference.W, + X=TestInference.X, + W=TestInference.W, inference=inference ) fnames = ['Q' + str(i) for i in range(TestInference.d_x)] @@ -104,8 +104,8 @@ def test_summary(self): wrapped_est.fit( TestInference.Y, TestInference.T, - TestInference.X, - TestInference.W, + X=TestInference.X, + W=TestInference.W, inference=inference ) summary_results = wrapped_est.summary() @@ -117,8 +117,8 @@ def test_summary(self): wrapped_est.fit( TestInference.Y, TestInference.T, - TestInference.X, - TestInference.W, + X=TestInference.X, + W=TestInference.W, inference=inference ) fnames = ['Q' + str(i) for i in range(TestInference.d_x)] @@ -138,8 +138,8 @@ def test_summary_discrete(self): cate_est.fit( TestInference.Y, TestInference.T, - TestInference.X, - TestInference.W, + X=TestInference.X, + W=TestInference.W, inference=inference ) summary_results = cate_est.summary(T=1) @@ -159,8 +159,8 @@ def test_summary_discrete(self): cate_est.fit( TestInference.Y, TestInference.T, - TestInference.X, - TestInference.W, + X=TestInference.X, + W=TestInference.W, inference=inference ) fnames = ['Q' + str(i) for i in range(TestInference.d_x)] @@ -174,8 +174,8 @@ def test_summary_discrete(self): cate_est.fit( TestInference.Y, TestInference.T, - TestInference.X, - TestInference.W, + X=TestInference.X, + W=TestInference.W, inference=inference ) summary_results = cate_est.summary(T=1) @@ -187,8 +187,8 @@ def test_summary_discrete(self): cate_est.fit( TestInference.Y, TestInference.T, - TestInference.X, - TestInference.W, + X=TestInference.X, + W=TestInference.W, inference=inference ) fnames = ['Q' + str(i) for i in range(TestInference.d_x)] @@ -202,8 +202,8 @@ def test_summary_discrete(self): wrapped_est.fit( TestInference.Y, TestInference.T, - TestInference.X, - TestInference.W, + X=TestInference.X, + W=TestInference.W, inference=inference ) summary_results = wrapped_est.summary(T=1) @@ -216,8 +216,8 @@ def test_summary_discrete(self): wrapped_est.fit( TestInference.Y, TestInference.T, - TestInference.X, - TestInference.W, + X=TestInference.X, + W=TestInference.W, inference=inference ) fnames = ['Q' + str(i) for i in range(TestInference.d_x)] @@ -275,16 +275,16 @@ def test_can_summarize(self): LinearDML(model_t=LinearRegression(), model_y=LinearRegression()).fit( TestInference.Y, TestInference.T, - TestInference.X, - TestInference.W + X=TestInference.X, + W=TestInference.W ).summary() LinearDRLearner(model_regression=LinearRegression(), model_propensity=LogisticRegression(), fit_cate_intercept=False).fit( TestInference.Y, TestInference.T > 0, - TestInference.X, - TestInference.W, + X=TestInference.X, + W=TestInference.W, inference=BootstrapInference(5) ).summary(1) diff --git a/econml/tests/test_metalearners.py b/econml/tests/test_metalearners.py index a667637cb..cb13b98c9 100644 --- a/econml/tests/test_metalearners.py +++ b/econml/tests/test_metalearners.py @@ -146,11 +146,11 @@ def _test_inputs(self, learner_instance, T0, T1): learner_instance.fit(list(Y), list(T), X=list(X)) learner_instance.effect(list(TestMetalearners.X_test), T0=T0, T1=T1) # Check that it fails correctly if lists of different shape are passed in - self.assertRaises(ValueError, learner_instance.fit, Y, T, X[:TestMetalearners.n // 2]) - self.assertRaises(ValueError, learner_instance.fit, Y[:TestMetalearners.n // 2], T, X) + self.assertRaises(ValueError, learner_instance.fit, Y, T, X=X[:TestMetalearners.n // 2]) + self.assertRaises(ValueError, learner_instance.fit, Y[:TestMetalearners.n // 2], T, X=X) # Check that it works when T, Y have shape (n, 1) self.assertWarns(DataConversionWarning, - learner_instance.fit, Y.reshape(-1, 1), T.reshape(-1, 1), X + learner_instance.fit, Y.reshape(-1, 1), T.reshape(-1, 1), X=X ) @classmethod diff --git a/econml/tests/test_orf.py b/econml/tests/test_orf.py index df9b4987b..72fa979eb 100644 --- a/econml/tests/test_orf.py +++ b/econml/tests/test_orf.py @@ -62,7 +62,7 @@ def test_continuous_treatments(self): est.fit(list(Y), list(T), X=list(TestOrthoForest.X), W=list(TestOrthoForest.W)) # --> Check that it fails correctly if lists of different shape are passed in self.assertRaises(ValueError, est.fit, Y[:TestOrthoForest.n // 2], T[:TestOrthoForest.n // 2], - TestOrthoForest.X, TestOrthoForest.W) + X=TestOrthoForest.X, W=TestOrthoForest.W) # Check that outputs have the correct shape out_te = est.const_marginal_effect(TestOrthoForest.x_test) self.assertEqual(TestOrthoForest.x_test.shape[0], out_te.shape[0]) @@ -81,7 +81,7 @@ def test_continuous_treatments(self): # Test continuous treatments without controls T = TestOrthoForest.eta_sample(TestOrthoForest.n) Y = T * TE + TestOrthoForest.epsilon_sample(TestOrthoForest.n) - est.fit(Y, T, TestOrthoForest.X, inference="blb") + est.fit(Y, T, X=TestOrthoForest.X, inference="blb") self._test_te(est, TestOrthoForest.expected_exp_te, tol=0.5) self._test_ci(est, TestOrthoForest.expected_exp_te, tol=1.5) @@ -106,15 +106,15 @@ def test_binary_treatments(self): est.fit(list(Y), list(T), X=list(TestOrthoForest.X), W=list(TestOrthoForest.W)) # --> Check that it fails correctly if lists of different shape are passed in self.assertRaises(ValueError, est.fit, Y[:TestOrthoForest.n // 2], T[:TestOrthoForest.n // 2], - TestOrthoForest.X, TestOrthoForest.W) + X=TestOrthoForest.X, W=TestOrthoForest.W) # --> Check that it works when T, Y have shape (n, 1) est.fit(Y.reshape(-1, 1), T.reshape(-1, 1), X=TestOrthoForest.X, W=TestOrthoForest.W) # --> Check that it fails correctly when T has shape (n, 2) self.assertRaises(ValueError, est.fit, Y, np.ones((TestOrthoForest.n, 2)), - TestOrthoForest.X, TestOrthoForest.W) + X=TestOrthoForest.X, W=TestOrthoForest.W) # --> Check that it fails correctly when the treatments are not numeric self.assertRaises(ValueError, est.fit, Y, np.array(["a"] * TestOrthoForest.n), - TestOrthoForest.X, TestOrthoForest.W) + X=TestOrthoForest.X, W=TestOrthoForest.W) # Check that outputs have the correct shape out_te = est.const_marginal_effect(TestOrthoForest.x_test) self.assertSequenceEqual((TestOrthoForest.x_test.shape[0], 1, 1), out_te.shape) diff --git a/econml/tests/test_shap.py b/econml/tests/test_shap.py index 74ad6e699..d2c6153f9 100644 --- a/econml/tests/test_shap.py +++ b/econml/tests/test_shap.py @@ -39,7 +39,7 @@ def test_continuous_t(self): ] for est in est_list: with self.subTest(est=est, featurizer=featurizer, d_y=d_y, d_t=d_t): - est.fit(Y, T, X, W) + est.fit(Y, T, X=X, W=W) shap_values = est.shap_values(X[:10], feature_names=["a", "b", "c"], background_samples=None) @@ -98,9 +98,9 @@ def test_discrete_t(self): for est in est_list: with self.subTest(est=est, featurizer=featurizer, d_y=d_y, d_t=d_t): if isinstance(est, (TLearner, SLearner, XLearner, DomainAdaptationLearner)): - est.fit(Y, T, X) + est.fit(Y, T, X=X) else: - est.fit(Y, T, X, W) + est.fit(Y, T, X=X, W=W) shap_values = est.shap_values(X[:10], feature_names=["a", "b", "c"], background_samples=None) for i, output in enumerate(est.cate_output_names()): diff --git a/econml/tests/test_statsmodels.py b/econml/tests/test_statsmodels.py index b7b2c5943..75a544cdf 100644 --- a/econml/tests/test_statsmodels.py +++ b/econml/tests/test_statsmodels.py @@ -722,21 +722,21 @@ def split(self, X, T): linear_first_stages=False) est.fit(y_sum, - X_final[:, -1], X_final[:, :-1], - None, freq_weight=n_sum, + X_final[:, -1], X=X_final[:, :-1], + W=None, freq_weight=n_sum, sample_var=var_sum, inference=StatsModelsInference(cov_type=cov_type)) - lr.fit(y, X[:, -1], X[:, :-1], None, + lr.fit(y, X[:, -1], X=X[:, :-1], W=None, inference=StatsModelsInference(cov_type=cov_type)) _compare_dml_classes(est, lr, X_test, alpha=alpha, tol=1e-8) # compare when both sample_var and sample_weight exist est.fit(y_sum, - X_final[:, -1], X_final[:, :-1], - None, sample_weight=w_sum, freq_weight=n_sum, + X_final[:, -1], X=X_final[:, :-1], + W=None, sample_weight=w_sum, freq_weight=n_sum, sample_var=var_sum, inference=StatsModelsInference(cov_type=cov_type)) - lr.fit(y, X[:, -1], X[:, :-1], None, sample_weight=w, + lr.fit(y, X[:, -1], X=X[:, :-1], W=None, sample_weight=w, inference=StatsModelsInference(cov_type=cov_type)) _compare_dml_classes(est, lr, X_test, alpha=alpha, tol=1e-8) @@ -800,8 +800,8 @@ def split(self, X, T): model_t=first_stage_model, model_final=OLS(), cv=SplitterSum()).fit(y_sum, - X_final[:, -1], X_final[:, :-1], - None, freq_weight=n_sum, + X_final[:, -1], X=X_final[:, :-1], + W=None, freq_weight=n_sum, sample_var=var_sum, inference="auto") @@ -809,17 +809,17 @@ def split(self, X, T): model_y=first_stage_model, model_t=first_stage_model, model_final=OLS(), - cv=Splitter()).fit(y, X[:, -1], X[:, :-1], None, + cv=Splitter()).fit(y, X[:, -1], X=X[:, :-1], W=None, inference="auto") _compare_classes(est.model_final_, lr.model_final_, X_test, alpha=alpha, tol=1e-10) # compare when both sample_var and sample_weight exist est.fit(y_sum, - X_final[:, -1], X_final[:, :-1], - None, sample_weight=w_sum, freq_weight=n_sum, + X_final[:, -1], X=X_final[:, :-1], + W=None, sample_weight=w_sum, freq_weight=n_sum, sample_var=var_sum, inference="auto") - lr.fit(y, X[:, -1], X[:, :-1], None, sample_weight=w, + lr.fit(y, X[:, -1], X=X[:, :-1], W=None, sample_weight=w, inference="auto") _compare_classes(est.model_final_, lr.model_final_, X_test, alpha=alpha, tol=1e-10) @@ -889,21 +889,21 @@ def split(self, X, T): cv=Splitter()) est.fit(y_sum, - X_final[:, -1], X_final[:, :-1], - None, freq_weight=n_sum, + X_final[:, -1], X=X_final[:, :-1], + W=None, freq_weight=n_sum, sample_var=var_sum, inference=StatsModelsInferenceDiscrete(cov_type=cov_type)) - lr.fit(y, X[:, -1], X[:, :-1], None, + lr.fit(y, X[:, -1], X=X[:, :-1], W=None, inference=StatsModelsInferenceDiscrete(cov_type=cov_type)) _compare_dr_classes(est, lr, X_test, alpha=alpha, tol=1e-8) # compare when both sample_var and sample_weight exist est.fit(y_sum, - X_final[:, -1], X_final[:, :-1], - None, sample_weight=w_sum, freq_weight=n_sum, + X_final[:, -1], X=X_final[:, :-1], + W=None, sample_weight=w_sum, freq_weight=n_sum, sample_var=var_sum, inference=StatsModelsInferenceDiscrete(cov_type=cov_type)) - lr.fit(y, X[:, -1], X[:, :-1], None, sample_weight=w, + lr.fit(y, X[:, -1], X=X[:, :-1], W=None, sample_weight=w, inference=StatsModelsInferenceDiscrete(cov_type=cov_type)) _compare_dr_classes(est, lr, X_test, alpha=alpha, tol=1e-8) @@ -1201,8 +1201,8 @@ def split(self, X, T): linear_first_stages=False, discrete_treatment=False).fit(y_sum, X_final[:, d:], - X_final[:, :d_x], - X_final[:, d_x:d], + X=X_final[:, :d_x], + W=X_final[:, d_x:d], freq_weight=n_sum, sample_var=var_sum, inference=StatsModelsInference(cov_type='nonrobust'))