We are ready to evaluate our model and see how well we can distinguish between Messi and Ronaldo.
Since we will be doing some model evaluation, we will need to import the following library:
MulticlassClassificationEvaluator
The following section walks through the following steps to evaluate model performance:
- Execute the following script to create a confusion matrix from the
predictDF
dataframe:
predictDF.crosstab('prediction', 'label').show().
- Calculate an accuracy score based on our 24 test images of Ronaldo and Messi by executing the following script:
from pyspark.ml.evaluation import MulticlassClassificationEvaluator scoring = predictDF.select("prediction", "label") accuracy_score = MulticlassClassificationEvaluator(metricName="accuracy") rate = accuracy_score.evaluate(scoring)*100 print("accuracy: {}%" .format(round(rate,2))).