R2 score for regression -14.542.
I was doing regression using Single Layer Perceptron. The R2 score I've got is -14.542. I got ranked as best model.
From what I know, R2 should be between 0 and 1.
Maybe you should have some checks for metrics and when they don't make sense just raise an error ?
Comments
-
TomWiley Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Registered Posts: 3 DataikerHi Cristinel,
Thanks for the suggestion!
Regarding R2 score, unfortunately the metric name is a bit misleading, as the possible range of expected values does include negatives:
An R2 score of 1 refers to a model that always predicts perfectly.
An R2 score of 0 refers to a model that always predicts the mean of the target.
An R2 score less than 0 therefore refers to a model that predicts consistently worse than the mean of the target.
The scikit-learn documentation has an example of when this can occur:
from sklearn.metrics import r2_score »»» y_true = [3, -0.5, 2, 7] »»» y_pred = [2.5, 0.0, 2, 8] »»» r2_score(y_true, y_pred) 0.948… … »»» y_true = [1, 2, 3] »»» y_pred = [1, 2, 3] »»» r2_score(y_true, y_pred) 1.0 »»» y_true = [1, 2, 3] »»» y_pred = [2, 2, 2] »»» r2_score(y_true, y_pred) 0.0 »»» y_true = [1, 2, 3] »»» y_pred = [3, 2, 1] »»» r2_score(y_true, y_pred) -3.0 …
More information about the scikit implementation of this metric can be found here.
From what I can see from your screenshot, the likely root cause of the model's poor performance in this case is the small size of the input dataset.
Please let us know if you have any further questions or inquiries on this topic !
Best regards,
Tom
-
Thank you, I appreciate your input.
Next time I will do some research before posting something I should have known already!
