-
Notifications
You must be signed in to change notification settings - Fork 933
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
Get error in refutation process ValueError: No group keys passed! #1028
Comments
Hi @stvgz , |
@stvgz I'm experiencing the same issue. Tried on: Exact same error as the traceback above after calling the refute_estimate method using identical parameters. |
@stvgz I have the same error and it is from the same example from the book Causal Inference and Discovery in Python. Pip uninstall dowhy and conda install did not work for me @galkampel. I am on MacOS Sonoma 14.3, Python 3.10.14, dowhy 0.11.1 Updates: |
thanks for tagging @bloebp Let me take a look at this. |
Hi @stvgz
and
then I restarted the kernel and it worked out. |
Describe the bug
Get error in refutation
Steps to reproduce the behavior
Very common steps
Read data
earnings_data = pd.read_csv(r'./data/ml_earnings.csv')
Define graph and model
`# Construct the graph (the graph is constant for all iterations)
nodes = ['took_a_course', 'earnings', 'age']
edges = [
('took_a_course', 'earnings'),
('age', 'took_a_course'),
('age', 'earnings')
]
Generate the GML graph
gml_string = 'graph [directed 1\n'
for node in nodes:
gml_string += f'\tnode [id "{node}" label "{node}"]\n'
for edge in edges:
gml_string += f'\tedge [source "{edge[0]}" target "{edge[1]}"]\n'
gml_string += ']'`
# Instantiate the CausalModel model = CausalModel( data=earnings_data, treatment='took_a_course', outcome='earnings', graph=gml_string )
estimate
# Get estimate (Matching) estimate = model.estimate_effect( identified_estimand=estimand, method_name='backdoor.distance_matching', target_units='ate', method_params={'distance_metric': 'minkowski', 'p': 2})
Refute
refutation = model.refute_estimate( estimand=estimand, estimate=estimate, method_name= "random_common_cause", # method_name = 'add_unobserved_common_cause' )
Error I got
`---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[23], line 1
----> 1 refutation = model.refute_estimate(
2 estimand=estimand,
3 estimate=estimate,
4 method_name= "random_common_cause",
5 # method_name = 'add_unobserved_common_cause'
6 )
File ~/opt/anaconda3/envs/causal/lib/python3.9/site-packages/dowhy/causal_model.py:434, in CausalModel.refute_estimate(self, estimand, estimate, method_name, show_progress_bar, **kwargs)
431 refuter_class = causal_refuters.get_class_object(method_name)
433 refuter = refuter_class(self._data, identified_estimand=estimand, estimate=estimate, **kwargs)
--> 434 res = refuter.refute_estimate(show_progress_bar)
435 return res
File ~/opt/anaconda3/envs/causal/lib/python3.9/site-packages/dowhy/causal_refuters/random_common_cause.py:45, in RandomCommonCause.refute_estimate(self, show_progress_bar)
44 def refute_estimate(self, show_progress_bar=False):
---> 45 refute = refute_random_common_cause(
46 self._data,
47 self._target_estimand,
48 self._estimate,
49 self._num_simulations,
50 self._random_state,
51 show_progress_bar,
...
--> 917 raise ValueError("No group keys passed!")
918 elif len(groupings) == 0:
919 groupings.append(Grouping(Index([], dtype="int"), np.array([], dtype=np.intp)))
ValueError: No group keys passed!`
This can also include a verbatim copy of outputs, or screenshots.
Expected behavior
A clear and concise description of what you expected to happen.
Version information:
Additional context
Example from book Causal Inference and Discovery
The text was updated successfully, but these errors were encountered: