Here is a part of the code to calculate R2 from several regression algorithms:
print("Random Forest Performance") print(metrics.r2_score(y_test, Y_p