Which statement best describes the relationship between bias and variance in a machine learning model?
Think about how a model behaves when it is too simple or too complex.
Bias measures error from wrong assumptions (underfitting), variance measures error from sensitivity to training data (overfitting). High bias means underfitting, high variance means overfitting.
Consider the following Python code that simulates training and test errors for models of increasing complexity. What is the output of the print statement?
import numpy as np complexity = np.array([1, 2, 3, 4, 5]) train_error = 1 / complexity test_error = 1 / complexity + 0.1 * complexity print(f"Train error: {train_error}") print(f"Test error: {test_error}")
Look at how 1/complexity changes and how 0.1 * complexity affects test error.
Train error is 1/complexity, so it decreases as complexity grows. Test error adds a term increasing with complexity, so it first decreases then increases, showing bias-variance tradeoff.
You train a linear regression model with L2 regularization (Ridge). Increasing the regularization parameter lambda will most likely:
Think about how regularization controls model complexity.
Increasing lambda penalizes large weights, simplifying the model, which increases bias but reduces variance.
You observe the following behavior in learning curves: training error is high and stable, but test error is high and does not improve with more data. What does this indicate about the model?
Think about what high training error and high test error means.
High training error and high test error that does not improve with more data suggests the model is too simple and underfits, showing high bias.
Given the following code snippet training a decision tree, what is the most likely cause of the model having high training error and high test error?
from sklearn.tree import DecisionTreeClassifier
model = DecisionTreeClassifier(max_depth=1)
model.fit(X_train, y_train)
train_acc = model.score(X_train, y_train)
test_acc = model.score(X_test, y_test)
print(f"Train accuracy: {train_acc}")
print(f"Test accuracy: {test_acc}")Consider how tree depth affects model complexity and errors.
A decision tree with max_depth=1 is very simple, likely underfitting, which causes low training accuracy and low test accuracy due to high bias.
