Skip to content

Commit

Permalink
Warn instead of raising an error if SLearner is given feature_set (
Browse files Browse the repository at this point in the history
  • Loading branch information
kklein authored Jun 18, 2024
1 parent 7f5a16d commit 7fc89e1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
Changelog
=========

0.5.0 (2024-06-18)
------------------

* No longer raise an error if ``feature_set`` is provided to :class:`metalearners.SLearner`.

0.4.2 (2024-06-18)
------------------

Expand Down
5 changes: 4 additions & 1 deletion metalearners/slearner.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ def _validate_params(self, feature_set, **kwargs):
# For SLearner it does not make sense to allow feature set as we only have one model
# and having it would bring problems when using fit_nuisance and predict_nuisance
# as we need to add the treatment column.
raise ValueError("SLearner does not support feature set definition.")
warnings.warn(
"Base-model specific feature_sets were provided to S-Learner. "
"These will be ignored and all available features will be used instead."
)

def fit(
self,
Expand Down
17 changes: 7 additions & 10 deletions tests/test_slearner.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,13 @@
from metalearners.slearner import SLearner, _append_treatment_to_covariates


def test_feature_set_raise():
with pytest.raises(
ValueError, match="SLearner does not support feature set definition."
):
SLearner(
nuisance_model_factory=LinearRegression,
is_classification=False,
n_variants=2,
feature_set="",
)
def test_feature_set_doesnt_raise():
SLearner(
nuisance_model_factory=LinearRegression,
is_classification=False,
n_variants=2,
feature_set="",
)


@pytest.mark.parametrize(
Expand Down

0 comments on commit 7fc89e1

Please sign in to comment.