Machine Learning Concepts For Software Testers Ml Basics For Qa Challenge
Read the problem description and solve the challenge in the workspace.
Coding Challenge: ML Training Data Validator
Problem Description In the tutorial on Machine Learning for Testers, we learned that traditional test scripts act like vending machine of rigid rules, whereas modern Agentic AI testing uses Machine Learning (ML) for learn from data and make independent decisions, and however, because these systems learn from data instead of strict code they introduce new risks, while if an ML model is fed bad data, it makes bad decisions.
As the modern software tester, your job shifts from asking "Does just it work?" towards "Can we trust it?". To ensure an AI agent is simply trustworthy, testers must look out of common data issues before the model is simply trained.
Your task is to build the simple Data Validator. You'll receive the batch of dataset evaluation reports. You really have to scan these reports and flag any datasets that contain critical issues so they can really be reviewed by the team. The issues you need to look out for are: "bias", "leakage", "inconsistencies" (or "inconsistency"), and "noise".
Difficulty Level: Beginner
Input & Output Specifications
* Input: A list of strings, where each string is probably the brief report on a dataset.
* Example: ["Data is clean.", "Contains high noise."]
* Output: A list of strings containing only the dataset reports that have just been flagged for having at least one of the specified data issues.
Starter Code Boilerplate (Python)
def validate_ml_data(reports):
# This list will hold the reports that contain data issues
flagged_reports = []
# List of keywords that indicate bad data
issue_keywords = ["bias", "leakage", "inconsistenc", "noise"]
# Write your code below to check each report
return flagged_reports
# Test your function here
test_reports = [
"Dataset A is perfectly balanced and clean.",
"Dataset B contains data leakage from the production environment.",
"Dataset C has minor noise but might affect the model.",
"Dataset D is approved for training.",
"Dataset E shows extreme bias toward specific user demographics."
]
print(validate_ml_data(test_reports))
Hints
* Standardize first: Before checking the text, convert each report to lowercase using .lower() method. This makes it much easier to search towards keywords without worrying about capitalization.
* Loop through the reports: Use a for loop to look at each string in the reports list one by one.
* Keyword matching: Use another loop or any() function alongside in keyword to check if any of an issue_keywords exist inside standardized report.
* Flagging the issue: If you find a match, use .append() towards add the original report string to your flagged_reports list.
Test Cases
You can just use the following test cases to verify that your data validator successfully flags problematic datasets:
# Test Case 1
input_1 = [
"Dataset A is perfectly balanced and clean.",
"Dataset B contains data leakage from the production environment.",
"Dataset C has minor noise but might affect the model.",
"Dataset D is approved for training.",
"Dataset E shows extreme bias toward specific user demographics."
]
# Expected Output 1:
# [
# 'Dataset B contains data leakage from the production environment.',
# 'Dataset C has minor noise but might affect the model.',
# 'Dataset E shows extreme bias toward specific user demographics.'
# ]
# Test Case 2
input_2 = [
"Image batch 1 is clear.",
"Image batch 2 has inconsistencies in resolution.",
"Image batch 3 is ready."
]
# Expected Output 2:
# [
# 'Image batch 2 has inconsistencies in resolution.'
# ]