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

Catch the exception for the R2 computation #62

Open
xiki-tempula opened this issue Aug 10, 2022 · 2 comments
Open

Catch the exception for the R2 computation #62

xiki-tempula opened this issue Aug 10, 2022 · 2 comments

Comments

@xiki-tempula
Copy link

xiki-tempula commented Aug 10, 2022

In
https://github.com/OpenFreeEnergy/arsenic/blob/main/arsenic/stats.py#L81-L83
The scipy.stats.linregress were used to find the R2.
In the older versions (scipy<1.8) when both x and y are the same value, for example:

import scipy
slope, intercept, r_value, p_value, std_err = scipy.stats.linregress([1.33, 1.33, 1.33], [0.33, 0.33, 0.33])

will return a runtime warning.
Now this would return a ValueError, it might be good to catch this exception and return 0? Thanks.

The code to reproduce this error is

from openff.arsenic.stats import bootstrap_statistic
bootstrap_statistic([1.33, 2.00], [0.33, 1.00], statistic="R2")
@mikemhenry
Copy link
Collaborator

@xiki-tempula thanks for this bug report!

I'm a little unsure why returning 0 is appropriate if y_true_sample != y_pred_sample Or are you saying that when y_true_sample is the same as y_pred_sample, scipy throws a ValueError?

@xiki-tempula
Copy link
Author

@mikemhenry Thanks for the reply. Sorry I have missed this message. I wonder if it is possible to allow arsenic to handle

from openff.arsenic.stats import bootstrap_statistic
bootstrap_statistic([1.33, 2.00], [0.33, 1.00], statistic="R2")

Currently, this would give ValueError.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants