QuestionQ89

VerifiedModel Deployment

A data scientist defined the Pandas UDF function predict to parallelize inference for a single-node model:

Question Image

They wrote the following incomplete code block to use predict to score every record in the Spark DataFrame spark_df:

Question Image

Which of the following lines of code can complete the code block and successfully finish the task?

Explanation

A scalar iterator Pandas UDF is invoked with Spark Column arguments and returns a Column expression, which can be supplied to withColumn. Expanding spark_df.columns passes all feature columns to predict; Spark supplies their batches to the iterator, and the function combines the batch features before returning one prediction Series. mapInPandas instead operates as a DataFrame-level transformation and is not a column expression for withColumn.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!