This is my code, I calculated R square using Scikit learn :
y =[0, 10, 20, 30, 40]
f =[0, 1, 2, 3, 4]
r2 = r2_score(y, f)
print('r2 score for perfect model is', r2)
Output :
r2 score for perfect model is -1.4300000000000002
Why is this coming out negative?