CERTIFIED-MACHINE-LEARNING-PROFESSIONAL · Question #53
CERTIFIED-MACHINE-LEARNING-PROFESSIONAL Question #53: Real Exam Question with Answer & Explanation
The correct answer is A: mlflow.load_model(model_uri). Important note: The stated correct answer of A appears to contain an error - mlflow.load_model() is not a valid top-level MLflow function and would raise an AttributeError. The actual correct answer is C. --- Option C (mlflow.sklearn.load_model(model_uri)) is correct because it u
Question
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?
Options
- Amlflow.load_model(model_uri)
- Bclient.list_artifacts(run_id)["feature-importances.csv"]
- Cmlflow.sklearn.load_model(model_uri)
- DThis can only be viewed in the MLflow Experiments UI
- Eclient.pyfunc.load_model(model_uri)
Explanation
Important note: The stated correct answer of A appears to contain an error - mlflow.load_model() is not a valid top-level MLflow function and would raise an AttributeError. The actual correct answer is C.
Option C (mlflow.sklearn.load_model(model_uri)) is correct because it uses the sklearn-flavored loader, which returns the native scikit-learn object - in this case, the actual RandomForestClassifier instance. Since feature_importances_ is a native sklearn attribute, it is fully accessible on the returned object.
Why the distractors are wrong:
- A (
mlflow.load_model) - This function does not exist at the top level of the MLflow API; it would raiseAttributeError. - B (
client.list_artifacts(...)["feature-importances.csv"]) -list_artifactsreturns a list ofFileInfoobjects, not a dict, and you cannot index it like a dictionary; also,feature_importances_is not automatically saved as a CSV artifact. - D - The MLflow UI shows metrics and parameters, not reconstructed Python model objects with live attributes.
- E (
client.pyfunc.load_model) -MlflowClienthas nopyfuncattribute; the correct call would bemlflow.pyfunc.load_model(), and even that returns a genericPyFuncModelwrapper that does not expose sklearn-specific attributes likefeature_importances_.
Memory tip: Think of it as speaking the model's language - use the flavor-specific loader (mlflow.sklearn, mlflow.xgboost, etc.) when you need the native object and its native attributes. pyfunc gives you a generic wrapper for inference only.
Community Discussion
No community discussion yet for this question.