For a multiclass classification problem with 5 classes, which Spark MLlib evaluator computes accuracy and is appropriate?
Select an answer to reveal the explanation.
Short Explanation and Infographic
MulticlassClassificationEvaluator is the right tool for any classification problem with 2 or more classes — and yes, accuracy is one of its supported metrics.
Full explanation below image
Full Explanation
pyspark.ml.evaluation.MulticlassClassificationEvaluator(labelCol='label', predictionCol='prediction', metricName='accuracy') supports: 'accuracy' (fraction of correct predictions), 'f1' (weighted F1), 'weightedPrecision', 'weightedRecall', 'weightedTruePositiveRate', 'weightedFalsePositiveRate', 'weightedFMeasure', 'truePositiveRateByLabel', 'falsePositiveRateByLabel', 'precisionByLabel', 'recallByLabel', 'fMeasureByLabel', 'logLoss', 'hammingLoss'. BinaryClassificationEvaluator is restricted to binary problems and only supports 'areaUnderROC' and 'areaUnderPR' — it does NOT support accuracy. RegressionEvaluator computes regression metrics (rmse, mae, r2). Despite the name 'multiclass', MulticlassClassificationEvaluator works correctly for binary classification too (it treats it as a 2-class problem).