Skip to content

Instantly share code, notes, and snippets.

@dvgodoy
Created March 9, 2019 12:30
Show Gist options
  • Save dvgodoy/4d4426e073526a416690188e929ecad6 to your computer and use it in GitHub Desktop.
Save dvgodoy/4d4426e073526a416690188e929ecad6 to your computer and use it in GitHub Desktop.
from pyspark.ml.evaluation import BinaryClassificationEvaluator
# Let's use the run-of-the-mill evaluator
evaluator = BinaryClassificationEvaluator(labelCol='Survived')
# We have only two choices: area under ROC and PR curves :-(
auroc = evaluator.evaluate(predictions, {evaluator.metricName: "areaUnderROC"})
auprc = evaluator.evaluate(predictions, {evaluator.metricName: "areaUnderPR"})
print("Area under ROC Curve: {:.4f}".format(auroc))
print("Area under PR Curve: {:.4f}".format(auprc))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment