# Actual values vs Preditec values plot

I was working on a project and I got a 0.98 R^2 score on both the training and test data sets and 0.91 training mse and 1.02 test mse, But my Actual values vs Predicted values looks like this, I was wondering that if this is considered accepteable and if my model is preforming well. I have also added the residuals plot.Thanks in advance.

model = xgb.XGBRegressor()
model.fit(X_train, y_train)

train_r2 = model.score(X_train, y_train)
y_train_pred = model.predict(X_train)
train_mse = mean_squared_error(y_train, y_train_pred)
test_r2 = model.score(X_test, y_test)
y_test_pred = model.predict(X_test)
test_mse = mean_squared_error(y_test, y_test_pred)
print(f'Test R^2 score: {test_r2}, Test MSE : {test_mse}')
print(f'Training R^2 score: {train_r2}, Training MSE : {train_mse}')

predicted_values = model.predict(X_test)
plt.scatter(y_test, predicted_values, color='green', alpha=0.4)
plt.xlabel("Actual Values")
plt.ylabel("Predicted Values")
plt.title("Actual vs. Predicted Values")
plt.show()

residuals = y_test - predicted_values

plt.scatter(y_test, residuals, alpha=0.5)
plt.xlabel("Actual Values")
plt.ylabel("Residuals")
plt.axhline(y=0, color='r', linestyle='-')
plt.title("Residual Plot")
plt.show()


• I’m with you on your skepticism! How do you compute those $R^2$ scores? How do you plot your data?
– Dave
Nov 5 at 23:08
• model = xgb.XGBRegressor() model.fit(X_train, y_train) r2 = model.score(X_train, y_train) y_train_pred = model.predict(X_train) mse = mean_squared_error(y_train, y_train_pred) test_r2 = model.score(X_test, y_test) print(f'Training R^2 score: {r2}, Training MSE : {mse}') Nov 5 at 23:38
• predicted_values = model.predict(X_test) plt.scatter(y_test, predicted_values, color='green', alpha=0.4) plt.xlabel("Actual Values") plt.ylabel("Predicted Values") plt.title("Actual vs. Predicted Values") plt.show() thanks for taking the time to help. Nov 5 at 23:39
• Could you please edit that into your original question as a code block with comments? Thanks!
– Dave
Nov 5 at 23:48
• Sure, and thank you Nov 6 at 0:17