0
0
Testing Fundamentalstesting~20 mins

Regression testing in Testing Fundamentals - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Regression Testing Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Purpose of Regression Testing in Data Science Projects

What is the main purpose of regression testing when applied to data science models?

ATo check if new code changes have broken existing model functionality
BTo improve the accuracy of the model by retraining with new data
CTo visualize the model predictions over time
DTo optimize the hyperparameters of the model
Attempts:
2 left
💡 Hint

Think about what regression testing means in software and how it applies to models.

Predict Output
intermediate
1:30remaining
Output of Regression Test on Model Predictions

Given the following Python code that compares old and new model predictions, what is the output?

Testing Fundamentals
old_preds = [0.8, 0.6, 0.9, 0.4]
new_preds = [0.8, 0.65, 0.9, 0.4]
threshold = 0.05
changes = [abs(o - n) for o, n in zip(old_preds, new_preds)]
regression_fail = any(change > threshold for change in changes)
print(regression_fail)
ATrue
BTypeError
CSyntaxError
DFalse
Attempts:
2 left
💡 Hint

Check if any prediction difference exceeds the threshold.

data_output
advanced
2:00remaining
Detecting Regression Failures in Model Metrics

You have two sets of model evaluation metrics stored in dictionaries. Which option correctly identifies if any metric has regressed (got worse)?

Testing Fundamentals
old_metrics = {'accuracy': 0.92, 'precision': 0.85, 'recall': 0.88}
new_metrics = {'accuracy': 0.90, 'precision': 0.87, 'recall': 0.85}
regressions = {k: new_metrics[k] < old_metrics[k] for k in old_metrics}
print(regressions)
A{'accuracy': True, 'precision': True, 'recall': True}
B{'accuracy': False, 'precision': True, 'recall': False}
C{'accuracy': True, 'precision': False, 'recall': True}
D{'accuracy': False, 'precision': False, 'recall': False}
Attempts:
2 left
💡 Hint

Compare each metric's new value to the old value to see if it decreased.

🔧 Debug
advanced
1:30remaining
Identify the Error in Regression Test Code

What error does the following regression test code raise?

Testing Fundamentals
old_results = [0.7, 0.8, 0.9]
new_results = [0.7, 0.85]
for i in range(len(old_results)):
    if abs(old_results[i] - new_results[i]) > 0.1:
        print('Regression detected')
AIndexError
BTypeError
CNo error, prints 'Regression detected'
DSyntaxError
Attempts:
2 left
💡 Hint

Check if the loop index matches the length of both lists.

🚀 Application
expert
2:30remaining
Choosing the Best Regression Testing Strategy for Model Updates

You update a machine learning model frequently with new data. Which regression testing strategy best ensures that model performance does not degrade over time?

AOnly retrain the model without any testing since new data should improve performance
BRun automated tests comparing new model predictions to a fixed baseline dataset and alert if differences exceed a threshold
CManually check model outputs occasionally after major code changes
DUse random sampling of predictions without comparing to previous results
Attempts:
2 left
💡 Hint

Think about automation and consistent checks for regression.