QuestionQ85

VerifiedModel Deployment

A machine learning engineer needs to parallelize inference for group-specific models by using the Pandas Function API. They created the apply_model function to look up and load the appropriate model for each group, and need to apply it to every group in DataFrame df.

They wrote this incomplete code block:

Question Image

Which code can fill the blank above to complete the task?

Explanation

PySpark GroupedData.applyInPandas(func, schema) maps each group of a DataFrame through a pandas function and returns a DataFrame using the supplied output schema. It is therefore the grouped Pandas Function API that matches df.groupby("device_id") followed by apply_model and schema=apply_return_schema.

Learn more

Community Discussion

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