Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam Certified Machine Learning Associate All Questions

View all questions & answers for the Certified Machine Learning Associate exam

Exam Certified Machine Learning Associate topic 1 question 18 discussion

Actual exam question from Databricks's Certified Machine Learning Associate
Question #: 18
Topic #: 1
[All Certified Machine Learning Associate Questions]

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

They have written the following incomplete code block to use predict to score each record of Spark DataFrame spark_df:

Which of the following lines of code can be used to complete the code block to successfully complete the task?

  • A. predict(*spark_df.columns)
  • B. mapInPandas(predict)
  • C. predict(Iterator(spark_df))
  • D. mapInPandas(predict(spark_df.columns))
  • E. predict(spark_df.columns)
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
souarav
Highly Voted 5 months, 3 weeks ago
Selected Answer: A
mapInPandas is used in pandas api functions and syntax is mapInPandas(predict,schema)
upvoted 5 times
...
ricorosol
Most Recent 1 month, 3 weeks ago
B. mapInPandas(predict): This is the correct choice. mapInPandas is used to apply a Pandas UDF to a Spark DataFrame. This function expects the UDF to take an iterator of Pandas DataFrames and return an iterator of Pandas Series or DataFrames, which matches the signature of the predict function defined.
upvoted 1 times
...
rajneesharora
4 months, 3 weeks ago
correct answer is A, Scalar Pandas UDFs work with column names or expressions and return a column that gets added to the DataFrame. In this particular case, the use of *spark_df.columns unpacks the column names, which allows the UDF to operate on all these columns. No other option provides all column names
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...