-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
R2_score for GLM #2696
R2_score for GLM #2696
Conversation
pymc3/stats.py
Outdated
R2_std: standard deviation of the Bayesian R2 | ||
""" | ||
e = y_true - y_pred | ||
var_y_est = np.var(y_pred, 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to fail if y_pred
has dimension 1.
pymc3/stats.py
Outdated
@@ -964,3 +964,33 @@ def bfmi(trace): | |||
energy = trace['energy'] | |||
|
|||
return np.square(np.diff(energy)).mean() / np.var(energy) | |||
|
|||
|
|||
def r2_score(y_true, y_pred): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about rounding the results by default (maybe 2 decimals) and adding an argument to control this...
pymc3/stats.py
Outdated
var_y_est = np.var(y_pred, 1) | ||
var_e = np.var(e, 1) | ||
|
||
r2_median = np.median(var_y_est / (var_y_est + var_e)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe you should assign var_y_est / (var_y_est + var_e)
to a variable and then use that variable to compute the mean, median and std
thx |
LGTM! In your previous PR you had a test, If possible you should add it again. |
@aloctavodia I didn't make any test in the previous pull request :/ |
OK, so maybe no test for this PR :-) |
Thanks @denadai2 |
* R2_score for GLM * Added round of results and dimension check in r2_score
Add Bayesian R2 PR pymc-devs#2696.
Fixes #2564.
Ref #2605.