Challenge - 5 Problems
Output Format Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output format of model predictions in JSON
Given a model that predicts labels for images, what is the output format of the following code snippet?
Prompt Engineering / GenAI
predictions = model.predict(images)
output = [{"image_id": i, "label": label} for i, label in enumerate(predictions)]
print(output)Attempts:
2 left
💡 Hint
Look at how the list comprehension builds dictionaries with keys 'image_id' and 'label'.
✗ Incorrect
The code creates a list of dictionaries, each with keys 'image_id' and 'label', pairing the index with the predicted label.
❓ Metrics
intermediate2:00remaining
Interpreting accuracy output format
After training a classification model, the accuracy is printed as follows. What is the type and format of the accuracy output?
Prompt Engineering / GenAI
accuracy = model.evaluate(test_data) print(f"Accuracy: {accuracy}")
Attempts:
2 left
💡 Hint
Model evaluation usually returns numeric metrics as floats.
✗ Incorrect
The evaluate method returns a float representing the overall accuracy between 0 and 1.
❓ Model Choice
advanced2:00remaining
Choosing output format for multi-label classification
You build a multi-label classifier that predicts multiple labels per input. Which output format best represents the model predictions?
Attempts:
2 left
💡 Hint
Multi-label means multiple labels per input, so output must allow multiple labels.
✗ Incorrect
A list of label indices per input clearly shows multiple labels predicted for each example.
🔧 Debug
advanced2:00remaining
Identifying output format error in prediction code
What error occurs when running this code that formats model output incorrectly?
Prompt Engineering / GenAI
preds = model.predict(data)
formatted = {i: preds[i] for i in preds}
print(formatted)Attempts:
2 left
💡 Hint
Check the type of preds and how it is used in the dict comprehension.
✗ Incorrect
preds is a list, so iterating over it yields values, not keys, causing KeyError when indexing.
🧠 Conceptual
expert2:00remaining
Best practice for output format in AI model serving
When serving an AI model via an API, which output format is best for easy parsing and extensibility?
Attempts:
2 left
💡 Hint
Consider formats that are human-readable and easy to extend with new fields.
✗ Incorrect
JSON is widely supported, human-readable, and allows adding extra info like confidence and metadata.