py-why / py-why/EconML

NonParamDMLIV sometimes ZeroDivisionError

Open
#837 3 comments 0 reactions 1 assignee View on GitHub

@ronikobrosly is already working on this.

Since Aug 27, 2024.

Dominant language
Jupyter Notebook
Stars
4.8k
Forks
827
PR merge metrics
No merged PRs in 30d

Description

Seems that one can run into ZeroDivisionErrors when using NonParamDMLIV. Reproduction code below. Note, the error is not consistent. You may have to run it multiple times before getting the ZeroDivisionError. 

From briefly looking into it, it seems the T residuals are all 0's when the error occurs.

econml version 0.15.0b1. Haven't tried other versions.

Let me know if I'm missing something!

from econml.iv.dml import NonParamDMLIV
import numpy as np
from sklearn.linear_model import LinearRegression

n = 100
d_x = 3

Y = np.random.normal(size=(n,))
T = np.random.normal(size=(n,))
X = np.random.normal(size=(n, d_x))
Z = np.random.normal(size=(n,))

est = NonParamDMLIV(discrete_instrument=False, discrete_treatment=False, model_final=LinearRegression())

est.fit(Y, T, Z=Z, X=X)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.