Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added warning message and test for issue #837 #919

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
8 changes: 8 additions & 0 deletions econml/iv/dml/_dml.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,14 @@ def predict(self, Y, T, X=None, W=None, Z=None, sample_weight=None, groups=None)
TX_pred = np.tile(TX_pred.reshape(1, -1), (T.shape[0], 1))
Y_res = Y - Y_pred.reshape(Y.shape)
T_res = TXZ_pred.reshape(T.shape) - TX_pred.reshape(T.shape)
if T_res.sum() == 0:
ronikobrosly marked this conversation as resolved.
Show resolved Hide resolved
raise ValueError(
"""
All values of the treatment residual are 0,
which then makes them unsuitable to use as weights
in downstream in econml/dml/dml.py
ronikobrosly marked this conversation as resolved.
Show resolved Hide resolved
"""
)
return Y_res, T_res


Expand Down
Loading