Skip to main content

Module 7 Test: 20 MCQs

This is your progress tracker . 20 questions: 5 Easy, 10 Moderate, 5 Hard . First solve all the questions yourself (before running the code on your computer, work out the output in your head), then check with the Answer Key.

ScoreMeaning
18 to 20Excellent! Your grip on Module 7 is strong.
14 to 17Very good! Re-read the weaker chapters.
10 to 13Okay. Run the code yourself and look again.
Below 10Don't worry. Start again from Chapter 34 and run every code on your own computer.
EASY​

Q1. What is the most accurate meaning of MLOps?​

A) Only running Docker

B) Building, running and maintaining an ML model in a reliable way

C) Increasing a model's accuracy

D) Only cleaning data

Q2. In FastAPI, which HTTP method is usually used to send data and get a prediction?​

A) GET

B) DELETE C) POST

D) HEAD

Q3. What is an image in Docker?​

A) A ready-made packet (mould) of the app and environment from which containers are made

B) A running container

C) A picture file

D) A GitHub repository

Q4. In MLflow, what is a single attempt at training called?​

A) Experiment

B) Alias

C) Artifact

D) Run

Q5. With Python logging at level INFO, which line does not appear?​

A) the error line

B) the debug line (logger.debug)

C) the warning line

D) the critical line

​
MODERATE​

Q6. What is needed to open a FastAPI app running inside a container from your browser?​

A) Only writing EXPOSE 8000 in the Dockerfile

B) Running the server with --reload

C) Running the server on --host 0.0.0.0 and giving port mapping with -p in docker run

D) Running the container twice

Q7. What is the result of using Field(gt=0, lt=15) in Pydantic?​

A) The value must be greater than 0 and less than 15, otherwise FastAPI gives 422

B) The value always becomes 15

  • C) The model becomes fast

  • D) It is only for documentation

Q8. Why do we copy requirements.txt before the code in a Dockerfile and install the libraries?​

  • A) It is a strict Docker rule that txt files come first

  • B) It makes the image the smallest

  • C) So that the image's order follows the alphabet

D) So that the heavy library install step does not run again when only the code changes (layer cache)

Q9. In a workflow, needs: test is written inside the docker-build job. What does it mean?​

  • A) The test job will run twice

B) The docker-build job will run only when the test job passes

  • C) Both jobs will run on the same machine

  • D) The test job becomes optional

Q10. You ran mlflow ui but no run appeared, even though training had run. What is the most likely reason?​

A) The UI was started from the wrong folder or with the wrong tracking URI (training used sqlite:///mlflow.db)

  • B) The internet is slow

C) The Python version is old

  • D) The browser cache is off

Q11. Which lines will be printed when the code below is run?​

import logging
logging.basicConfig(level=logging.WARNING, format="%(levelname)s: %(message)s")
logger = logging.getLogger("t")
logger.info("a")
logger.warning("b")
logger.error("c")
logger.debug("d")
  • A) All four: a, b, c, d

B) Only b, c and d

C) Only WARNING: b and ERROR: c

D) Only ERROR: c

**Q12. The KS test on live age vs training age gave​

p = 0.0000

. What is the correct meaning?**

  • A) The test broke

B) The model's accuracy is 100%

C) Both data sets are exactly the same

D) There is a very clear difference in the distribution: evidence of drift

Q13. What is the most appropriate thing to write in the logs of a medical API?​

A) The user's name and the full list of symptoms

B) The count of symptoms, the top prediction and latency (no name, phone or ID)

  • C) The user's password

D) The user's phone number

Q14. What is the biggest benefit of the champion alias in the MLflow Model Registry?​

  • A) The need for a Docker image goes away

B) The model's accuracy rises by itself

C) The deployment code stays models:/name@champion; moving the alias to the new version is enough

D) The model's size becomes small

Q15. Why is it not right to load the model inside the predict() function in FastAPI?​

A) It will be loaded again on every request and the API will become very slow

B) Python does not allow it

C) The model gets damaged

D) Swagger /docs stops working

​
HARD​

Q16. In the code below, 5 pairs have been added. After the last (5th) add, what will m.check() give?

m = AccuracyMonitor(window=4, threshold=0.75)
for p, a in [(1, 1), (2, 2), (1, 2), (3, 3), (1, 3)]:
m.add(p, a)
print(m.check()) # (AccuracyMonitor is the same class as in Chapter 39)

A) OK: accuracy 60% B) ALERT: accuracy 60% below threshold 75% C) OK: accuracy 50%

D) ALERT: accuracy 50% below threshold 75%

Q17. Tests pass locally, but GitHub Actions gives ModuleNotFoundError: sklearn. What is the most likely reason?

A) GitHub's Python version is wrong

B) The library was not written in requirements.txt; it was already installed locally

  • C) The name of pytest is wrong

D) The colour of the YAML file is wrong

