QuestionQ49

VerifiedModel Development

A data scientist has built a three-class decision-tree classifier with Spark ML and generated predictions in a Spark DataFrame, preds_df, with this schema:

prediction DOUBLE  
actual DOUBLE  

Which code block can compute the model’s accuracy from the data in preds_df and store it in the accuracy variable?

Explanation

MulticlassClassificationEvaluator is the Spark ML evaluator for multiclass classification and supports accuracy as a metric. Setting predictionCol to prediction and labelCol to actual matches the DataFrame schema; calling evaluate(preds_df) returns the scalar accuracy value.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!