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

R2_Score() is inconsistent with other methods #13

Open
MaurizioSicorello opened this issue Jun 29, 2021 · 1 comment
Open

R2_Score() is inconsistent with other methods #13

MaurizioSicorello opened this issue Jun 29, 2021 · 1 comment

Comments

@MaurizioSicorello
Copy link

When trying to compute R-Squared from predicted and actual values, the results from R2_Score() did not match other methods. (they were very large and negative).

Here is some R-Code to reproduce this issue:

`x = rnorm(20)
y = rnorm(20)

test = lm(y~x)
summary(test)
y_pred = predict(test)

MLmetrics

R2_Score(y, y_pred)

squared correlation

cor(y_pred, y)^2

sums of squares formula

PRESS = sum((y - y_pred)^2)
SS = sum((y - mean(y))^2)
1 - (PRESS/SS)`

@hadjipantelis
Copy link

The example presented uses the wrong order of input arguments.

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