BLACK FRIDAY SALE – Unlock Up to 25% OFF on All Exam Prep! - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Databricks Machine Learning Associate Exam - Topic 3 Question 4 Discussion

Posted by Brent on May 18, 2024 at 01:20 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)

Suggested Answer: C

To compute the root mean-squared-error (RMSE) of a linear regression model using Spark ML, the RegressionEvaluator class is used. The RegressionEvaluator is specifically designed for regression tasks and can calculate various metrics, including RMSE, based on the columns containing predictions and actual values.

The correct code block to compute RMSE from the preds_df DataFrame is:

regression_evaluator = RegressionEvaluator( predictionCol='prediction', labelCol='actual', metricName='rmse' ) rmse = regression_evaluator.evaluate(preds_df)

This code creates an instance of RegressionEvaluator, specifying the prediction and label columns, as well as the metric to be computed ('rmse'). It then evaluates the predictions in preds_df and assigns the resulting RMSE value to the rmse variable.

Options A and B incorrectly use BinaryClassificationEvaluator, which is not suitable for regression tasks. Option D also incorrectly uses BinaryClassificationEvaluator.


PySpark ML Documentation

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
36 comments · newest first
BL
Blythe 1 year ago
Wait, why is RMSE important again?
BA
Barabara 1 year ago
Definitely going with Option A, it makes sense!
TE
Tenesha 1 year ago
Not so sure about Option C, seems off.
GL
Glory 1 year ago
I think Option B looks right!
LU
Luis 1 year ago
RMSE is calculated using predictions and actual values.
JA
Jamal 1 year ago
I'm a bit confused about the syntax in these options. I hope one of them correctly uses the `preds_df` DataFrame for the RMSE calculation.
LA
Laura 1 year ago
I feel like Option C might be the right choice, but I can't recall if we need to specify the metric name explicitly.
WI
William 1 year ago
I remember practicing a similar question where we had to compute RMSE, and I think it involved using `evaluate` method on the evaluator.
PI
Pilar 1 year ago
I think we need to use the `RegressionEvaluator` to calculate RMSE, but I'm not sure which option shows that correctly.
KA
Karon 1 year ago
I'm a little confused by the different code options. I'll need to double-check the Spark ML documentation to make sure I'm selecting the right approach to calculate the RMSE for this linear regression model.
AI
Aileen 1 year ago
Okay, I've got this. Option B looks like the correct way to compute the RMSE. It's using the built-in Spark ML evaluator to calculate the metric directly from the prediction and actual columns in the DataFrame.
VI
Vicky 1 year ago
Hmm, I'm a bit unsure about this one. I need to make sure I understand how to properly calculate RMSE using the data in the Spark DataFrame. Let me think through the different code options carefully.
HY
Hyman 1 year ago
This looks like a straightforward question to calculate the RMSE of a linear regression model. I'll carefully review the code options and choose the one that correctly computes the RMSE.
LO
Loise 1 year ago
I remember learning about this in class. The counter variable is local, so any changes outside the For Each scope won't impact the next iteration. I'm feeling good about this one.
TH
Theodora 1 year ago
Isn't a process decision program chart meant for planning responses? I could confuse that with what they're looking for here.
LI
Lisha 1 year ago
Hmm, I'm a bit confused on this one. I know OSPF has different router types, but I can't remember which one generates the type 2 LSAs specifically.
RA
Rashida 3 years ago
Hold up, did anyone else notice the typo in option A? 'preds_df' should be 'predictions_df'. That's a dead giveaway that it's not the right answer. Gotta be on the lookout for those details, folks!
MI
Mike 3 years ago
Hmm, this is a tough one. I'd say Option D, just to mix things up a bit. Who needs RMSE anyway? We should be focusing on accuracy, not root-mean-squared-error.
GA
Gail 2 years ago
↳ replying to Mike
I agree, let's go with Option D.
MA
Markus 2 years ago
↳ replying to Mike
RMSE is important for evaluating the model, so Option D seems like the right choice.
LU
Luke 2 years ago
↳ replying to Mike
I agree, let's go with Option D.
LI
Linette 2 years ago
↳ replying to Mike
I think Option D is the correct choice.
SV
Svetlana 2 years ago
↳ replying to Mike
I agree, let's go with Option D.
RO
Ronnie 2 years ago
↳ replying to Mike
I think Option D is the correct choice.
LY
Lynda 2 years ago
↳ replying to Mike
I think Option D is the way to go.
BE
Becky 3 years ago
I'm torn between B and C, but I think C is the way to go. The math checks out, and it's a straightforward implementation.
TE
Temeka 2 years ago
↳ replying to Becky
User2
SL
Slyvia 2 years ago
↳ replying to Becky
User1
LI
Lilli 3 years ago
Option C looks promising, let's go with that. The formula seems spot on for computing the RMSE.
AN
Angella 2 years ago
↳ replying to Lilli
I think Option C is the best option for this task.
KA
Karan 2 years ago
↳ replying to Lilli
Great, let's proceed with Option C then.
LE
Leigha 3 years ago
↳ replying to Lilli
Yes, Option C is the best one for calculating the RMSE.
VA
Valentin 3 years ago
↳ replying to Lilli
The formula in Option C looks accurate for calculating RMSE.
LA
Laquanda 3 years ago
↳ replying to Lilli
I agree, Option C is the correct choice for computing the RMSE.
UL
Ula 3 years ago
↳ replying to Lilli
I agree, Option C seems like the right choice for this.
SA
Sabina 3 years ago
↳ replying to Lilli
Let's use Option C to compute the RMSE.
0/2000 characters

Save Cancel