Spaces:
Paused
Paused
Download server/tasks/task_expert.py from Adity00/dqa-openenv: direct link, hf CLI and curl.
- Browser
- Download file 3.18 kB
-
https://huggingface.co/spaces/Adity00/dqa-openenv/resolve/main/server/tasks/task_expert.py
- Command line
-
hf download hf://spaces/Adity00/dqa-openenv/server/tasks/task_expert.py
-
curl -L -o task_expert.py https://huggingface.co/spaces/Adity00/dqa-openenv/resolve/main/server/tasks/task_expert.py
3.18 kB
| """Task definition for Expert tier: Medical Records Quality Assurance.""" | |
| TASK_ID = "expert" | |
| TASK_NAME = "Medical Records Quality Assurance" | |
| TASK_DIFFICULTY = "expert" | |
| MAX_STEPS = 35 | |
| TASK_DESCRIPTION = """ | |
| You are a data quality agent working on a medical records dataset. | |
| The dataset has 300 rows (plus duplicates) and 12 columns: | |
| patient_id, age, gender, diagnosis, blood_glucose, blood_pressure_systolic, | |
| bmi, medication, admission_date, days_admitted, discharge_status, insurance_type. | |
| Your job is to fix these quality issues: | |
| 1. blood_glucose column has ~20% missing values β fill with median | |
| 2. bmi column has invalid sentinel values of -1.0 β filter those rows out | |
| 3. Duplicate patient records exist β remove them | |
| 4. medication column has casing variants (Metformin, LISINOPRIL, None, Albuterol) | |
| β normalize to lowercase | |
| 5. discharge_status column has casing variants (Recovered, DECEASED, Transferred) | |
| β normalize to lowercase | |
| 6. Some diabetes patients have blood_glucose=80 (statistically valid but | |
| medically impossible β diabetic patients must have blood_glucose > 100) | |
| SEMANTIC RULES (cross-column, graded separately): | |
| diagnosis='diabetes' -> blood_glucose must be > 100 | |
| diagnosis='healthy' -> medication must be 'none' | |
| bmi must be in range [10, 60] | |
| IMPORTANT: The semantic rules contribute 30% of your final score. | |
| Fixing bmi=-1.0 rows and medication casing directly improves semantic score. | |
| You have {max_steps} steps. Call submit() when satisfied. | |
| """.strip() | |
| SYSTEM_PROMPT = """ | |
| You are a data cleaning expert. You will receive a dataset description | |
| and must output a single JSON action to clean the data step by step. | |
| Always respond with valid JSON in this exact format: | |
| { | |
| "action_type": "<action_name>", | |
| "column": "<column_name_or_null>", | |
| "parameters": {} | |
| } | |
| Valid action_types: fill_nulls, drop_duplicates, cast_type, | |
| normalize_category, clip_outliers, drop_column, filter_rows, | |
| merge_categories, submit, noop | |
| Key strategy for this task (follow this order EXACTLY): | |
| 1. fill_nulls on blood_glucose with strategy median | |
| 2. filter_rows to remove invalid bmi β condition: "bmi >= 10 and bmi <= 60" | |
| 3. drop_duplicates | |
| 4. normalize_category on medication with this EXACT mapping: | |
| {"Metformin": "metformin", "LISINOPRIL": "lisinopril", | |
| "None": "none", "Albuterol": "albuterol"} | |
| 5. normalize_category on discharge_status with this EXACT mapping: | |
| {"Recovered": "recovered", "DECEASED": "deceased", | |
| "Transferred": "transferred"} | |
| 6. submit | |
| CRITICAL: For normalize_category you MUST include the mapping in parameters. | |
| The correct JSON for step 4 is: | |
| { | |
| "action_type": "normalize_category", | |
| "column": "medication", | |
| "parameters": { | |
| "mapping": { | |
| "Metformin": "metformin", | |
| "LISINOPRIL": "lisinopril", | |
| "None": "none", | |
| "Albuterol": "albuterol" | |
| } | |
| } | |
| } | |
| The correct JSON for step 2 is: | |
| { | |
| "action_type": "filter_rows", | |
| "column": null, | |
| "parameters": { | |
| "condition": "bmi >= 10 and bmi <= 60" | |
| } | |
| } | |
| Do NOT call normalize_category without the mapping β it will do nothing. | |
| If no more actions needed: {"action_type": "submit", "column": null, "parameters": {}} | |
| """.strip() | |