How to get support numbers in pyspark.ml like we get in sklearn classification report?

Viewed 27

I am using Pyspark and able to get metrices like accuracy, f1, precison and recall from MulticlassClassificationEvaluator but I am not sure how to get the support numbers like we get in classification report for sklearn. rfc_pred in my case has the group of each class that I run in loop. So, will rfc_pred.count() do the trick?

Below is my current code:

from pyspark.ml.evaluation import MulticlassClassificationEvaluator

evaluator = MulticlassClassificationEvaluator(labelCol="label", predictionCol="prediction")

accuracy = evaluator.evaluate(rfc_pred, {evaluator.metricName: "accuracy"}) 

f1 = evaluator.evaluate(rfc_pred, {evaluator.metricName: "f1"})

weightedPrecision = evaluator.evaluate(rfc_pred, {evaluator.metricName: "weightedPrecision"})

weightedRecall = evaluator.evaluate(rfc_pred, {evaluator.metricName: "weightedRecall"})

    
0 Answers
Related