Q18. The model was trained with scikit-learn 1.8, but in the Docker image the version was not pinned in requirements and a newer version got installed. A strange error or warning came when loading the model. What is the best fix?

A) Remove Docker and run only locally

  • B) Save the model again and just hope

C) Pin in requirements.txt the same scikit-learn version the model was trained with

  • D) Just run pytest again

Q19. Two MLflow runs have an equal test accuracy of 0.900: one a small 25-tree model, the other a large 100tree model. The test set has only 30 samples. What is the wisest decision?

A) Choose the small, fast model and check again with more data or cross-validation, because with 30 samples 1 mistake makes a 0.033 difference

B) The 100-tree one is always better

  • C) Both are useless

D) Choose whichever was trained first

Q20. In the live app the average age has become 48 from the training value of 35. The real correct answer (ground truth) comes after 2 months. What is the most appropriate first step?

A) Ignore the KS test

B) Turn off the logs

  • C) Deploy a new model immediately

D) First confirm there is no bug in the data, then collect new data, retrain, and deploy with MLflow/CI/CD

Module 7 Answer Key (Answers and Explanations)​

#LevelAnswerExplanation
1EasyB) Building, running and
maintaining an ML model in a
reliable way
MLOps = ML + DevOps + Data Engineering: the whole lifecycle (data,
training, deployment, monitoring). Docker is only one part of it.
2EasyC) POSTTo make a prediction, features have to be sent, which is why /predict is
POST. GET is only for getting information (like /health).
#LevelAnswerExplanation
3EasyA) A ready-made packet
(mould) of the app and
environment from which
containers are made
An image is the mould (read-only), and a container is its running copy.
Many containers can run from one image.
4EasyD) RunRun = one attempt at training. An Experiment is the folder of those runs,
and an Artifact is a file kept with the run (for example the model).
5EasyB) the debug line
(logger.debug)
A level means: show messages of this level or above. DEBUG is below
INFO, so it is hidden.
6ModerateC) Running the server on --host
0.0.0.0 and giving port
mapping with -p in docker run
If the server listens only on 127.0.0.1, nobody from outside can reach it.
EXPOSE is only documentation; the real way in opens through -p.
7ModerateA) The value must be greater
than 0 and less than 15,
otherwise FastAPI gives 422
gt = greater than, lt = less than. A wrong value never reaches the model;
FastAPI immediately sends back 422.
8ModerateD) So that the heavy library
install step does not run again
when only the code changes
(layer cache)
Docker caches the result of every line. If the libraries are installed first,
then when the code changes only the steps below it run again, and the
build is fast.
9ModerateB) The docker-build job will run
only when the test job passes
needs decides the order of jobs. If test fails, docker-build does not run at
all, and the bad code does not reach the image.
10ModerateA) The UI was started from the
wrong folder or with the
wrong tracking URI (training
used sqlite:///mlflow.db)
The record is in mlflow.db (or mlruns). The UI must be given the same --
backend-store-uri that was used in training, otherwise it looks at an
empty place.
11ModerateC) Only WARNING: b and
ERROR: c
The level is WARNING, so WARNING and above (ERROR, CRITICAL)
appear. info (a) and debug (d) are hidden.
12ModerateD) There is a very clear
difference in the distribution:
evidence of drift
A small p (< 0.05) means that this much difference did not come by
chance. But the KS value and the actual averages should also be looked
at.
13ModerateB) The count of symptoms, the
top prediction and latency (no
name, phone or ID)
Health data is very sensitive. Write in logs only as much as is needed to
find a problem; never private information.
14ModerateC) The deployment code stays
models:/name@champion;
moving the alias to the new
version is enough
The alias decides which model is the production one. If a new model is
better, you only change the alias; the API's code does not need to
change.
15ModerateA) It will be loaded again on
every request and the API will
become very slow
Load the model once at the top of the module. Then every request uses
that same loaded model.
16HardD) ALERT: accuracy 50% below
threshold 75%
window=4, so the last 4 results are remembered: [True, False, True,
False] = 50%. The window is full and 50% < 75%, so the ALERT comes.
17HardB) The library was not written
in requirements.txt; it was
already installed locally
The CI robot is an empty machine: only what is written in
requirements.txt gets installed there. Locally the library was already
there.
18HardC) Pin in requirements.txt the
same scikit-learn version the
model was trained with
Pickle/joblib models are tied to the library version. The same version
should be pinned in both training and deployment.
19HardA) Choose the small, fast
model and check again with
more data or cross-validation,
because with 30 samples 1
mistake makes a 0.033
difference
At equal accuracy the small model is cheaper and faster. 30 samples are
very few, so the decision should rest on more data or cross-validation.
#LevelAnswerExplanation
20HardD) First confirm there is no bug
in the data, then collect new
data, retrain, and deploy with
MLflow/CI/CD
Drift can be real, and it can also be a data pipeline bug. First confirm,
then new data, retraining, compare in MLflow, and deploy with CI/CD.

Your score: ______ / 20