CertLumen

Databricks Machine Learning Associate · Section 4 · 12% of the exam

Identify the differences and advantages of model serving approaches: batch, realtime, and streaming

One of the objectives of the Databricks Certified Machine Learning Associate exam, in the section “Model Deployment”. Here is what it covers, the points to remember and a question to try.

What it covers

Compare the three ways to deliver predictions on Databricks (batch, streaming and real-time) and pick the right one from latency, throughput and cost requirements. Then run batch inference with pandas: load a registered model by alias, score a pandas DataFrame, and scale the same pandas code across a cluster with spark_udf and mapInPandas.

Points to remember

  • Batch: scheduled, highest throughput, lowest cost, minutes to hours of latency; the most common and usually most cost-effective pattern.
  • Streaming: continuous or micro-batch scoring of arriving data with seconds to minutes of latency; Structured Streaming or Lakeflow Spark Declarative Pipelines.
  • Real-time: per-request REST calls to a Model Serving endpoint with millisecond latency; the most expensive per prediction.
  • Low latency but predictable inputs: precompute in batch and publish to an online store for lookups.
  • Load by alias for batch jobs: mlflow.pyfunc.load_model('models:/catalog.schema.model@champion').

Try a question

A nightly job loads a scikit-learn churn classifier with mlflow.pyfunc.load_model("models:/prod.ml.churn_model@champion") and scores a pandas DataFrame. The marketing team wants each customer's churn probability, but predict() returns only 0 and 1. What should the data scientist change?

  1. APass threshold=None to predict(), which makes the pyfunc model return probabilities instead
  2. BCall mlflow.pyfunc.spark_udf with result_type="double", which returns probabilities instead of labels
  3. CRegister the model under a new alias such as @proba, which switches the output to probabilities
  4. DLoad it with mlflow.sklearn.load_model(...) and call predict_proba(pdf)
Show the answer

D. mlflow.pyfunc.load_model returns a generic PyFuncModel whose predict() calls the model's predict method, which gives class labels for a scikit-learn classifier. To get probabilities in pandas batch inference, load the native flavor with mlflow.sklearn.load_model and call predict_proba, keeping the alias in the URI so the job still follows the champion.

Written for practice in the style of the exam: never a question from the real exam.

In the course

2 lessons teach this objective: Batch, Streaming and Real-Time Inference; Batch Scoring with pandas, Streaming Inference with Lakeflow Spark Declarative Pipelines (about 75 minutes), and 19 practice questions test it. The course has lessons, exam-style questions, timed practice exams and an AI tutor for every objective, and a pass prediction that tells you when you're ready to book.

More in this section

← Previous objective · All 48 objectives · Next objective →