I am new to ML, and I am using the following code to figure out RMSE & R2. However, the R2 value is shown as: -43.13.
I have already gone through few posts on Stackoverflow mentioning the significance of negative R2. But in my data set, it is clear that as 'certifications' data increases, so does the 'salary'. So there is clearly a positive correlation between them. Then why is R2 negative?
Certifications data: [ 2. 3. 5. 6. 7. 9. 10. 14.]
Salary data: [22000. 23000. 24000. 28000. 33000. 42000. 44000. 53000.]
model=LinearRegression()
certification_train,certification_test,salary_train,salary_test=train_test_split(certifications,salary,test_size=0.2)
model.fit(certification_train.reshape(-1,1), salary_train.reshape(-1,1))
salary_prediction=model.predict(certification_test.reshape(-1,1))
print("R2:",r2_score(salary_test,salary_prediction))