Evaluator for multiclass classification

This article is tagged with: Evaluator for multiclass classification and lua

Evaluator for Multiclass Classification

# Evaluator for Multiclass Classification
scoreAndLabels = [(0.0, 0.0), (0.0, 1.0), (0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (1.0, 1.0), (1.0, 1.0), (2.0, 2.0), (2.0, 0.0)]
dataset = spark.createDataFrame(scoreAndLabels, ["prediction", "label"])
# ...
evaluator = MulticlassClassificationEvaluator(predictionCol="prediction")
evaluator.evaluate(dataset)
# 0.55...
evaluate.evaluate(dataset, {evaluator.metricName: "accuracy"})
# 0.66...
mce_path = temp_path + "/mce"
evaluator.save(mce_path)
evaluator2 = MulticlassClassificationvaluator.load(mce_path)
str(evaluator2.getPredictionCol())
'prediction'

This article is tagged with: Evaluator for multiclass classification and lua