Databricks Machine Learning Associate Question 292
Select 2You are tasked with training and evaluating a machine learning model using Spark ML in Databricks. You decide to use a Random Forest model for classification. After preparing the data, splitting it into training and test sets, and training the model, you want to evaluate its performance. Which of the following steps are necessary to correctly evaluate the model on the test set?
- A
Transform the test dataset using the trained Random Forest model to generate predictions.
- B
Directly compare the features of the test set with the training set to calculate the accuracy.
- C
Use a classification evaluator from Spark ML to compute metrics such as accuracy or F1 score.
- D
Fit the trained Random Forest model to the test dataset before evaluating.
- E
Split the test dataset into additional training and validation sets for evaluation.
Show answer and explanation
Correct answers: A, C
Explanation
To evaluate a machine learning model in Spark ML, you first generate predictions on the test dataset using the trained model by transforming the test set. Then, you use a classification evaluator to compute metrics like accuracy or F1 score. Fitting the model to the test set or altering the test set is not appropriate, as it violates the principles of proper model evaluation.
- A. Correct.
Correct: Transforming the test dataset using the trained model is necessary to generate predictions, which are then used to compute evaluation metrics.
- B. Incorrect.
Incorrect: Comparing features between the test and training sets does not provide meaningful evaluation metrics. Evaluation requires predictions and ground truths.
- C. Correct.
Correct: A classification evaluator is specifically designed to compute metrics such as accuracy or F1 score, making it essential for model evaluation.
- D. Incorrect.
Incorrect: The trained Random Forest model should not be fitted to the test dataset. The test set is only used for evaluation, not training.
- E. Incorrect.
Incorrect: Splitting the test dataset further is unnecessary. The test dataset should remain intact for evaluation to ensure reliable performance metrics.