0
0
ML Pythonprogramming~20 mins

Residual analysis in ML Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Residual Analysis Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding Residuals in Regression

What does a residual represent in a regression model?

AThe predicted value of the dependent variable
BThe difference between the observed value and the predicted value
CThe average value of the dependent variable
DThe slope of the regression line
Attempts:
2 left
Predict Output
intermediate
2:00remaining
Calculate Residuals from Predictions

Given the true values and predicted values below, what is the list of residuals?

ML Python
true_values = [10, 15, 20, 25]
predicted_values = [8, 14, 22, 24]
residuals = [true - pred for true, pred in zip(true_values, predicted_values)]
print(residuals)
A[2, 1, 2, -1]
B[-2, -1, 2, -1]
C[2, -1, -2, 1]
D[2, 1, -2, 1]
Attempts:
2 left
Metrics
advanced
2:00remaining
Choosing the Correct Residual Metric

Which metric best summarizes the average magnitude of residuals without canceling positive and negative errors?

AMean Residual
BMean Squared Error (MSE)
CMean Absolute Error (MAE)
DResidual Sum
Attempts:
2 left
🔧 Debug
advanced
2:00remaining
Identify the Error in Residual Calculation Code

What error will this code produce when calculating residuals?

ML Python
true_vals = [5, 7, 9]
pred_vals = [4, 6]
residuals = [t - p for t, p in zip(true_vals, pred_vals)]
print(residuals)
ANo error; outputs [1, 1]
BIndexError due to different list lengths
CTypeError due to subtraction of incompatible types
DValueError due to zip mismatch
Attempts:
2 left
Model Choice
expert
3:00remaining
Model Selection Based on Residual Patterns

You observe a pattern in residuals that increases with predicted values, indicating heteroscedasticity. Which model adjustment is best to address this?

AUse weighted least squares regression giving less weight to points with larger residuals
BSwitch to a linear regression without intercept
CIncrease the number of features in the model
DUse a decision tree regression without residual analysis
Attempts:
2 left