#Please check if any of your values being passed in are NaN or inf: np.isnan(x).any() np.isnan(y).any() np.isinf(x).any() np.isinf(y).any() #If any of those yields true. Remove the nan entries or inf entries.
Here is what the above code is Doing:
1. It is creating a linear regression model.
2. It is fitting the model to the data.
3. It is predicting the y values for the x values.
4. It is calculating the mean squared error.
5. It is calculating the r2 score.