Complete the code to import the regression testing module.
import [1]
We use pytest for regression testing in Python because it supports test automation and easy test writing.
Complete the code to define a regression test function that checks if the output matches expected.
def test_model_output(): result = model.predict(data) assert result == [1]
None which would always fail the test.The test compares the model's prediction result to the expected_output to detect regressions.
Fix the error in the test assertion to correctly check if the model's accuracy is above 90%.
def test_accuracy(): accuracy = model.evaluate(test_data) assert accuracy [1] 0.9
The test should assert that accuracy is greater than or equal to 0.9 to pass.
Fill both blanks to create a regression test that filters results and checks if all are above threshold.
filtered_results = [r for r in results if r [1] threshold] assert all(r [2] threshold for r in filtered_results)
The list comprehension filters results greater than threshold, and the assertion checks all are greater or equal to threshold.
Fill all three blanks to create a dictionary comprehension that maps features to values only if value is above limit.
filtered_dict = [1]: [2] for [3], [2] in features.items() if [2] > limit}
The comprehension uses feature as key and value as value, iterating over features.items().