Answers for "Evaluator for Multiclass Classification"

0

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'
Posted by: Guest on April-01-2020

Code answers related to "Evaluator for Multiclass Classification"

Python Answers by Framework

Browse Popular Code Answers by Language