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

'squared' is deprecated error while running evaluate_causal_model #1236

Open
newbietogitdotcom opened this issue Aug 6, 2024 · 5 comments
Open
Labels
question Further information is requested

Comments

@newbietogitdotcom
Copy link

Thank you for creating this awesome library!. I got a question

Here is my code

from dowhy import gcm

Create the structural causal model object

scm = gcm.StructuralCausalModel(causal_graph)

Automatically assign generative models to each node based on the given data

auto_assignment_summary = gcm.auto.assign_causal_mechanisms(scm, df13)

print(auto_assignment_summary)

Fit causal models to data

#learn the parameters of the model
gcm.fit(scm, df13)

print(gcm.evaluate_causal_model(scm, df13, compare_mechanism_baselines=True, evaluate_invertibility_assumptions=False))

While the code runs fine, during its progress i get below error

"/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/sklearn/metrics/_regression.py:483: FutureWarning: 'squared' is deprecated in version 1.4 and will be removed in 1.6. To calculate the root mean squared error, use the function'root_mean_squared_error'.
warnings.warn("

How do i avoid this error ?

@newbietogitdotcom newbietogitdotcom added the question Further information is requested label Aug 6, 2024
@bloebp
Copy link
Member

bloebp commented Aug 6, 2024

Hey, it seems this is a warning, not an error, i.e., you can ignore it for now. Nevertheless, it is something we need to change. I will put it on the backlog. Thanks a lot for flagging!

@newbietogitdotcom
Copy link
Author

Okay great, thank you!

@bloebp
Copy link
Member

bloebp commented Oct 28, 2024

Just following-up on this, this actually seems to be coming from scikit-learn not from DoWhy. You might just need to update scikit learn.

@mbeale
Copy link
Contributor

mbeale commented Dec 26, 2024

I'm getting an error on this now @bloebp .

"""
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/joblib/externals/loky/process_executor.py", line 463, in _process_worker
r = call_item()
File "/usr/local/lib/python3.10/dist-packages/joblib/externals/loky/process_executor.py", line 291, in call
return self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.10/dist-packages/joblib/parallel.py", line 598, in call
return [func(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/joblib/parallel.py", line 598, in
return [func(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/dowhy/gcm/model_evaluation.py", line 467, in evaluate_node
metric_evaluations["NMSE"].append(nmse(node_data[test_indices], conditional_expectations))
File "/usr/local/lib/python3.10/dist-packages/dowhy/gcm/model_evaluation.py", line 683, in nmse
return mean_squared_error(y_true, y_pred, squared=squared) / (np.var(y_true) if squared else y_std)
File "/usr/local/lib/python3.10/dist-packages/sklearn/utils/_param_validation.py", line 194, in wrapper
params = func_sig.bind(*args, **kwargs)
File "/usr/lib/python3.10/inspect.py", line 3186, in bind
return self._bind(args, kwargs)
File "/usr/lib/python3.10/inspect.py", line 3175, in _bind
raise TypeError(
TypeError: got an unexpected keyword argument 'squared'
"""

The above exception was the direct cause of the following exception:

TypeError Traceback (most recent call last)
in <cell line: 3>()
15
16 gcm.fit(causal_model, data)
---> 17 summary_evaluation = gcm.evaluate_causal_model(causal_model, data, compare_mechanism_baselines=True)
18 print(summary_evaluation)

7 frames
/usr/local/lib/python3.10/dist-packages/joblib/parallel.py in _return_or_raise(self)
761 try:
762 if self.status == TASK_ERROR:
--> 763 raise self._result
764 return self._result
765 finally:

TypeError: got an unexpected keyword argument 'squared'

sklearn is version 1.6.0. I guess I have to go to <= 1.4 to get this to work

@bloebp
Copy link
Member

bloebp commented Jan 10, 2025

Hey, thanks a lot! I will take a look.

@bloebp bloebp reopened this Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants