Evaluator for Multiclass Classification code example
Example: 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)
evaluate.evaluate(dataset, {evaluator.metricName: "accuracy"})
mce_path = temp_path + "/mce"
evaluator.save(mce_path)
evaluator2 = MulticlassClassificationvaluator.load(mce_path)
str(evaluator2.getPredictionCol())
'prediction'