I have 2 data frames following then calcualate the r2 value:
x_true = pd.DataFrame({COL_USER: [1, 2, 3, 4], COL_ITEM: [5, 6, 7, 8], COL_RATING: [9, 10, 11, 12]})
x_pred = pd.DataFrame({COL_USER: [1, 2, 3, 4], COL_ITEM: [5, 6, 7, 8], COL_RATING: [13, 14, 15, 16]})
spark = start_or_get_spark("EvaluationTesting", "local")
X_true = spark.createDataFrame(x_true)
X_pred = spark.createDataFrame(x_pred)
sre = SparkRatingEvaluation(X_true, X_pred, **HEADER)
r2 = sre.rsquared()
The result of r2 score is 0.888… => I want visualize the result in Scatterplot. I have try annotate method but it not working. My code is:
plt.annotate("r-squared = {:.3f}".format(r2_score(X_true, x_pred)), (0, 1))