# Plot actual vs predicted
gg <- ggplot(pred_results, aes(x = Actual, y = Predicted)) +
geom_point(color = "blue", alpha = 0.7) +
geom_abline(intercept = 0, slope = 1, color = "black", linetype = "dashed") +
labs(title = "Test Set: Actual vs Predicted",
x = "Actual (%)",
y = "Predicted (%)") +
theme_minimal()
# Add annotations for model metrics
gg <- gg +
annotate("text", x = Inf, y = -Inf, hjust = 0, vjust = 0,
label = paste("Model R-squared:", round(best_model_results$model_r2, 2))) +
annotate("text", x = Inf, y = -Inf, hjust = 0.5, vjust = 0.5,
label = paste("Test R-squared:", round(best_model_results$test_r2, 2))) +
annotate("text", x = Inf, y = -Inf, hjust = 0.7, vjust = 0.7,
label = paste("Correlation:", round(best_model_results$correlation, 2))) +
annotate("text", x = Inf, y = -Inf, hjust = 0.8, vjust = 0.8,
label = paste("MSE:", round(best_model_results$MSE, 2))) +
annotate("text", x = Inf, y = -Inf, hjust = 1, vjust = 1,
label = paste("Max Error:", round(best_model_results$max_error, 2)))
image is added here:
I tried changing the number, but I was not able to adjust the position.