A data scientist has developed and logged a scikit-learn random forest model model, and then they ended their Spark session and terminated their cluster. After starting a new cluster, they want to review the feature_importances_ of the original model object.
Which of the following lines of code can be used to restore the model object so that feature_importances_ is available?
Suggested Answer: A
Get Premium Databricks Machine Learning Professional Questions
as Interactive Web-Based Practice Test or PDF
Real Exam Format
Detailed Explanations
Instant Access
Get Your Practice Test
34 comments · newest first
MI
Miriam
10 months ago
I’m not sure about D, I thought we could access it programmatically.
AN
Anika
10 months ago
Wait, can you really only view it in the UI? That seems odd!
SA
Sage
10 months ago
Definitely agree with C, it’s the proper way to load scikit-learn models.
LU
Luz
10 months ago
Option A is also a valid choice, but not for scikit-learn models.
IV
Ivan
10 months ago
I think option C is the right one!
AL
Alex
11 months ago
I thought we could only view feature importances in the UI, but I feel like there's a way to load the model directly too.
ME
Merlyn
11 months ago
I vaguely recall that `client.list_artifacts` is used for listing files, but I don't think it actually loads the model.
KE
Kerry
11 months ago
I think we practiced a similar question where we had to retrieve model artifacts. I feel like option C is the right one since it specifies sklearn.
MI
Mirta
11 months ago
I remember we discussed how to load models with MLflow, but I'm not sure if it's `mlflow.load_model` or `mlflow.sklearn.load_model`.
MO
Mozelle
12 months ago
Hmm, I'm not sure about this one. I'll have to review my notes on MLflow and model persistence to make the best choice.
SE
Selene
12 months ago
Ah, I think I've got it! The key is that the data scientist terminated their Spark cluster, so we need to use a method that doesn't rely on the Spark session.
FA
Farrah
12 months ago
Wait, I'm a bit confused. Isn't there something about Spark in the question? I wonder if that changes how we need to approach this.
LO
Lorean
1 year ago
Okay, let's see. I'm pretty sure I've used mlflow.load_model() before to restore a model, so that's my first guess.
LA
Lauran
1 year ago
Hmm, this looks like a tricky one. I'll need to think through the options carefully to make sure I don't miss anything.
TA
Tawna
1 year ago
Option C is the way to go. Hey, at least it's not asking us to restore the model from a backup tape or something!
LA
Lavera
1 year ago
Yeah, MLflow is a lifesaver when it comes to managing and restoring model objects.
AR
Arlene
1 year ago
Option C is definitely the right choice. MLflow makes it easy to load the model object.
PA
Patrick
2 years ago
I think D) This can only be viewed in the MLflow Experiments UI is incorrect because we need to access the feature_importances_ in the code
FA
Fairy
2 years ago
I'm going with C. Gotta love those scikit-learn-specific utilities, they make my life so much easier. *sarcasm intensifies*
EZ
Ezekiel
2 years ago
I'm not sure, but I think A) mlflow.load_model(model_uri) might also work since it's a general model loading function in MLflow
BO
Bok
2 years ago
D is a joke, right? I'm not gonna look at feature importances in the MLflow UI, that's what the code is for!
HA
Hana
1 year ago
E) client.pyfunc.load_model(model_uri)
LO
Louvenia
1 year ago
C) mlflow.sklearn.load_model(model_uri)
QU
Quentin
1 year ago
A) mlflow.load_model(model_uri)
LE
Lea
2 years ago
I agree with Monroe, because mlflow.sklearn.load_model(model_uri) is specifically for loading scikit-learn models
GL
Glen
2 years ago
I'm not sure why you can't just use `mlflow.load_model()` to restore the model. Seems like a waste of time to have a separate function for scikit-learn models.
LO
Louis
1 year ago
I'm not sure why you can't just use `mlflow.load_model()` to restore the model. Seems like a waste of time to have a separate function for scikit-learn models.
DO
Dottie
1 year ago
C) mlflow.sklearn.load_model(model_uri)
WE
Wenona
1 year ago
A) mlflow.load_model(model_uri)
MO
Monroe
2 years ago
I think the correct answer is C) mlflow.sklearn.load_model(model_uri)
JU
Jutta
2 years ago
Option C looks like the correct answer. You can use `mlflow.sklearn.load_model()` to restore the original model object and access the `feature_importances_`.
KA
Kanisha
2 years ago
Great, thanks for confirming!
ZE
Zena
2 years ago
Yes, you are correct. `mlflow.sklearn.load_model()` can be used to restore the model object.
IR
Irma
2 years ago
I think option C is the right choice.