Databricks Machine Learning Associate Question 288
Select 4You are tasked with building a machine learning pipeline using Spark ML to predict customer churn. The dataset is stored in a Delta table and includes features like age, account_balance, and tenure. After creating a RandomForestClassifier model, you use the CrossValidator class to evaluate the model's performance. Which of the following steps are necessary to properly train and evaluate the model?
- A
Split the dataset into training and test sets using
randomSplit. - B
Set up a
ParamGridBuilderto specify hyperparameter combinations for theCrossValidator. - C
Use the
fitmethod on theCrossValidatorwith the test dataset to train the model. - D
Specify an evaluation metric such as
accuracyorf1for theCrossValidator. - E
Transform the test dataset using the trained model to evaluate its performance.
Show answer and explanation
Correct answers: A, B, D, E
Explanation
To properly train and evaluate a machine learning model using Spark ML, you need to split the dataset into training and test sets, define hyperparameter combinations with ParamGridBuilder, specify an evaluation metric for the CrossValidator, and evaluate the model on the test set by transforming it. It's important to train the model on the training set only and avoid using the test set during training.
- A. Correct.
Correct: Splitting the dataset into training and test sets is a standard practice in machine learning to ensure proper evaluation of model performance.
- B. Correct.
Correct: The
ParamGridBuilderis used to define hyperparameter combinations for theCrossValidatorto test during model tuning. - C. Incorrect.
Incorrect: The
fitmethod on theCrossValidatorshould only be called on the training dataset, not the test dataset. - D. Correct.
Correct: Specifying an evaluation metric is required for the
CrossValidatorto assess model performance during hyperparameter tuning. - E. Correct.
Correct: After training the model, the test dataset must be transformed using the trained model to evaluate its performance on unseen data.