Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Databricks Machine Learning Associate Exam - Topic 4 Question 47 Discussion

Posted by Dyan on Jul 15, 2026 at 10:45 PM

A data scientist has developed a linear regression model using Spark ML and computed the predictions in a Spark DataFrame preds_df with the following schema:

prediction DOUBLE

actual DOUBLE

Which of the following code blocks can be used to compute the root mean-squared-error of the model according to the data in preds_df and assign it to the rmse variable?

A)

B)

C)

D)

E)

Suggested Answer: C

The code block to compute the root mean-squared error (RMSE) for a linear regression model in Spark ML should use the RegressionEvaluator class with metricName set to 'rmse'. Given the schema of preds_df with columns prediction and actual, the correct evaluator setup will specify predictionCol='prediction' and labelCol='actual'. Thus, the appropriate code block (Option C in your list) that uses RegressionEvaluator to compute the RMSE is the correct choice. This setup correctly measures the performance of the regression model using the predictions and actual outcomes from the DataFrame. Reference:

Spark ML documentation (Using RegressionEvaluator to Compute RMSE).


Get Premium Databricks Machine Learning Associate Questions as Interactive Web-Based Practice Test or PDF Real Exam Format Detailed Explanations Instant Access Get Your Practice Test
12 comments · newest first
KA
Kaitlyn 1 month ago
I’m leaning towards option A. It matches the RMSE formula.
DE
Delsie 1 month ago
I feel option B is better. It seems more efficient.
TO
Tonette 1 month ago
I think it's option C. Looks straightforward.
CH
Cheryl 2 months ago
Surprised there's no mention of using a built-in function!
CH
Christa 2 months ago
Totally agree with B, it's straightforward!
KA
Kasandra 2 months ago
Wait, isn't Option C missing something?
ET
Ettie 2 months ago
I think Option D is the right choice!
BR
Britt 2 months ago
Option B looks solid for RMSE calculation.
BR
Brandee 2 months ago
I think option E looks familiar, but I’m uncertain if it correctly assigns the RMSE to the variable.
SU
Sue 3 months ago
I feel like we did a similar question where we had to compute metrics from a DataFrame, but I can't remember the exact syntax.
LA
Lauran 3 months ago
I think it was something about using the `RegressionEvaluator`, but I can't recall if it was in option C or D.
JA
Jaime 3 months ago
I remember we practiced calculating RMSE, but I’m not sure which code block uses the right functions in Spark.
0/2000 characters

Save Cancel