After fitting the model the R2 for test data is negative

Hi,

After I fit the model and try to get the R2 for my test data, I am getting negative R2. Can someone help me understand if I am calculating it correctly? The R2 for Train is 0.72.

Thanks in advance!

Assuming you are using sklearn’s r2_score function, the values can range from 1.0 to negative infinity:

Best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse). In the general case when the true y is non-constant, a constant model that always predicts the average y disregarding the input features would get a
score of 0.0.

Thank for your response @cluhmann. Yes, I am using sklearn’s r2_score function. Does this mean that we cannot use R2 for model evaluation? If so, what would be the best metric to evaluate model strength?

Also, @cluhmann - How do you resolve this issue?

That function may be useful. There is no singular answer to the question “What is the correct metric to evaluate my model”? I might suggest checking out the notebooks on conducting posterior predictive checks.