0
0
Intro to Computingfundamentals~20 mins

Training data and models in Intro to Computing - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Training Data and Models Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What is the main purpose of training data in machine learning?

Imagine you want to teach a computer to recognize pictures of cats. What role does the training data play in this process?

AIt provides examples for the model to learn patterns from.
BIt tests how well the model performs on new data.
CIt stores the final predictions made by the model.
DIt cleans and prepares the data before training.
Attempts:
2 left
💡 Hint

Think about what the model needs to see to learn.

🔍 Analysis
intermediate
2:00remaining
What is the output of this Python code simulating model training?

Consider this simple code that simulates training a model by counting how many times a value appears in training data.

Intro to Computing
training_data = ['cat', 'dog', 'cat', 'bird', 'dog', 'cat']
model = {}
for item in training_data:
    model[item] = model.get(item, 0) + 1
print(model)
ASyntaxError
B{'cat': 3, 'dog': 2, 'bird': 1}
C{'cat': 3, 'dog': 3, 'bird': 1}
D{'cat': 2, 'dog': 2, 'bird': 1}
Attempts:
2 left
💡 Hint

Count how many times each animal appears in the list.

data_output
advanced
2:00remaining
What is the shape of the training data matrix after preprocessing?

You have 1000 images, each resized to 28x28 pixels and converted to grayscale. The images are stored as a NumPy array for training.

What will be the shape of the training data array?

A(1000, 28, 28)
B(28, 28, 1000)
C(1000, 784)
D(784, 1000)
Attempts:
2 left
💡 Hint

Think about flattening each 28x28 image into a single row vector.

visualization
advanced
2:00remaining
Which plot best shows model performance over training epochs?

You trained a model for 10 epochs and recorded accuracy after each epoch. Which plot type best visualizes this change over time?

ALine plot showing accuracy on the y-axis and epochs on the x-axis.
BBar chart showing accuracy for each class.
CScatter plot of accuracy vs. number of training samples.
DPie chart showing percentage of correct predictions.
Attempts:
2 left
💡 Hint

Think about how to show change over a sequence of steps.

🔍 Analysis
expert
2:00remaining
What error does this code raise when training a model with mismatched data?

Look at this code snippet where features and labels have different lengths.

Intro to Computing
features = [[1, 2], [3, 4], [5, 6]]
labels = [0, 1]
from sklearn.linear_model import LogisticRegression
model = LogisticRegression()
model.fit(features, labels)
ANo error, model trains successfully
BTypeError: unsupported operand type(s) for +: 'int' and 'list'
CIndexError: list index out of range
DValueError: Found input variables with inconsistent numbers of samples
Attempts:
2 left
💡 Hint

Check if the number of feature rows matches the number of labels.