CERTIFIED-MACHINE-LEARNING-PROFESSIONAL · Question #23
CERTIFIED-MACHINE-LEARNING-PROFESSIONAL Question #23: Real Exam Question with Answer & Explanation
The correct answer is A: The context parameter allows the user to specify which version of the registered MLflow Model. There appears to be an error in this question - the marked correct answer (A) does not accurately describe the context parameter. Option E is the correct answer based on MLflow documentation. In MLflow's PythonModel subclass, the predict method signature is predict(self, context,
Question
Which of the following describes the purpose of the context parameter in the predict method of Python models for MLflow?
Options
- AThe context parameter allows the user to specify which version of the registered MLflow Model
- BThe context parameter allows the user to document the performance of a model after it has been
- CThe context parameter allows the user to include relevant details of the business case to allow
- DThe context parameter allows the user to provide the model with completely custom if-else logic
- EThe context parameter allows the user to provide the model access to objects like preprocessing
Explanation
There appears to be an error in this question - the marked correct answer (A) does not accurately describe the context parameter. Option E is the correct answer based on MLflow documentation.
In MLflow's PythonModel subclass, the predict method signature is predict(self, context, model_input). The context parameter is a mlflow.pyfunc.PythonModelContext object whose primary purpose is to give the model access to artifacts logged alongside it - things like serialized preprocessing pipelines, tokenizers, scalers, or any other object saved via artifacts={} at log time. You access them via context.artifacts["my_object"].
Why the distractors are wrong:
- A - Model version selection happens at load/serving time (e.g.,
mlflow.pyfunc.load_model("models:/MyModel/3")), not throughcontext. - B - Performance documentation is done via
mlflow.log_metric(), not throughpredict'scontext. - C - Business case documentation belongs in model descriptions or tags, not
context. - D - Custom logic lives in the body of
predictitself, not in thecontextobject.
Memory tip: Think of context as a backpack the model carries into predict - it holds extra gear (artifacts) the model packed when it was logged, ready to unzip and use during inference.
Flag this to your instructor: the marked answer (A) is incorrect per MLflow's API. The correct answer is E.
Community Discussion
No community discussion yet for this question.