How it works...

In this recipe, we explored generating evaluation metrics for a multi-classification model. First, we loaded the Iris data into memory and split it in a ratio 60:40. Second, we trained a logistic regression model with the number of classifications set to three. Third, we made predictions with the test dataset and utilized MultiClassMetric to generate evaluation measurements. Finally, we evaluated metrics such as the model accuracy, weighted precision, weighted recall, weighted F1 score, weighted false positive rate, and so on.

Get Apache Spark 2.x Machine Learning Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.