evaluator for multiclass classification

Solutions on MaxInterview for evaluator for multiclass classification by the best coders in the world

showing results for - "evaluator for multiclass classification"
Solal
29 May 2019
1# Evaluator for Multiclass Classification
2
3scoreAndLabels = [(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)]
4dataset = spark.createDataFrame(scoreAndLabels, ["prediction", "label"])
5# ...
6evaluator = MulticlassClassificationEvaluator(predictionCol="prediction")
7evaluator.evaluate(dataset)
8# 0.55...
9evaluate.evaluate(dataset, {evaluator.metricName: "accuracy"})
10# 0.66...
11mce_path = temp_path + "/mce"
12evaluator.save(mce_path)
13evaluator2 = MulticlassClassificationvaluator.load(mce_path)
14str(evaluator2.getPredictionCol())
15'prediction'