py-why / py-why/EconML

Convergence problem in SparseLinearDML

Open
#567 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Hi,
when training a SparseLinearDML instance, I get the log below, and then the last line repeating for a couple hundred times (overnight), finally resulting in a divide-by-zero and nans.

Identical setup using LinearDML works fine.

Any suggestions on fixing this?

BTW linear_first_stages must be False for this run as else it runs out of RAM (tries to allocate a TiB or something like that)
Thanks a lot!

fitting backdoor.econml.dml.SparseLinearDML {'init_params': {'model_t': DummyClassifier(), 'model_y': <auto_causality.utils.AutoMLWrapper object at 0x000001AB5DE50370>, 'discrete_treatment': True, 'linear_first_stages': False}, 'fit_params': {}}
calling AutoML fit method with  {'time_budget': 300, 'verbose': 1, 'task': 'regression', 'n_jobs': 11, 'pred_time_limit': 1e-05}
calling AutoML fit method with  {'time_budget': 300, 'verbose': 1, 'task': 'regression', 'n_jobs': 11, 'pred_time_limit': 1e-05}
Objective did not converge. You might want to increase the number of iterations. Duality gap: 0.0, tolerance: 0.0
Objective did not converge. You might want to increase the number of iterations. Duality gap: 0.0, tolerance: 0.0
Objective did not converge. You might want to increase the number of iterations. Duality gap: 0.0, tolerance: 0.0
(a couple hundred more like this)
Objective did not converge. You might want to increase the number of iterations. Duality gap: 0.0, tolerance: 0.0
Objective did not converge. You might want to increase the number of iterations. Duality gap: 0.0, tolerance: 0.0
divide by zero encountered in true_divide
invalid value encountered in matmul
The final model has a nonzero intercept for at least one outcome; it will be subtracted, but consider fitting a model without an intercept if possible.
Increasing the treatment variable(s) [RECEIVED_CAMPAIGN] from [0] to [1] causes an increase of nan in the expected value of the outcome [VOL_GBP_AFTER_90D], over the data distribution/population represented by the dataset.
manual mean impact: nan nan std: nan
Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm 2021.1.2\plugins\python\helpers\pydev\pydevd.py", line 1483, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "C:\Program Files\JetBrains\PyCharm 2021.1.2\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "C:/Users/egor.kraev/Transferwise/causality/notebooks/CRM_impact.py", line 243, in <module>
    intrp.interpret(est_obj, X_train)
  File "C:\Users\egor.kraev\.conda\envs\generic3.9\lib\site-packages\econml\cate_interpreter\_interpreters.py", line 193, in interpret
    self.tree_model_.fit(X, y_pred.reshape((y_pred.shape[0], -1)))
  File "C:\Users\egor.kraev\.conda\envs\generic3.9\lib\site-packages\sklearn\tree\_classes.py", line 1252, in fit
    super().fit(
  File "C:\Users\egor.kraev\.conda\envs\generic3.9\lib\site-packages\sklearn\tree\_classes.py", line 157, in fit
    X, y = self._validate_data(X, y,
  File "C:\Users\egor.kraev\.conda\envs\generic3.9\lib\site-packages\sklearn\base.py", line 431, in _validate_data
    y = check_array(y, **check_y_params)
  File "C:\Users\egor.kraev\.conda\envs\generic3.9\lib\site-packages\sklearn\utils\validation.py", line 63, in inner_f
    return f(*args, **kwargs)
  File "C:\Users\egor.kraev\.conda\envs\generic3.9\lib\site-packages\sklearn\utils\validation.py", line 720, in check_array
    _assert_all_finite(array,
  File "C:\Users\egor.kraev\.conda\envs\generic3.9\lib\site-packages\sklearn\utils\validation.py", line 103, in _assert_all_finite
    raise ValueError(
ValueError: Input contains NaN, infinity or a value too large for dtype('float64').
python-BaseException

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.

Research direction

No repository file or test is named. Start by reproducing SparseLinearDML with the reported model settings and inspect the scikit-learn convergence warnings and traceback; done means identifying why the fit produces divide-by-zero and NaN values and adding a verified regression test or documented resolution.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, scikit-learn
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.