เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

Create the evaluator

The first thing you need when doing cross validation for model selection is a way to compare different models. Luckily, the pyspark.ml.evaluation submodule has classes for evaluating different kinds of models. Your model is a binary classification model, so you'll be using the BinaryClassificationEvaluator from the pyspark.ml.evaluation module.

This evaluator calculates the area under the ROC. This is a metric that combines the two kinds of errors a binary classifier can make (false positives and false negatives) into a simple number. You'll learn more about this towards the end of the chapter!

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

Foundations of PySpark

ดูคอร์ส

คำแนะนำการฝึกหัด

  • Import the submodule pyspark.ml.evaluation as evals.
  • Create evaluator by calling evals.BinaryClassificationEvaluator() with the argument metricName="areaUnderROC".

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

# Import the evaluation submodule
import ____ as evals

# Create a BinaryClassificationEvaluator
evaluator = ____
แก้ไขและรันโค้ด